-
-
Notifications
You must be signed in to change notification settings - Fork 812
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resolvers for input object types on mutations? #652
Comments
I join the question. This is very useful if you could transform the result from the input and perform the additionally validation of the data. In addition, it will be possible to simplify the validation code in the mutation itself. |
Yeah, unfortunately right now there is no way to process input types before they get passed to the resolver. That would probably be out of scope for being built into this library until it's added to the upstream graphql-js implementation this is based on. It would take a lot of work, but I bet you could implement something like this using schema directives: https://dev-blog.apollodata.com/reusable-graphql-schema-directives-131fb3a177d1 |
Yeah, too much work. But there were at least two suggestions on this thread which lean on custom directives instead. |
For anyone interested, I implemented the idea of a resolver (called coercer) for input object in graphql-field-arguments-coercion. It can be used with graphql-tools to install the coercer functions and process the inputs before being passed to the field resolver. |
I have a mutation that takes an input object.
The Ids like
entryId
in the GraphQL system are Base64 obfuscated strings and I need to convert them back to integers to talk to the back-end services.EntryChanges
is anotherinput
object with even more Ids that I need to convert back to integers.I tried to add a resolver for
UpdateEntryInput
, Apollo Server crashed:What is wrong? I didn't find any good examples on how to handle this.
The text was updated successfully, but these errors were encountered: