Configure Nuxt Apollo via the apollo
property.
export default defineNuxtConfig({
modules: ['@nuxtjs/apollo'],
apollo: {
autoImports: true,
authType: 'Bearer',
authHeader: 'Authorization',
tokenStorage: 'cookie',
proxyCookies: true,
clients: {}
}
})
- Default:
true
Determine if vue-apollo composables should be automatically imported and accessible within your nuxt app.
- Default:
Bearer
Specify the Authentication scheme.
- Default:
Authorization
Name of the Authentication token header.
- Default:
cookie
Specify if the auth token should be stored in cookie
or localStorage
. Cookie
storage is required for SSR.
- Default:
true
Specify if client cookies should be proxied to the server.
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
})
::
The GraphQL endpoint.
Provide a GraphQL endpoint to be used client-side. Overrides httpEndpoint
.
Provide additional configuration for the HttpLink.
Provide additional configuration for the GraphQLWsLink
.
Specify a websocket endpoint to be used for subscriptions. The wss
protocol is recommended in production.
Specify if the client should solely use WebSocket. requires wsEndpoint
.
-
- Default:
true
- Default:
Specify if the client should be able to connect to the Apollo Client Devtools in production mode.
Configure default options to be applied to the apollo client.
Additional configuration for the in-memory cache.
-
- Default:
apollo:<client-name>.token"
- Default:
Specify the name under which the token will be stored.
-
- Default:
cookie
- Default:
Specify if the auth token should be stored in cookie
or localStorage
. Cookie
storage is required for SSR.
-
- Default:
Bearer
- Default:
Specify the Authentication scheme.
-
- Default:
Authorization
- Default:
Name of the Authentication token header.
-
- Default:
false
- Default:
Determine if the apollo-upload-client
HttpLink should be used instead of the standard Apollo HttpLink.