the-road-to-graphql / fullstack-apollo-express-postgresql-boilerplate

💥 A sophisticated GraphQL with Apollo, Express and PostgreSQL boilerplate project.
https://roadtoreact.com
MIT License
1.2k stars 261 forks source link

signOut client undefined #11

Closed GitProdEnv closed 5 years ago

GitProdEnv commented 6 years ago

In client/src/index.js client is undefined? I work on a similar project but I can't get my head around this.

if (networkError) {
    console.log('Network error', networkError);
    if (networkError.statusCode === 401) {
      signOut(client);
    }
  }

we reference client further below in

const client = new ApolloClient({
  link,
  cache,
});
rwieruch commented 6 years ago

You are absolutely right. This makes no sense :) Any way to get access to the client instance within the error functions for resetting the store?

I think because of hoisting and because the variable is used within a function, the client instance isn't undefined here.

Related: https://github.com/apollographql/apollo-link/issues/595