Skip to Content

mutatingPreResolveHook Configuration

Published: October 19, 2021

Mutating preResolve Hooks allow you to rewrite or manipulate the inputs to an Operation. You have access to the Context containing the User Object, in case they are authenticated, which means you're able to inject user variables into the Operation.

Here's an example:

const wunderGraphHooks = ConfigureWunderGraphHooks({
queries: {
Missions: {
async mutatingPreResolve(ctx: Context, input: MissionsInput) {
return {
...input,
find: {
id: ctx.user?.user_id
}
}
}
}
},
})

We're returning the original MissionsInput Object and are enhancing it using the user_id as the id argument.


Product

Subscribe to our newsletter!

Stay informed when great things happen! Get the latest news about APIs, GraphQL and more straight into your mailbox.

© 2021 WunderGraph