title: In Apollo client, how to do refetchQueries with headers after a succesful mutation?
body: <p>I'm having some troubles with Apollo client and was wondering if someone could help me out here.</p>
  
  <p>How can I re-run my query (with headers) after a succesful mutation which returns me a bearer token?</p>
  
  <p>I found out there is something called refetchQueries, but it seems to ignore all the headers thus my bearer token as well.</p>
  
  <p>Say I have the following mutation in my Login component:</p>
  
  <pre><code>&lt;Mutation
    mutation={LOGIN_USER}
    refetchQueries={[{
      query: GET_USER,
    }]}
  &gt;
    {(loginUser, { loading, error, data }) =&gt; {
      if (data) {
        cookies.set('token', data.loginUser.token)
      }
      return (
        &lt;form...
  </code></pre>
  
  <p>and the following authLink in my App.js:</p>
  
  <pre><code>const authLink = setContext((_, { headers }) =&gt; {
    const token = cookies.get('token')
  
    return {
      headers: {
        ...headers,
        authorization: token  ? `Bearer ${token}`  : null
      },
    }
  })
  </code></pre>
  
  <p>Problem seems to be that the authLink thingy doesn't work when using refetchQueries (no headers are sent). When I refresh the browser my query works ok as the cookie is then used to get the token, but this doesn't seem to happen with refetchQueries...</p>
  
  <p>So how could I run my query after the mutation with the bearer token in the header or is there a better way to do this?</p>
  
  <p>Cheers</p>