Initial Auth integration

This commit is contained in:
Barry Low committed 2018-10-11 14:53:58 -07:00
1 parent 27c32184b2
commit 401fb88e0e
8 files changed
+53 -158

No files matched your search

+6 -4
View File
@@ -4,8 +4,8 @@ import { InMemoryCache } from 'apollo-cache-inmemory'
import { ApolloLink, split, Observable } from 'apollo-link'
import { onError } from 'apollo-link-error'
import { setContext } from 'apollo-link-context'
import { WebSocketLink } from 'apollo-link-ws'
import { SubscriptionClient } from 'subscriptions-transport-ws'
// import { WebSocketLink } from 'apollo-link-ws'
// import { SubscriptionClient } from 'subscriptions-transport-ws'
import { getMainDefinition } from 'apollo-utilities'
import { getItem } from '../utils/local-storage'
@@ -15,6 +15,7 @@ const graphqlEndpoint =
? process.env.PROD_GRAPHQL
: process.env.DEV_GRAPHQL
/*
const wsUri = graphqlEndpoint.replace(/^http/, 'ws')
const globalVar =
@@ -23,6 +24,7 @@ const globalVar =
: typeof window !== 'undefined'
? window
: {}
const webSocketImpl = globalVar.WebSocket || globalVar.MozWebSocket
const wsClient = new SubscriptionClient(
@@ -40,7 +42,7 @@ wsClient.onDisconnected(() => {
wsClient.onReconnected(() => {
// console.log('onReconnected')
})
*/
const httpLink = new HttpLink({ uri: graphqlEndpoint })
const link = split(
@@ -48,7 +50,7 @@ const link = split(
const { kind, operation } = getMainDefinition(query)
return kind === 'OperationDefinition' && operation === 'subscription'
},
new WebSocketLink(wsClient),
// new WebSocketLink(wsClient),
httpLink
)