graphql-compose / graphql-compose/graphql-compose-mongoose
Add hooks to resolvers config options (after releasing v9.0.0)
- Dominant language
- TypeScript
- Stars
- 706
- Forks
- 98
- PR merge metrics
- No merged PRs in 30d
Description
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 method `composeMongose` for creating TypeComposers from mongoose models. And this method will not create resolvers. You will be able to create them via `mongooseResolvers`:
```ts
import { UserModel } from './user';
import { composeMongoose } from 'graphql-compose-mongoose';
const UserTC = composeMongoose(UserModel);
// ... modify type as you need
const userFindManyResolver = UserTC.mongooseResolvers.findMany(configForFindMany);
const userRemoveByIdResolver = UserTC.mongooseResolvers.removeById(configForRemoveById);
```
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:
- authorization
- logging
- validation
- subscription support (pushing event to PubSub)
You may see how hooks are implemented in [mongo-graphql-starter](https://github.com/arackaf/mongo-graphql-starter#how-to-use-processing-hooks). 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.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.