Ocelot-Social/webapp/plugins/apollo-config.js
mattwr18 2f43069ea0 Subscribe to notifications/remove polling
- We want to publish when a notification occurs for a specific user, not
  have the client poll the backend for ever user every minute.

- Co-authored-by: @Tirokk <wolle.huss@pjannto.com>
2020-02-05 17:37:38 +01:00

24 lines
722 B
JavaScript

import { InMemoryCache, IntrospectionFragmentMatcher } from 'apollo-cache-inmemory'
import introspectionQueryResultData from './apollo-config/fragmentTypes.json'
const fragmentMatcher = new IntrospectionFragmentMatcher({
introspectionQueryResultData,
})
export default ({ app }) => {
const backendUrl = process.env.GRAPHQL_URI || 'http://localhost:4000'
return {
wsEndpoint: 'ws://localhost:4000/graphql', // optional
httpEndpoint: process.server ? backendUrl : '/api',
httpLinkOptions: {
credentials: 'same-origin',
},
credentials: true,
tokenName: 'human-connection-token',
persisting: false,
websocketsOnly: false,
cache: new InMemoryCache({ fragmentMatcher }),
}
}