Open YuriFontella opened 3 years ago
@YuriFontella - Every request to a Mercurius drivin graphql server triggers a hook.
https://mercurius.dev/#/docs/lifecycle
Scott
@YuriFontella - Every request to a Mercurius drivin graphql server triggers a hook.
https://mercurius.dev/#/docs/lifecycle
Scott
I looked at it, and it was weird. Because in the lifecycle there is no preHandler hook. And mercurius has its own function to add hooks "app.graphql.addHook"
app.addHook('preHandler', async () => {
console.log('Im executed in graphql queries')
})
It didn't make sense for me to call this hook in graphql queries
Yeah, so app.addhook would be for a fastify hook, right? And the same goes, they are for all requests.
https://www.fastify.io/docs/latest/Hooks/
Scott
Hello, I would like to know if it is normal behavior for a hook to be triggered with graphql queries? Considering, that it has its own hooks function.
hook that is loaded:
graphql specific hook in mercurius:
Demo project: https://github.com/YuriFontella/graphql-add-hook-test
The hook loaded as a plugin, is called for every graphql query executed.