|
@@ -8,8 +8,11 @@ import VeeValidate from 'vee-validate'
|
|
import { ApolloClient } from 'apollo-client'
|
|
import { ApolloClient } from 'apollo-client'
|
|
import { createPersistedQueryLink } from 'apollo-link-persisted-queries'
|
|
import { createPersistedQueryLink } from 'apollo-link-persisted-queries'
|
|
// import { BatchHttpLink } from 'apollo-link-batch-http'
|
|
// import { BatchHttpLink } from 'apollo-link-batch-http'
|
|
|
|
+import { split } from 'apollo-link'
|
|
import { createHttpLink } from 'apollo-link-http'
|
|
import { createHttpLink } from 'apollo-link-http'
|
|
|
|
+import { WebSocketLink } from 'apollo-link-ws'
|
|
import { InMemoryCache } from 'apollo-cache-inmemory'
|
|
import { InMemoryCache } from 'apollo-cache-inmemory'
|
|
|
|
+import { getMainDefinition } from 'apollo-utilities'
|
|
import VueApollo from 'vue-apollo'
|
|
import VueApollo from 'vue-apollo'
|
|
import Vuetify from 'vuetify'
|
|
import Vuetify from 'vuetify'
|
|
import Velocity from 'velocity-animate'
|
|
import Velocity from 'velocity-animate'
|
|
@@ -48,6 +51,7 @@ moment.locale(siteConfig.lang)
|
|
// ====================================
|
|
// ====================================
|
|
|
|
|
|
const graphQLEndpoint = window.location.protocol + '//' + window.location.host + '/graphql'
|
|
const graphQLEndpoint = window.location.protocol + '//' + window.location.host + '/graphql'
|
|
|
|
+const graphQLWSEndpoint = ((window.location.protocol === 'https:') ? 'wss:' : 'ws:') + '//' + window.location.host + '/graphql-subscriptions'
|
|
|
|
|
|
const graphQLLink = createPersistedQueryLink().concat(
|
|
const graphQLLink = createPersistedQueryLink().concat(
|
|
createHttpLink({
|
|
createHttpLink({
|
|
@@ -77,8 +81,19 @@ const graphQLLink = createPersistedQueryLink().concat(
|
|
})
|
|
})
|
|
)
|
|
)
|
|
|
|
|
|
|
|
+const graphQLWSLink = new WebSocketLink({
|
|
|
|
+ uri: graphQLWSEndpoint,
|
|
|
|
+ options: {
|
|
|
|
+ reconnect: true,
|
|
|
|
+ lazy: true
|
|
|
|
+ }
|
|
|
|
+})
|
|
|
|
+
|
|
window.graphQL = new ApolloClient({
|
|
window.graphQL = new ApolloClient({
|
|
- link: graphQLLink,
|
|
|
|
|
|
+ link: split(({ query }) => {
|
|
|
|
+ const { kind, operation } = getMainDefinition(query)
|
|
|
|
+ return kind === 'OperationDefinition' && operation === 'subscription'
|
|
|
|
+ }, graphQLWSLink, graphQLLink),
|
|
cache: new InMemoryCache(),
|
|
cache: new InMemoryCache(),
|
|
connectToDevTools: (process.env.node_env === 'development')
|
|
connectToDevTools: (process.env.node_env === 'development')
|
|
})
|
|
})
|