0

Any Example on how to leverage fastify-jwt plugin with fastify-gql for authentication?. I want to protect '/graphql' route but not '/' and '/health' routes.

Any help is appreciated?

thotam
  • 941
  • 2
  • 16
  • 31

1 Answers1

0

I have started a PR with this example.

You can check the source code here.

The plugin fastify-gql doesn't expose this feature, but it registers the routs you need to protect. So, listening for the onRoute hook, you can check when the fastify-gql plugin is adding his routes and append your preValidation hook to them and apply your auth logic.

Manuel Spigolon
  • 11,003
  • 5
  • 50
  • 73