Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import {InMemoryCache} from 'apollo-cache-inmemory';
import {ApolloLink} from 'apollo-client-preset';
import {ApolloClient} from 'apollo-client';
import CreateClientStore from './CreateClientStore';
// Set up Cache
const cache = new InMemoryCache();
// Set up Local State
const stateLink = CreateClientStore(cache);
// Initialize the Apollo Client
const Client = new ApolloClient({
link: ApolloLink.from([
stateLink,
]),
cache: cache,
});
export default Client;
updateNetworkStatus: (_, { isConnected }, { cache }) => {
const data = {
networkStatus: {
__typename: 'NetworkStatus',
isConnected,
},
}
cache.writeData({ data })
return null
},
},
},
})
const client = new ApolloClient({
link: ApolloLink.from([stateLink, authLink.concat(link)]),
cache,
})
export default client
const createClient = (opts = {}, state) => {
const client = new ApolloClient({
link: ApolloLink.from([logs(opts), auth(opts), http(opts)]),
...opts
});
if (state) {
client.cache.restore(state);
}
return client;
};
const createClient = (opts: { ssrMode?: boolean; token?: string }, state?) => {
const client = new ApolloClient({
link: ApolloLink.from([logs(opts), auth(opts), http(opts)]),
...opts
});
if (state) {
client.cache.restore(state);
}
return client;
};
export default async () => {
const cacheSchemaVersion = (await getSchemaVersion()) || 0;
if (currentSchemaVersion === cacheSchemaVersion) {
await persistor.restore();
} else {
await persistor.purge();
await saveSchemaVersion(currentSchemaVersion);
}
const clientStateLink = await generateClientStateLink(cache);
return new ApolloClient({
connectToDevTools: process.env.NODE_ENV === 'development',
link: ApolloLink.from([
clientStateLink,
new HttpLink({
uri: 'https://graphql-guc.now.sh/graphql',
}),
]),
cache,
});
};