Skip to Content

mutatingPreResolve Hook Configuration

Published: 2022-05-24

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

Comparisons

Subscribe to our newsletter!

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

© 2022 WunderGraph