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?
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?
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.