0

I'm using express-graqphl and was wondering if there is any concept of running a function before each graphql endpoint is executed? I'd like to have this for things like validating JWTs and other things. I realize we could use express for this, e.g.

app.use('/graphql`, doChecks);

but I'd like for the graphql handler to throw an error so it'll be inside the errors: [] list in the results giving the client a consistent experience with the api. Is there any direct support for this in the package?

d512
  • 32,267
  • 28
  • 81
  • 107

1 Answers1

0

The context function is executed before every request. If you're using Apollo v4+ then here are the docs

The context function is most often used to manage auth, including reading and validation of security tokens.

Michel Floyd
  • 18,793
  • 4
  • 24
  • 39