sdy

update cache

......@@ -7,7 +7,7 @@ import { ApolloLink, split } from "apollo-link";
import { getMainDefinition } from "apollo-utilities";
import { withClientState } from "apollo-link-state";
import { setContext } from "apollo-link-context";
import { resolvers, defaults } from "./ClientState";
import { resolvers, typeDefs } from "./ClientState";
const httpLink = new HttpLink({
uri: "http://localhost:4000",
......@@ -25,10 +25,18 @@ const setAuthorizationLink = setContext((request, previousContext) => ({
}));
const clientState = withClientState({
defaults,
typeDefs,
resolvers,
});
const cache = new InMemoryCache();
cache.writeData({
data: {
isLoggedIn: Boolean(localStorage.getItem("token") || false),
},
});
const client = new ApolloClient({
link: ApolloLink.from([
onError(({ graphQLErrors, networkError }) => {
......@@ -54,6 +62,6 @@ const client = new ApolloClient({
httpLink
),
]),
cache: new InMemoryCache(),
cache,
});
export default client;
......