Skip to content

Latest commit

 

History

History
176 lines (117 loc) · 3.66 KB

2.configuration.md

File metadata and controls

176 lines (117 loc) · 3.66 KB

Configuration

Configure Nuxt Apollo via the apollo property.


Defaults

export default defineNuxtConfig({
  modules: ['@nuxtjs/apollo'],

  apollo: {
    autoImports: true,
    authType: 'Bearer',
    authHeader: 'Authorization',
    tokenStorage: 'cookie',
    proxyCookies: true,
    clients: {}
  }
})

autoImports

  • Default: true

Determine if vue-apollo composables should be automatically imported and accessible within your nuxt app.

authType

  • Default: Bearer

Specify the Authentication scheme.

authHeader

  • Default: Authorization

Name of the Authentication token header.

tokenStorage

  • Default: cookie

Specify if the auth token should be stored in cookie or localStorage. Cookie storage is required for SSR.

proxyCookies

  • Default: true

Specify if client cookies should be proxied to the server.

clients

Configure your Apollo Client instances.

::code-group

export default defineNuxtConfig({
  modules: ['@nuxtjs/apollo'],

  apollo: {
    clients: {
      default: {
        httpEndpoint: '',
        browserHttpEndpoint: '',
        wsEndpoint: '',
        httpLinkOptions: {},
        wsLinkOptions: {},
        wsEndpoint: '',
        websocketsOnly: false,
        connectToDevTools: false,
        defaultOptions: {},
        inMemoryCacheOptions: {},
        tokenName: 'apollo:<client-name>.token',
        tokenStorage: 'cookie',
        authType: 'Bearer',
        authHeader: 'Authorization',
        useUploadLink: false
      },
      other: './apollo/other.ts'
    }
  }
})
import { defineApolloClient } from '@nuxtjs/apollo'

export default defineApolloClient({
  httpEndpoint: '',
  browserHttpEndpoint: '',
  wsEndpoint: '',
  httpLinkOptions: {},
  wsLinkOptions: {},
  wsEndpoint: '',
  websocketsOnly: false,
  connectToDevTools: false,
  defaultOptions: {},
  inMemoryCacheOptions: {},
  tokenName: 'apollo:<client-name>.token',
  tokenStorage: 'cookie',
  authType: 'Bearer',
  authHeader: 'Authorization',
  useUploadLink: false
})

::

  • httpEndpoint

The GraphQL endpoint.

  • browserHttpEndpoint

Provide a GraphQL endpoint to be used client-side. Overrides httpEndpoint.

  • httpLinkOptions

Provide additional configuration for the HttpLink.

  • wsLinkOptions

Provide additional configuration for the GraphQLWsLink.

  • wsEndpoint

Specify a websocket endpoint to be used for subscriptions. The wss protocol is recommended in production.

  • websocketsOnly

Specify if the client should solely use WebSocket. requires wsEndpoint.

  • connectToDevTools

    • Default: true

Specify if the client should be able to connect to the Apollo Client Devtools in production mode.

  • defaultOptions

Configure default options to be applied to the apollo client.

  • inMemoryCacheOptions

Additional configuration for the in-memory cache.

  • tokenName

    • Default: apollo:<client-name>.token"

Specify the name under which the token will be stored.

  • tokenStorage

    • Default: cookie

Specify if the auth token should be stored in cookie or localStorage. Cookie storage is required for SSR.

  • authType

    • Default: Bearer

Specify the Authentication scheme.

  • authHeader

    • Default: Authorization

Name of the Authentication token header.

  • useUploadLink

    • Default: false

Determine if the apollo-upload-client HttpLink should be used instead of the standard Apollo HttpLink.