Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

144
Vistas
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?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

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.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda