mutatingPreResolve Hook Configuration
Published: 2022-05-23
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.