{"id":21529049,"url":"https://github.com/newbeea/nuxt3-apollo-module","last_synced_at":"2026-03-06T16:34:50.378Z","repository":{"id":41245575,"uuid":"441449420","full_name":"newbeea/nuxt3-apollo-module","owner":"newbeea","description":null,"archived":false,"fork":false,"pushed_at":"2022-09-29T11:36:23.000Z","size":58,"stargazers_count":33,"open_issues_count":10,"forks_count":8,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-09-26T15:31:58.901Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/newbeea.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-12-24T11:33:36.000Z","updated_at":"2024-07-04T07:19:43.000Z","dependencies_parsed_at":"2022-07-12T23:10:30.819Z","dependency_job_id":null,"html_url":"https://github.com/newbeea/nuxt3-apollo-module","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/newbeea/nuxt3-apollo-module","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/newbeea%2Fnuxt3-apollo-module","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/newbeea%2Fnuxt3-apollo-module/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/newbeea%2Fnuxt3-apollo-module/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/newbeea%2Fnuxt3-apollo-module/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/newbeea","download_url":"https://codeload.github.com/newbeea/nuxt3-apollo-module/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/newbeea%2Fnuxt3-apollo-module/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30185560,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-06T14:42:24.748Z","status":"ssl_error","status_checked_at":"2026-03-06T14:42:14.925Z","response_time":250,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-24T01:55:40.512Z","updated_at":"2026-03-06T16:34:45.368Z","avatar_url":"https://github.com/newbeea.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @nuxt3/apollo-module\n\nApollo module for nuxt3\n\n## Demo\n[nuxt3-apollo-starter](https://github.com/newbeea/nuxt3-apollo-starter)\n\n## Installation\n\n```bash\nnpm i -D @nuxt3/apollo-module\n```\n\n## Configuration\n```js\n// nuxt.config.js\nimport '@nuxt3/apollo-module' // import to remove config warning, not necessary\nexport default {\n  buildModules: [\n    '@nuxt3/apollo-module'\n  ],\n  apollo: {\n    clientConfigs: {\n      default: {\n        // see https://www.apollographql.com/docs/react/api/core/ApolloClient/#ApolloClient.constructor\n      },\n      client1: {\n        // another client\n      },\n      client2: {\n        // authentication type\n        authenticationType: 'Bearer', // default 'Bearer'\n      }\n    },\n    // Cookie parameters used to store authentication token\n    cookieAttributes: {\n      /**\n        * Define when the cookie will be removed. Value can be a Number\n        * which will be interpreted as days from time of creation or a\n        * Date instance. If omitted, the cookie becomes a session cookie.\n        */\n      expires: 7,\n\n      /**\n        * Define the path where the cookie is available. Defaults to '/'\n        */\n      path: '/',\n\n      /**\n        * Define the domain where the cookie is available. Defaults to\n        * the domain of the page where the cookie was created.\n        */\n      domain: 'example.com',\n\n      /**\n        * A Boolean indicating if the cookie transmission requires a\n        * secure protocol (https). Defaults to false.\n        */\n      secure: false,\n    },\n  }\n}\n```\n\n## Usage\nQuery code(You can use[@nuxt3/graphql-codegen-module](https://github.com/newbeea/nuxt3-graphql-codegen-module) to generate code)\n```\nimport gql from 'graphql-tag'\nimport * as VueApolloComposable from '@vue/apollo-composable'\n\nexport const HelloDocument = gql`\n  query Hello {\n    world\n  }\n\n`\n\nexport function useHelloQuery() {\n  return VueApolloComposable.useQuery\u003cany, any\u003e(HelloDocument, {}, {\n    // prefetch: false, // prefetch: false will fetch on client\n  })\n}\n```\n\nFetch in setup\n```\n\u003cscript setup lang=\"ts\"\u003e\nimport { useHelloQuery } from '@/api'\n\n// default client\nconst { result, loading } = await useHelloQuery() \n// result: { \"world\": \"Hello world!\" }\n\n// use client by id\nconst { result, loading } = await useHelloQuery({\n  clientId: 'client1'\n}) \n// result: { \"world\": \"Hello world!\" }\n\n// client only \nconst { result, loading } = await useHelloQuery({\n  prefetch: false\n}) \n// result: { \"world\": \"Hello world!\" } (check 'result \u0026\u0026 result.world' in template is necessary)\n\u003c/script\u003e\n```\n\nAuthentication\nYou have following methods for authentication available:\n```js\n // set your graphql-token\n $apolloHelpers.onLogin(token /* if not default you can pass in clientId as second argument, you can set custom cookies attributes object as the third argument, and you can skip reset store as the fourth argument */)\n // unset your graphql-token\n $apolloHelpers.onLogout(/* if not default you can pass in clientId as first argument, and you can skip reset store as the second argument */)\n // get your current token (we persist token in a cookie)\n $apolloHelpers.getToken(/* you can provide clientId */)\n ```\n\nUser login\n```js\nimport { useLoginMutation } from '@/generated/operations' // generated by @nuxt3/graphql-codegen-module\nconst { mutate: login, onDone } = useLoginMutation({\n})\nconst { $apolloHelpers } = useNuxtApp()\nonDone((res) =\u003e {\n  const token = res.data.login.token // based on your resolver\n  $apolloHelpers.onLogin(token)\n})\n```\n\nUser logout\n```js\n// ~/components/my-component.js\n\nconst { $apolloHelpers } = useNuxtApp()\nconst logout = () =\u003e {\n  $apolloHelpers.onLogout()\n}\n```\n\n## Dev\n\n```\npnpm i\n```\n\n```\npnpm run build\n```\n\n\n\n## License\n\nMIT License © 2021-PRESENT [Phil xu](https://github.com/newbeea)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnewbeea%2Fnuxt3-apollo-module","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnewbeea%2Fnuxt3-apollo-module","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnewbeea%2Fnuxt3-apollo-module/lists"}