Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

131
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!