diff --git a/client/src/graphql/initial-state.js b/client/src/graphql/initial-state.js new file mode 100644 index 000000000..8455e0562 --- /dev/null +++ b/client/src/graphql/initial-state.js @@ -0,0 +1,5 @@ +export default { + currentSelectedNavItem: null, + currentUser: null, + token: null +}; diff --git a/client/src/index.js b/client/src/index.js index 29423deab..bd2e8911e 100644 --- a/client/src/index.js +++ b/client/src/index.js @@ -7,6 +7,7 @@ import { createHttpLink } from "apollo-link-http"; import { InMemoryCache } from "apollo-cache-inmemory"; import { ApolloClient } from "apollo-boost"; import { typeDefs, resolvers } from "./graphql/resolvers"; +import initialState from "./graphql/initial-state"; // require('dotenv').config() import * as serviceWorker from "./serviceWorker"; @@ -14,26 +15,23 @@ import * as serviceWorker from "./serviceWorker"; import "./index.css"; import { default as App } from "./App/App.container"; +const token = client.readQuery + const httpLink = createHttpLink({ uri: "https://bodyshop-dev-db.herokuapp.com/v1/graphql" }); -const cache = new InMemoryCache(); + const client = new ApolloClient({ link: httpLink, - cache, + cache: new InMemoryCache(), typeDefs, resolvers }); client.writeData({ - data: { - currentSelectedNavItem: null, - currentUser: null, - authState: null, - gqlToken: null - } + data: initialState }); ReactDOM.render(