graphql-compose-mongoose icon indicating copy to clipboard operation
graphql-compose-mongoose copied to clipboard

Correct(suggested) way to add new argument to find* resolvers

Open MatthewJonD opened this issue 5 years ago • 2 comments

For backwards compatibility, we need to add a new argument to some of our default resolvers. Right now, out of the box, "LIMIT" is supported- Historically, we used "TAKE" for the same function. It would throttle the number of records returned.

What would the prescribed way to have "TAKE" also be avail to a findMany resolver, just passing the value to the resolver code in, executing the "LIMIT" function?

MatthewJonD avatar Jan 22 '20 15:01 MatthewJonD

Try to wrap existed resolver. You need to add new arg, and in resolve method just pass args.take value to args.limit

Something like this: https://github.com/graphql-compose/graphql-compose-mongoose/blob/eecf9eab1b09b05f19ec67d24b7ccb35d06e00f8/src/tests/github_issues/136-test.js#L37-L49

nodkz avatar Feb 04 '20 13:02 nodkz

Perfect...That was what we had. But thank you for the confirmation.

MDrooker avatar Feb 05 '20 09:02 MDrooker