mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
After some intensive debugging I found out that `req` (on the server) and `nuxtState` (on the client) have access to the configurations changed at runtime. How did I debug it: ``` yarn run build env WEBSOCKET_URI=whatever yarn run start ``` I also put a `console.log` into `plugins/apollo-client.js`.
25 lines
770 B
JavaScript
25 lines
770 B
JavaScript
import { InMemoryCache, IntrospectionFragmentMatcher } from 'apollo-cache-inmemory'
|
|
import introspectionQueryResultData from './apollo-config/fragmentTypes.json'
|
|
|
|
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 || 'ws://localhost:4000/graphql',
|
|
httpEndpoint: process.server ? backendUrl : '/api',
|
|
httpLinkOptions: {
|
|
credentials: 'same-origin',
|
|
},
|
|
credentials: true,
|
|
tokenName: 'human-connection-token',
|
|
persisting: false,
|
|
websocketsOnly: false,
|
|
cache: new InMemoryCache({ fragmentMatcher }),
|
|
}
|
|
}
|