title: How to redirect or navigate in apollo client if token is expired
body: <p>I just use React-Native for Client and check validate token in my server.</p>
  
  <p>When my jwt token is expired, the server notices it to the client.</p>
  
  <p>Then, the apollo-client catchs graphQL Error.</p>
  
  <p>I want to navigate to logout user and to get it to login form at that time.</p>
  
  <p>However, I don't know how to do that in my graphQL forEach block, </p>
  
  <p>because I can't use react navigation out side of the NavigationContainer.</p>
  
  <p>anyone who know solve this problem?</p>
  
  <pre><code>...
  const cache = new InMemoryCache()
          await persistCache({
              cache,
              storage: AsyncStorage,
          })  
  const clientState = (cache) =&gt;
  new ApolloClient({
      link: ApolloLink.from([
          ...
          onError(({ graphQLErrors, networkError }) =&gt; {
              if (graphQLErrors)
                  graphQLErrors.forEach(
                      async ({ message, locations, path }) =&gt; {
                          console.log(
                              `[GraphQL error]: Message: ${message}, Location: ${JSON.stringify(
                                  locations
                              )}, Path: ${path}`
                          )
                          if (
                              message ===
                              "You need to log in to perform this action"
                          ) {
                              logout() &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; I want to redirect!
                          }
                      }
                  )
              if (networkError)
                  console.log(`[Network error]: ${networkError}`)
          }), 
       ...
  ]})
  const client = clientState(cache)
  return loaded &amp;&amp; client ? (
      &lt;ApolloHooksProvider client={client}&gt;
          &lt;SafeAreaProvider&gt;
              &lt;AuthProvider isLoggedIn={isLoggedIn} userEmail={userEmail}&gt;
                  &lt;NavigationContainer style={{ backgroundColor: "white" }}&gt;
                      &lt;TopNav /&gt;
                  &lt;/NavigationContainer&gt;
              &lt;/AuthProvider&gt;
          &lt;/SafeAreaProvider&gt;
      &lt;/ApolloHooksProvider&gt;
  ) : (
      &lt;AppLoading /&gt;
  )
  </code></pre>