{"_id":"@7span/nuxt-apollo-module","_rev":"4-24c91dd0d9c6acf8f05daff8578c59ad","name":"@7span/nuxt-apollo-module","dist-tags":{"latest":"4.0.1-rc.8"},"versions":{"4.0.1-rc.5":{"name":"@7span/nuxt-apollo-module","version":"4.0.1-rc.5","license":"MIT","main":"lib/module.js","typings":"types/index.d.ts","repository":{"type":"git","url":"git+https://github.com/nuxt-community/apollo-module.git"},"homepage":"https://github.com/nuxt-community/apollo-module","publishConfig":{"access":"public"},"scripts":{"dev":"nuxt test/fixture","dev2":"nuxt test/fixture-static-auth","dev3":"nuxt test/fixture-multi-endpoints","dev4":"nuxt test/fixture-local-state","lint":"eslint lib test","test":"yarn test:fixtures && yarn test:types","test:fixtures":"jest --forceExit","test:types":"tsc -p types/test","release":"standard-version --prerelease rc && git push --follow-tags && npm publish"},"dependencies":{"cross-fetch":"^3.0.6","universal-cookie":"^4.0.4","vue-apollo":"^3.0.5","vue-cli-plugin-apollo":"^0.22.2","webpack-node-externals":"^2.5.2"},"peerDependencies":{"@apollo/client":"^3.1.5"},"devDependencies":{"@babel/core":"latest","@babel/preset-env":"latest","@nuxt/types":"latest","@nuxtjs/eslint-config":"latest","@types/graphql":"latest","@types/universal-cookie":"latest","babel-eslint":"latest","babel-jest":"latest","codecov":"latest","dotenv":"latest","eslint":"latest","graphql-tag":"latest","jest":"latest","jsdom":"latest","nuxt-edge":"latest","standard-version":"latest","typescript":"latest"},"gitHead":"5d6d3ae48c730d483a9ba68e955cf09822296300","description":"* Nuxt.js module to use [vue-apollo](https://github.com/Akryum/vue-apollo) * uses internally same approach as [vue-cli-plugin-apollo](https://github.com/Akryum/vue-cli-plugin-apollo)","bugs":{"url":"https://github.com/nuxt-community/apollo-module/issues"},"_id":"@7span/nuxt-apollo-module@4.0.1-rc.5","_nodeVersion":"14.17.5","_npmVersion":"6.14.14","dist":{"integrity":"sha512-hv12PJAO6HO7Gj1SRj+nLN+D/jmEk6NDZ3ChPVhr8Wr1bNN7wVzlparDtYTUQB9fHC8JygsfOTTLnbGkVTe7ZA==","shasum":"f20706799cacbef72f0da2d0da983c09277b5f89","tarball":"https://registry.npmjs.org/@7span/nuxt-apollo-module/-/nuxt-apollo-module-4.0.1-rc.5.tgz","fileCount":9,"unpackedSize":29912,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiIb8QACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpbZw//Rv7BnyutncZC2HTO85lfexMhS+EEPnEnXeuHelV7wzRoKcqx\r\nJOAUcpetwFrsRez/4ItIRD0f9SeewovHSL7pDUsh26gkq5IC/tv+x+7ht5LG\r\nuCMUBNcjRv046jHZqQ41l2PS0IFHH3y3xDQeVsjDobQ1O5K9Nzh/oxiF9oWj\r\n1zbDDuJ4uEo0mXJAqam00bYh4fped/bz47fc4PeI6hjb48IyxPK9X9mmEmTK\r\nTHE7SLoq2QZlGpvDG4NMud9uKYEOVCxRfYdm/peaeIXa4zfIx64C8YJ7/2wd\r\nz+IJgrBkGcfHiLx8HtbISUCvWLCUXo2GDke2LwvgyKV7IqDWo3+0j63eRWcX\r\nE9lWn/uuHWWoC74ZaNuVhOc55RQNL0ddRKiKnyLfaRSI8aj3ZueI1aOcl8qq\r\nhFLAZ4YucQA8ajlJDCvN8w/Koq/4MH0U6BHcHnOEI0Z7OFPdhdF3t1FJmO6A\r\npgN1xYU/LqjxTApUw9HziGsiIhSMcmOrtxPh3oLtkbWu/O0UNlcR8zIBN3uF\r\nK32wtkQisgXOCBekO3tjU7D5Skt2lk8unYdnh3qk4/5YM4NfUMkJtGAvBJTD\r\nVWcPDzK5tVSW3EdtaNtZ7eH2n6ayBJCrwKfM8GXpw7lVxVgJM6gjI8Bg8IGU\r\nYMa+Zvq0LApN7WJDidvZZN5+xwD0nHvE0GA=\r\n=rwmU\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBl438c6J1pfXpe2O1LV5jGQy9fnw//BQw9OzDKFJRdXAiEA1467npLfp6I3r/xqfX1khGKcTtUcbgJHOr2Ph3TQ6M8="}]},"_npmUser":{"name":"theharsh","email":"mail@theharsh.in"},"directories":{},"maintainers":[{"name":"theharsh","email":"mail@theharsh.in"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/nuxt-apollo-module_4.0.1-rc.5_1646378768740_0.6173202893531173"},"_hasShrinkwrap":false},"4.0.1-rc.6":{"name":"@7span/nuxt-apollo-module","version":"4.0.1-rc.6","license":"MIT","main":"lib/module.js","typings":"types/index.d.ts","repository":{"type":"git","url":"git+https://github.com/nuxt-community/apollo-module.git"},"homepage":"https://github.com/nuxt-community/apollo-module","publishConfig":{"access":"public"},"scripts":{"dev":"nuxt test/fixture","dev2":"nuxt test/fixture-static-auth","dev3":"nuxt test/fixture-multi-endpoints","dev4":"nuxt test/fixture-local-state","lint":"eslint lib test","test":"yarn test:fixtures && yarn test:types","test:fixtures":"jest --forceExit","test:types":"tsc -p types/test","release":"standard-version --prerelease rc && git push --follow-tags && npm publish"},"dependencies":{"cross-fetch":"^3.0.6","universal-cookie":"^4.0.4","vue-apollo":"^3.1.0","vue-cli-plugin-apollo":"^0.22.2","webpack-node-externals":"^2.5.2"},"devDependencies":{"@babel/core":"latest","@babel/preset-env":"latest","@nuxt/types":"latest","@nuxtjs/eslint-config":"latest","@types/graphql":"latest","@types/universal-cookie":"latest","babel-eslint":"latest","babel-jest":"latest","codecov":"latest","dotenv":"latest","eslint":"latest","graphql-tag":"latest","jest":"latest","jsdom":"latest","nuxt-edge":"latest","standard-version":"latest","typescript":"latest"},"gitHead":"1cb19403913284092a47a5c3ab56f9889a943885","description":"* Nuxt.js module to use [vue-apollo](https://github.com/Akryum/vue-apollo) * uses internally same approach as [vue-cli-plugin-apollo](https://github.com/Akryum/vue-cli-plugin-apollo)","bugs":{"url":"https://github.com/nuxt-community/apollo-module/issues"},"_id":"@7span/nuxt-apollo-module@4.0.1-rc.6","_nodeVersion":"16.14.2","_npmVersion":"8.5.0","dist":{"integrity":"sha512-NXd6vXn5vlyDLQasVMdq+HibkliIMQJfMwhwBLpAOjD5K6zVUE67+K3HDnhGmuX5kdwWnzm8mhDArzF7leGEjg==","shasum":"0f49704cb7c7c97bd79982dd4c80f35ee1899e16","tarball":"https://registry.npmjs.org/@7span/nuxt-apollo-module/-/nuxt-apollo-module-4.0.1-rc.6.tgz","fileCount":8,"unpackedSize":28343,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEBKrU6ybwXjJKoZ7DvB5x9+mykf57Zvynzk8OpUGOcPAiB2JnIhySXJzW6ol45HDKSCQcow9QzKd7PH6DK494G9CA=="}]},"_npmUser":{"name":"theharsh","email":"mail@theharsh.in"},"directories":{},"maintainers":[{"name":"theharsh","email":"mail@theharsh.in"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/nuxt-apollo-module_4.0.1-rc.6_1690302471587_0.21942743691122124"},"_hasShrinkwrap":false},"4.0.1-rc.7":{"name":"@7span/nuxt-apollo-module","version":"4.0.1-rc.7","license":"MIT","main":"lib/module.js","typings":"types/index.d.ts","repository":{"type":"git","url":"git+https://github.com/nuxt-community/apollo-module.git"},"homepage":"https://github.com/nuxt-community/apollo-module","publishConfig":{"access":"public"},"scripts":{"dev":"nuxt test/fixture","dev2":"nuxt test/fixture-static-auth","dev3":"nuxt test/fixture-multi-endpoints","dev4":"nuxt test/fixture-local-state","build":"nuxt build","lint":"eslint lib test","test":"yarn test:fixtures && yarn test:types","test:fixtures":"jest --forceExit","test:types":"tsc -p types/test","release":"standard-version --prerelease rc && git push --follow-tags && npm publish"},"dependencies":{"cross-fetch":"^4.0.0","universal-cookie":"^6.1.1","vue-apollo":"^3.1.1","vue-cli-plugin-apollo":"^0.22.2","webpack-node-externals":"^3.0.0"},"devDependencies":{"@babel/core":"^7.22.19","@babel/preset-env":"^7.22.15","@nuxt/types":"^2.17.1","@nuxtjs/eslint-config":"^12.0.0","@types/graphql":"^14.5.0","@types/universal-cookie":"^3.0.0","babel-eslint":"^10.1.0","babel-jest":"^29.7.0","codecov":"^3.8.3","dotenv":"^16.3.1","eslint":"^8.49.0","graphql-tag":"^2.12.6","jest":"^29.7.0","jsdom":"^22.1.0","nuxt-edge":"^2.17.2-28245622.53dfec7","standard-version":"^9.5.0","typescript":"^5.2.2"},"gitHead":"d59b72c3c6d8a84b4dc4155a91852908c131676a","description":"* Nuxt.js module to use [vue-apollo](https://github.com/Akryum/vue-apollo) * uses internally same approach as [vue-cli-plugin-apollo](https://github.com/Akryum/vue-cli-plugin-apollo)","bugs":{"url":"https://github.com/nuxt-community/apollo-module/issues"},"_id":"@7span/nuxt-apollo-module@4.0.1-rc.7","_nodeVersion":"18.17.0","_npmVersion":"9.6.7","dist":{"integrity":"sha512-Cao7HUDBJgZguaXhMAWSj4vjEzcqEEDJcUvmJMkDujl3pSOT3lNrj9O91KWMev2gUrJtsGaXE31RJquuY2olRw==","shasum":"4cd67e45935aa2550ab1e045215c9c514d869f00","tarball":"https://registry.npmjs.org/@7span/nuxt-apollo-module/-/nuxt-apollo-module-4.0.1-rc.7.tgz","fileCount":8,"unpackedSize":28402,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIA5U2BkFUWcKv6AmGgvZFEUAQvn2HdsxzR2blSBZ6NR3AiA9mGtdcpi4mOBjD8fE3y68+jP4tTI65L0srk6/+Xt80Q=="}]},"_npmUser":{"name":"theharsh","email":"mail@theharsh.in"},"directories":{},"maintainers":[{"name":"theharsh","email":"mail@theharsh.in"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/nuxt-apollo-module_4.0.1-rc.7_1694757552552_0.9652002653661635"},"_hasShrinkwrap":false},"4.0.1-rc.8":{"name":"@7span/nuxt-apollo-module","version":"4.0.1-rc.8","license":"MIT","main":"lib/module.js","typings":"types/index.d.ts","repository":{"type":"git","url":"git+https://github.com/nuxt-community/apollo-module.git"},"homepage":"https://github.com/nuxt-community/apollo-module","publishConfig":{"access":"public"},"scripts":{"dev":"nuxt test/fixture","dev2":"nuxt test/fixture-static-auth","dev3":"nuxt test/fixture-multi-endpoints","dev4":"nuxt test/fixture-local-state","build":"nuxt build","lint":"eslint lib test","test":"yarn test:fixtures && yarn test:types","test:fixtures":"jest --forceExit","test:types":"tsc -p types/test","release":"standard-version --prerelease rc && git push --follow-tags && npm publish"},"dependencies":{"cross-fetch":"^4.0.0","universal-cookie":"^6.1.1","vue-apollo":"^3.1.0","webpack-node-externals":"^3.0.0"},"devDependencies":{"@babel/core":"^7.22.19","@babel/preset-env":"^7.22.15","@nuxt/types":"^2.17.1","@nuxtjs/eslint-config":"^12.0.0","@types/graphql":"^14.5.0","@types/universal-cookie":"^3.0.0","babel-eslint":"^10.1.0","babel-jest":"^29.7.0","codecov":"^3.8.3","dotenv":"^16.3.1","eslint":"^8.49.0","graphql-tag":"^2.12.6","jest":"^29.7.0","jsdom":"^22.1.0","nuxt-edge":"^2.17.2-28245622.53dfec7","standard-version":"^9.5.0","typescript":"^5.2.2"},"gitHead":"d59b72c3c6d8a84b4dc4155a91852908c131676a","description":"* Nuxt.js module to use [vue-apollo](https://github.com/Akryum/vue-apollo) * uses internally same approach as [vue-cli-plugin-apollo](https://github.com/Akryum/vue-cli-plugin-apollo)","bugs":{"url":"https://github.com/nuxt-community/apollo-module/issues"},"_id":"@7span/nuxt-apollo-module@4.0.1-rc.8","_nodeVersion":"18.17.0","_npmVersion":"9.6.7","dist":{"integrity":"sha512-kH3uJVr0hjI3boaNzV8pF/FG39vam/kTlr945vD0GoUQ9hLvsYpt4YTxqCbCkJrMPvGe5n7Y88eDkp9d96auLw==","shasum":"d91f4e6773d056c0b17f87bb36b61f4a8e15fbff","tarball":"https://registry.npmjs.org/@7span/nuxt-apollo-module/-/nuxt-apollo-module-4.0.1-rc.8.tgz","fileCount":8,"unpackedSize":28362,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCZ/AjdFD//ijpu6SfgS7KX+RAGqNnOQacL7/DG0k9bbgIhAJPSWnFrvPG2Iqy4YwdXSVzcfRnBm2xbItplYkPNGaxm"}]},"_npmUser":{"name":"theharsh","email":"mail@theharsh.in"},"directories":{},"maintainers":[{"name":"theharsh","email":"mail@theharsh.in"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/nuxt-apollo-module_4.0.1-rc.8_1695124642682_0.8357564680663097"},"_hasShrinkwrap":false}},"time":{"created":"2022-03-04T07:26:08.649Z","4.0.1-rc.5":"2022-03-04T07:26:08.890Z","modified":"2023-09-19T11:57:23.086Z","4.0.1-rc.6":"2023-07-25T16:27:51.810Z","4.0.1-rc.7":"2023-09-15T05:59:12.702Z","4.0.1-rc.8":"2023-09-19T11:57:22.906Z"},"maintainers":[{"name":"theharsh","email":"mail@theharsh.in"}],"description":"* Nuxt.js module to use [vue-apollo](https://github.com/Akryum/vue-apollo) * uses internally same approach as [vue-cli-plugin-apollo](https://github.com/Akryum/vue-cli-plugin-apollo)","homepage":"https://github.com/nuxt-community/apollo-module","repository":{"type":"git","url":"git+https://github.com/nuxt-community/apollo-module.git"},"bugs":{"url":"https://github.com/nuxt-community/apollo-module/issues"},"license":"MIT","readme":"# Apollo inside of NuxtJS\n\n* Nuxt.js module to use [vue-apollo](https://github.com/Akryum/vue-apollo)\n* uses internally same approach as [vue-cli-plugin-apollo](https://github.com/Akryum/vue-cli-plugin-apollo)\n\n[![npm version](https://img.shields.io/npm/v/@nuxtjs/apollo.svg)](https://www.npmjs.com/package/@nuxtjs/apollo)\n[![license](https://img.shields.io/github/license/nuxt-community/apollo-module.svg)](https://github.com/nuxt-community/apollo-module/blob/master/LICENSE)\n\n\n## Warning\n\nThis version requires Vue 2.6+ with serverPrefetch support. For example:\n\n```bash\nnpm install --save vue@2.6.6 vue-template-compiler@2.6.6 vue-server-renderer@2.6.6\n```\nSometime you may need to remove/rebuild package-lock.json/yarn.lock to make it work.\n\n## Setup\n\n### 1- Install apollo module\n\n```bash\nnpm install --save @nuxtjs/apollo\n```\n\nor \n\n```bash\nyarn add @nuxtjs/apollo\n```\n\n### 2- Load `@nuxtjs/apollo` module\n\n```js\n// nuxt.config.js\n\nexport default {\n  modules: [\n    '@nuxtjs/apollo',\n  ],\n\n  apollo: {\n    clientConfigs: {\n      default: {\n        httpEndpoint: 'http://localhost:4000',\n      }\n    }\n  }\n}\n```\n\n### 3- Loading `*.gql` or `*.graphql` files _(optional)_\n\nInstall `graphql-tag`\n   \n```bash\nnpm install --save graphql-tag\n```\n\nor \n\n```bash\nyarn add graphql-tag\n```\n\n#### :warning: Typescript users\n\nAdd a `gql.d.ts` file in your sources folder with the following content:\n```typescript\ndeclare module '*.gql' {\n  import { DocumentNode } from 'graphql'\n\n  const content: DocumentNode\n  export default content\n}\n\ndeclare module '*.graphql' {\n  import { DocumentNode } from 'graphql'\n\n  const content: DocumentNode\n  export default content\n}\n```\n\n## Usage\n\nYou have a successfully enabled `vue-apollo` in your project. \n\nCheckout [Official example](https://github.com/nuxt/nuxt.js/tree/dev/examples/vue-apollo) and [vue-apollo](https://apollo.vuejs.org/guide/apollo) official documentation for how to use `vue-apollo` inside your application\n\n## Advanced configuration\n\n```js\n{\n  // Add apollo module\n  modules: ['@nuxtjs/apollo'],\n\n  apollo: {\n    // Sets up the apollo client endpoints\n    clientConfigs: {\n      // recommended: use a file to declare the client configuration (see below for example)\n      default: '~/plugins/my-alternative-apollo-config.js',\n\n      // you can setup multiple clients with arbitrary names\n      alternativeClient: {\n        // required\n        httpEndpoint: 'http://localhost:4000',\n\n        // override HTTP endpoint in browser only\n        browserHttpEndpoint: '/graphql',\n\n        // See https://www.apollographql.com/docs/link/links/http.html#options\n        httpLinkOptions: {\n          credentials: 'same-origin'\n        },\n\n        // You can use `wss` for secure connection (recommended in production)\n        // Use `null` to disable subscriptions\n        wsEndpoint: 'ws://localhost:4000',\n\n        // LocalStorage token\n        tokenName: 'apollo-token',\n\n        // Enable Automatic Query persisting with Apollo Engine\n        persisting: false,\n\n        // Use websockets for everything (no HTTP)\n        // You need to pass a `wsEndpoint` for this to work\n        websocketsOnly: false\n      },\n    },\n    \n    /**\n     * default 'apollo' definition\n     */\n    defaultOptions: {\n      // See 'apollo' definition\n      // For example: default query options\n      $query: {\n        loadingKey: 'loading',\n        fetchPolicy: 'cache-and-network',\n      },\n    },\n    \n    // setup a global query loader observer (see below for example)\n    watchLoading: '~/plugins/apollo-watch-loading-handler.js',\n    \n    // setup a global error handler (see below for example)\n    errorHandler: '~/plugins/apollo-error-handler.js',\n\n    // Sets the authentication type for any authorized request.\n    authenticationType: 'Bearer', \n\n    // Token name for the cookie which will be set in case of authentication\n    tokenName: 'apollo-token',\n\n    // [deprecated] Enable the graphql-tag/loader to parse *.gql/*.graphql files\n    includeNodeModules: true,\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\n#### Apollo `clientOptions` using file configuration\n\n:warning: In case you need to declare functions (like `getAuth` or `inMemoryCacheOptions.fragmentMatcher`) inside apollo configuration, you **MUST** define your `clientOptions` using an external file\n\n```js\n// ~/plugins/my-alternative-apollo-config.js\n\nexport default (context) => {\n  return {\n    httpEndpoint: 'http://localhost:4000/graphql-alt',\n\n    /*\n     * For permanent authentication provide `getAuth` function.\n     * The string returned will be used in all requests as authorization header\n     */\n    getAuth: () => 'Bearer my-static-token',\n  }\n}\n```\n\n\n#### `watchLoading` example\n\n```js\n// ~/plugins/apollo-watch-loading-handler.js\n\nexport default (isLoading, countModifier, nuxtContext) => {\n  loading += countModifier\n  console.log('Global loading', loading, countModifier)\n}\n\n```\n\n#### `errorHandler` example\n\n```js\n// ~/plugins/apollo-error-handler.js\n\nexport default ({ graphQLErrors, networkError, operation, forward }, nuxtContext) => {\n  console.log('Global error handler')\n  console.log(graphQLErrors, networkError, operation, forward)\n}\n\n```\n\n## Options\nYou can either (in a simple setup) just add an object as described above. If you need to overwrite cache or the default `getAuth()` function then use a path to your config file which returns the client config options.\n### clientConfigs `Option`: required\nSets up the apollo client endpoints. All available options for each endpoint you find [here](https://github.com/Akryum/vue-cli-plugin-apollo/blob/master/graphql-client/src/index.js#L15)\n\nCheck out [official vue-apollo-cli](https://github.com/Akryum/vue-cli-plugin-apollo) where possible usecases are presented.\n\n#### clientConfigs.default `Object`: required\n\n#### clientConfigs.<your-additional-client-key> `Object|Path`: optional\n\n### tokenName `String`: optional, default: 'apollo-token'\n\nToken name for the cookie which will be set in case of authentication. You can also provide an option `tokenName` in each of your `clientConfigs` to overwrite the default. When each request is made, the value of whatever is in this cooke will be sent in an \"Authorization\" HTTP header as specified by `authenticationType` below.\n\n### authenticationType `String`: optional, default: 'Bearer'\n\nSets the authentication type for any authorized request. Modify this if the authentication type your GraphQL API requires is not the default `Bearer`. All requests will then be sent with the appropriate HTTP header in the format: \"Authorization: <authenticationType> <your token taken from user cookies>\" (Eg. `Authorization: Bearer abc123`). \n  \nIf your backend requires an Authorization header in the format \"Authorization: <your token>\", without any prefix, then you should set this value to an empty string.\n\n### includeNodeModules `Boolean`: optional, default: false\n\nIn case you use `*.gql` files inside of `node_module` folder you can enable the `graphql-tag/loader` to parse the files for you.\n\n\n## Authentication\n\nYou have following methods for authentication available:\n```js\n // set your graphql-token\n this.$apolloHelpers.onLogin(token /* if not default you can pass in client 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 this.$apolloHelpers.onLogout(/* if not default you can pass in client 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 this.$apolloHelpers.getToken(/* you can provide named tokenName if not 'apollo-token' */)\n```\nCheck out the [full example](https://github.com/nuxt-community/apollo-module/tree/master/test/fixture)\n\n\n#### User login\n```js\n// ~/components/my-component.js\n\nexport default {\n  methods: {\n    async onSubmit () {\n      const credentials = this.credentials\n      try {\n          const res = await this.$apollo.mutate({\n              mutation: authenticateUserGql,\n              variables: credentials\n          }).then(({data}) => data && data.authenticateUser)\n          await this.$apolloHelpers.onLogin(res.token)\n      } catch (e) {\n          console.error(e)\n      }\n    },\n  }\n}\n```\n\n#### User logout\n```js\n// ~/components/my-component.js\n\nexport default {\n  methods: {\n    async onLogout () {\n      await this.$apolloHelpers.onLogout()\n    },\n  }\n}\n```\n\n#### getToken\n```js\n// ~/middleware/isAuth.js\n\nexport default ({app, error}) => {\n  const hasToken = !!app.$apolloHelpers.getToken()\n  if (!hasToken) {\n    error({\n      errorCode:503, \n      message:'You are not allowed to see this'\n    })\n  }\n}\n```\n\n#### Examples to access the defaultClient of your apolloProvider\n##### Vuex actions\n```js\n// ~/store/my-store.js\n\nexport default {\n  actions: {\n    foo (store, payload) {\n      let client = this.app.apolloProvider.defaultClient\n    }\n  }\n}\n```\n\n##### asyncData/fetch method of page component\n```js\n// ~/components/my-component.js\n\nexport default {\n  asyncData (context) {\n    let client = context.app.apolloProvider.defaultClient\n  }\n}\n```\n\n##### nuxtServerInit\n```js\nexport default {\n  nuxtServerInit (store, context) {\n    let client = context.app.apolloProvider.defaultClient\n  }\n}\n```\n\n\n##### access client or call mutations and queries of any method inside of component\n```js\n// ~/components/my-component.js\n\nexport default {\n  methods: {\n    foo () {\n      // receive the associated Apollo client \n      const client = this.$apollo.getClient()\n\n      // most likely you would call mutations like following:\n      this.$apollo.mutate({mutation, variables})\n      \n      // but you could also call queries like this:\n      this.$apollo.query({query, variables})\n        .then(({ data }) => {\n          // do what you want with data\n        })\n    }\n  }\n}\n```\n\nOnce you get the client, you can access its methods and properties. See [API Reference](https://vue-apollo.netlify.com/api/dollar-apollo.html)\n\n#### Smart queries on any component\n```js\n// nuxt.config.js\n\nexport default {\n  apollo: {\n    foo: {\n      query: fooGql,\n      variables () {\n        return {\n          myVar: this.myVar\n        }\n      }\n    }\n  }\n}\n```\n\nSee [vue-apollo documentation](https://vue-apollo.netlify.com/guide/apollo/queries.html) for more information on smart queries\n\n#### Add GQL file recognition on node_modules\n```js\n// nuxt.config.js\n\nexport default {\n  apollo: {\n    clientConfigs: {\n      default: '~/apollo/client-configs/default.js'\n    },\n    includeNodeModules: true\n  }\n}\n```\n\n## Upgrade\n\n### Upgrade Guide apollo-module v3 => v4\n\nVersion 4 of this module leaves you with zero configuration. This means we use the best possible approach available from `vue-cli-plugin-apollo` and the same configuration behaviour. This means you don't need to wire up your own configuration, simply pass \n\nEdit your configuration as following:\n```js\n// nuxt.config.js\n\nexport default {\n  apollo: {\n    clientConfigs: {\n      default:{\n        httpEndpoint: YOUR_ENDPOINT,\n        wsEndpoint: YOUR_WS_ENDPOINT\n      }\n    }\n  }\n}\n\n```\n\n### Upgrade Guide apollo-client v1 => v2\n\nVersion 3 of this module is using apollo-client 2.x. You need to make sure to update all your middle/afterware according to the upgrade guide of apollo-client. Check this source for a reference: https://www.apollographql.com/docs/apollo-server/migration-two-dot/\n\n## Troubleshooting \n\n### Proxies\n\nCORS errors are most often resolved with proxies.  If you see a Cross-Origin-Request error in your client side console look into setting up a proxy.  Check out https://github.com/nuxt-community/proxy-module for quick and straight forward setup.\n\n###  ctx.req.session - req is undefined\n\nThis is just a placeholder.  You'll want to replace it with whatever storage mechanism you choose to store your token.\nHere is an example using local storage : https://github.com/Akryum/vue-apollo/issues/144\n\n## Contribute and wire up setup\n\nSetup the required fields in `.env` file in root folder\n\n```bash\n# cat .env\nHTTP_ENDPOINT=https://your-endpoint\nWS_ENDPOINT=wss://your-endpoint\n```\n\nIn `index.vue` the login process requires that the gql endpoint enables a mutation which returns a valid token:\n```gql\nmutation authenticateUser($email:String!,$password:String!){\n    authenticateUser(email: $email, password: $password) {\n        token\n        id\n    }\n}\n```\n\nIf your gql backend is prepared start running nuxt as follow\n```bash\nnpm install\nnpm run dev\n```\n","readmeFilename":"README.md"}