Skip to content
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

Variables are coerced twice during an execution when a field validation instrumentation is active #2458

Closed
jenssuhr opened this issue Jul 14, 2021 · 3 comments

Comments

@jenssuhr
Copy link

jenssuhr commented Jul 14, 2021

Describe the bug
It looks like variables are coerced twice during an execution using graphql-java 16.2, once in execute and once in validateFieldsAndArguments. This breaks e.g. enums with non-default names.

Variables are first coerced here, then added to the execution context.
In FieldValidationSupport, the QueryTraverser is initialized with those variables from the execution context and coerces them again here.

To Reproduce
If you have an enum value defined like this

GraphQLEnumType.newEnum()
    .name("MyEnum")
    .description("My enum with all lowercase names.")
    .values(
        MyEnum.values().map {
            GraphQLEnumValueDefinition.newEnumValueDefinition()
                .name(it.getLowerCaseName())
                .value(it)
                .build()
        }
    ).build()

the first coercion works correctly, but the second one fails.

@dondonz
Copy link
Member

dondonz commented Jul 19, 2021

Hi @jenssuhr,

I'm trying to investigate the issue but I can't reproduce the error. Could you please help me by expanding on your example?

Could you please paste here:

  1. an example query,
  2. the field validation instrumentation(s) used, and
  3. the name of the error when the second coercion failed

@jenssuhr
Copy link
Author

Hi, thanks for investigating! I'll try to add an example as soon as possible.

@jenssuhr
Copy link
Author

I just noticed that we're not using the field validation correctly. Instead of using SimpleFieldValidation and adding rules, we were using a separate FieldValidationInstrumentation for each rule and chaining them together using ChainedInstrumentation. Fixing that will probably also fix this issue.
Thank you for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants