Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

133
Visualizações
How do I deserialize the user in my graphQL context

I have a express server in which I am using express-graphql. I am also authenticating with passport and passport-google-oauth20.

I am setting up my graphQl without the context:

router.use(graphqlHTTP({
  schema,
  graphiql: true
}));

Which means that the request is passed into my resolver as the context.

const rootResolvers = {
  Query: {
    hello: (obj, args, context) => {
      console.log(context.headers.cookie);
      return "hello"
    }
  }
};

I can see the cookie from the request. How do use the cookie that get to deserialize the user? passport typically does this for me, but in this case I need to call the deserialize function outside of the passport lifecycle. How do I do this?

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

There is a user attached to the request and it is already deserialized. Inside the resolver, all that needs to be done is access the user:

const rootResolvers = {
  Query: {
    hello: (obj, args, context) => {
      console.log(context.user);
      return "hellllo"
    }
  }
};

And now you can use it anyway that you want.

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda