Skip to Content

preResolve Hook Configuration

Published: 2022-05-23

The preResolveHook runs, as the name suggests, before the resolver is being executed. As it's not a mutating hook, it will "mutate" the Request Chain.

Here's an example:

const wunderGraphHooks = ConfigureWunderGraphHooks({
queries: {
Missions: {
// generated
async preResolve(ctx: Context, input: MissionsInput) {
console.dir({ctx,input}); // user defined
}
}
},
})

Hooks of the kind preResolve will always contain a Context (ctx) Object. The Context object contains useful information, e.g. the User Object if the user is authenticated.

If there are any Variables defined for the preResolve Hook, these will be available as the second parameter. The structure of the Hooks is generated with TypeScript types. This means, all parameters of the Hook will be typed.


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