graphql-compose / graphql-compose/graphql-compose-mongoose
resolvers skip asynchronous validators
- Dominant language
- TypeScript
- Stars
- 706
- Forks
- 98
- PR merge metrics
- No merged PRs in 30d
Description
The `validateDoc` function used in many resolvers, e.g. `updateById`, `createOne`, found [here](https://github.com/graphql-compose/graphql-compose-mongoose/blob/744b767b4029cbdaa3d0734368fec3ef5f38f7f7/src/resolvers/helpers/validate.ts#L23) will call `doc.validateSync` for mongoose >= v7. `validateSync` does not run asynchronous validators, and instead skips them. This leads to validation being silently skipped within this package.
Since `validateDoc` is an asynchronous function, and `await`s for validations in mongoose < v7, it seems that there is no good reason to not `await` for validation in the >= v7 case as well.
Happy to make a pull request if the maintainers agree.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.