title: Set Authorization Headers in ApolloClient for each request
body: <p>I am learning GraphQL and Next.js through a Udemy Course and the author uses ApolloClient from apollo-boost package. But @apollo/client package is the new one and I started using that instead.</p>
  <p>using apollo-boost's ApolloClient the author sets the credentials for each request like below:</p>
  <pre><code>new ApolloClient({
        request: operation =&gt; {
          operation.setContext({
            fetchOptions: {
              credentials: 'include'
            },
            headers
          })
        },
        uri: process.env.BASE_URL,
        cache: new InMemoryCache().restore(initialState || {})
  })
  </code></pre>
  <p>This is not working for me as request is not present in @apollo/client's ApolloClient. So I tried like below:</p>
  <pre><code>const link = new HttpLink({ uri: &quot;http://localhost:3000/graphql&quot;, credentials: 'include' });
  new ApolloClient({
        cache: new InMemoryCache().restore(initialState || { }),
        link,
      })
  </code></pre>
  <p>But the credentials are not working for each request. I am not getting user information.
  I am using passport which is storing logged in user info in cookies.
  Below is the index.js file for configuring passport:</p>
  <pre><code>const config = require('../config/dev');
  const sessison = require('express-session');
  const passport = require('passport');
  exports.init = (server, db) =&gt; {
    require('./passport').init(passport);
    const sess = {
      name: 'portfolio-session',
      secret: config.SESSION_SECRET,
      cookie: { maxAge: 2 * 60 * 60 * 100},
      resave: false,
      saveUninitialized: false,
      store: db.initSessionStore()
    }
  
    server.use(sessison(sess));
    server.use(passport.initialize());
    server.use(passport.session());
  }
  </code></pre>
  <p>Can somebody help with code to add authentication to ApolloClient?</p>
  <p>Thanks :)</p>