Open nodkz opened 3 years ago
Hooks sound like a great idea! I am wondering where I can find a type definition of the config options? In each resolver's file... :disappointed:
I was curious because I wanted to see how the relay
style middleware fits into this? or if it does still?
With getResolver
I was able to provide an array of middlewares. Would the new hooks replace this?
Current approach for middlewares is declared here https://github.com/graphql-compose/graphql-compose-mongoose/issues/158#issuecomment-772695238:
schemaComposer.Query.addFields({ userById: UserTC.mongooseResolvers.findById().withMiddlewares([authMiddleware]), userByIds: UserTC.mongooseResolvers.findByIds().withMiddlewares([authMiddleware]), });
The new major 9.0.0 version of graphql-compose-mongoose will introduce a new process for resolver creation. Before 9.0.0 all resolvers were created on
composeWithMongoose
method call. But starting from 9.0.0 introduced a new methodcomposeMongose
for creating TypeComposers from mongoose models. And this method will not create resolvers. You will be able to create them viamongooseResolvers
:Such granular resolver creation unlocks the ability to provide as many configuration options as we need. And the first candidate is HOOKS (which should replace spaghetti with
wrapResolve
).HOOKS may solve the following tasks:
You may see how hooks are implemented in mongo-graphql-starter. I want to provide something similar but on a resolver basis.
Anyway, if you have any ideas about how configs for HOOKS should look like, or found somewhere a convenient hook realization – please share with us.