I’m trying to make a blocking API call during inputField resolution. Essentially, we need to make sure that some data coming into the server is checked before its allowed through graphql into the mutation resolver.
This kind of thing is possible with normal “output” fields and directives, by overriding field.resolve, but no such thing seems possible with inputFields. There are some hacky work-arounds that involve overwriting the type of the inputField using the directive, and then in the new type definition doing whatever you needed, but those seem to all by synchronous, non-blocking functions and it doesn’t seem like I can jam an API call in there.
That brings me to apollo-server-plugins. Perhaps it would be possible to register a directive on the INPUT_FIELD as a no-op, and then when willResolveField is called within the plugin, go and look at every inputField that had the directive and do the necessary server-call. Unfortunately, the directives don’t seem to show up to the plugin at all. The selectionSets show the fields, however they all come up with directives: array empty.
So, what do? Is there a way to accomplish this in graphql without asking the user to do something manually in their mutation resolver? Is there ANY way to fire an async function from a directive that’s on an input_field or maybe on a mutation itself?