Skip to content

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

@jenssuhr

Description

@jenssuhr

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions