mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
26 lines
777 B
JavaScript
26 lines
777 B
JavaScript
import { InMemoryCache, IntrospectionFragmentMatcher } from 'apollo-cache-inmemory'
|
|
import introspectionQueryResultData from './apollo-config/fragmentTypes.json'
|
|
import metadata from '~/constants/metadata'
|
|
|
|
const fragmentMatcher = new IntrospectionFragmentMatcher({
|
|
introspectionQueryResultData,
|
|
})
|
|
|
|
export default ({ req, nuxtState }) => {
|
|
const { env } = req || nuxtState
|
|
const backendUrl = env.GRAPHQL_URI || 'http://localhost:4000'
|
|
|
|
return {
|
|
wsEndpoint: env.WEBSOCKETS_URI,
|
|
httpEndpoint: process.server ? backendUrl : '/api',
|
|
httpLinkOptions: {
|
|
credentials: 'same-origin',
|
|
},
|
|
credentials: true,
|
|
tokenName: metadata.COOKIE_NAME,
|
|
persisting: false,
|
|
websocketsOnly: false,
|
|
cache: new InMemoryCache({ fragmentMatcher }),
|
|
}
|
|
}
|