graphql-middleware
graphql-middleware copied to clipboard
Question: adding middleware around a (mock) type resolver?
I've been able to successfully apply middleware for fields, but when I try to apply one to a type resolver, it only applies the middleware to that type's field resolvers, not the type resolver itself.
Is there a way to only have it apply to the type resolver?
For example, given the below resolvers, I'd like to wrap the Contact
type resolver, but I can only seem to get it to apply to that type's fields (e.g, name
below).
// RESOLVERS
{
// mock type resolver
Contact: () => {
return {
name: () => { /* field resolver */ }
}
},
Query: () => {
contacts: () => { /* field resolver */ }
}
}
// MIDDLEWARE
applyMiddleware(schema, {
Contact: myMiddleware()
})
Hi @jrnail23 👋 ,
Could you explain in a bit more detail what a type-resolver would do? Maybe you could do some mocking by checking the name
of the field? You can get that information from the info
argument in the middleware.