Showing
1 changed file
with
11 additions
and
3 deletions
... | @@ -7,7 +7,7 @@ import { ApolloLink, split } from "apollo-link"; | ... | @@ -7,7 +7,7 @@ import { ApolloLink, split } from "apollo-link"; |
7 | import { getMainDefinition } from "apollo-utilities"; | 7 | import { getMainDefinition } from "apollo-utilities"; |
8 | import { withClientState } from "apollo-link-state"; | 8 | import { withClientState } from "apollo-link-state"; |
9 | import { setContext } from "apollo-link-context"; | 9 | import { setContext } from "apollo-link-context"; |
10 | -import { resolvers, defaults } from "./ClientState"; | 10 | +import { resolvers, typeDefs } from "./ClientState"; |
11 | 11 | ||
12 | const httpLink = new HttpLink({ | 12 | const httpLink = new HttpLink({ |
13 | uri: "http://localhost:4000", | 13 | uri: "http://localhost:4000", |
... | @@ -25,10 +25,18 @@ const setAuthorizationLink = setContext((request, previousContext) => ({ | ... | @@ -25,10 +25,18 @@ const setAuthorizationLink = setContext((request, previousContext) => ({ |
25 | })); | 25 | })); |
26 | 26 | ||
27 | const clientState = withClientState({ | 27 | const clientState = withClientState({ |
28 | - defaults, | 28 | + typeDefs, |
29 | resolvers, | 29 | resolvers, |
30 | }); | 30 | }); |
31 | 31 | ||
32 | +const cache = new InMemoryCache(); | ||
33 | + | ||
34 | +cache.writeData({ | ||
35 | + data: { | ||
36 | + isLoggedIn: Boolean(localStorage.getItem("token") || false), | ||
37 | + }, | ||
38 | +}); | ||
39 | + | ||
32 | const client = new ApolloClient({ | 40 | const client = new ApolloClient({ |
33 | link: ApolloLink.from([ | 41 | link: ApolloLink.from([ |
34 | onError(({ graphQLErrors, networkError }) => { | 42 | onError(({ graphQLErrors, networkError }) => { |
... | @@ -54,6 +62,6 @@ const client = new ApolloClient({ | ... | @@ -54,6 +62,6 @@ const client = new ApolloClient({ |
54 | httpLink | 62 | httpLink |
55 | ), | 63 | ), |
56 | ]), | 64 | ]), |
57 | - cache: new InMemoryCache(), | 65 | + cache, |
58 | }); | 66 | }); |
59 | export default client; | 67 | export default client; | ... | ... |
-
Please register or login to post a comment