Typed arguments in resolvers
- Dominant language
- TypeScript
- Stars
- 20.3k
- Forks
- 2.1k
- Avg merge
- 44m
- Merged PRs (30d)
- 6
Description
It's kinda feature request. I've [posted a question](https://stackoverflow.com/questions/51337630/detecting-argument-types-in-resolver) how to do this using existing tools (btw I'l be very grateful if someone can help with this), but I think this really should be in a spec/ref implementation.
Resolver accepts arguments as plain javascript object, already combined from inline arguments and variables. But GraphQL is strongly typed and this benefit doesn't work here. I get arguments, but I don't know types of these arguments. Getting types of args in resolver is useful because it gives more possibilities to process input. To validate or transform it based on types. This is especially useful in scenarios when you have deeply nested input with relations, multiple named input types, repeated types (lists of objects), etc.
And I see two variants of improving this:
1. Change plain object in resolver args to special object with types mappings
2. Add a function to graphql core that given args and resolverInfo will return type map
Contributor guide
Assessment
This issue has not been assessed yet.