You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Get value of input type with custom scalars as Map with already coerced values #424
We have a mutation with an input type that includes custom scalars. We would like to have our mutation resolver being called with the parsed value for the input type as a Map so we are able to see which properties have been set and which not.
scalar A
scalar B
input MyInput {
a: A
b: B
}
type Mutation {
myMutation(input: MyInput): String
}
publicclassMyResolverimplementsGraphQLMutationResolver {
publicStringmyMutation(LinkedHashMapinput) {
if (input.containsKey("a")) {
// do something
}
if (input.containsKey("b")) {
// do something
}
}
}
However if we implement the mutation resolver like this, the map with the parsed custom scalars is passed on to the ObjectMapper in MethodFieldResolver#createDataFetcher and we loose the parsed values for the custom scalars. We currently solve this by retrieving the map with the parsed custom scalars from the DataFetchingEnvironment like this:
publicclassMyResolverimplementsGraphQLMutationResolver {
publicStringmyMutation(LinkedHashMapinput, DataFetchingEnvironmentenvironment) {
input = environment.getArgument("input");
if (input.containsKey("a")) {
// do something
}
if (input.containsKey("b")) {
// do something
}
}
}
Could the mutation resolver be called with the parsed custom scalars so we do not need to override the input value with the parsed value in the DataFetchingEnvironment? In a way simular to fix #320 - Add support for lists of Scalar field arguments that are already coerced for issue #198 - Input types with custom scalars in method field resolver.
Activity