JWT authoraztion set after useQuery

Hello! I am currently implementing Oauth social login

I implemented the access token used to get the client cookie from the server.

After executing the query with useMeQuery, which receives user information created with graphql-code-generator, I thought that the cookie was applied right from Authoraztion and the data would come over.

In the first request, the Authoraztion header was not attached to the request at all, so I ran the request and reloaded the page by refreshing, and then the authoraztion header was attached and the result was OK.

I implemented it by getting the cookie from authLink and putting it in the Authorazation of the Header, but since the first is not attached to the header and the second is attached, I don’t know where there is a problem. Can I get help?

@EungyuCho can you share some of your code, especially the parts that show how you’re setting the headers?

@hwillson Here is code

and my apollo setting referring this link.

thanks you for reply

const httpLink = createHttpLink({
  uri: `${config.graphqlUrl}`,
  credentials: 'include',

const authLink = setContext((_, { headers }) => {
  const token = cookie.load(JWT_TOKEN)
  return {
    headers: {
      authorization: `Bearer ${token}`,

const cache = new InMemoryCache()

function createApolloClient() {
  return new ApolloClient({
    ssrMode: typeof window === 'undefined',
    link: authLink.concat(httpLink),


I solved this problem…

AuthLink couldn’t read cookies due to incorrect cookie settings :sweat_smile:

1 Like