title: How to forward response headers through GraphQL to client
body: <p>I'm having an issue using GraphQL where the response headers are being dropped when returning to client. My application is using NodeJS, Passport.js and Express Cookie-Session to manage authentication and sessions. </p>
  
  <p>I have an existing <code>/login</code> route which authenticates with Passport and returns a <code>user{}</code> object and <code>set-cookie</code> headers to the client. In result, a cookie is created on the client's browser and their session is established.</p>
  
  <p>Now, we have recently added GraphQL and I created a <code>login</code> query, which calls the existing <code>/login</code> route and responds with the <code>user{}</code> object. However, when the GraphQL returns the response to the client, the response headers are no longer included so the cookie is never created.</p>
  
  <p>How can I forward the original response headers through GraphQL to reach the client?</p>
  
  <p>Here is an example of the GraphQL login:</p>
  
  <pre><code>login { 
    type: typeLogin,
    args : { 'username/password here' },
    async resolve(_, args, context) {
      const response = await fetch('/login', {
        credentials: 'include',
        method: 'POST',
        body: JSON.stringify('username/password here')
     })
  
     const data = await response.json();
  
     // console.log(response.headers) will display correct headers
  
     return data; // User is returned but response headers are not
     }
   }
  </code></pre>