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

This will validate @oneOf variable values when the variables are coerced #3580

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

bbakerman
Copy link
Member

@bbakerman bbakerman commented Apr 28, 2024

This will call the oneOf validation during the coercion of the variables during execution.

This MAY make the later validation during argument retrieval slightly redundant however there are other paths that can enter this value code so I have left it in place

This PR plus #3577 will mean variables and literals are covered

static Object externalValueToInternalValueImpl(
String variableName,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needed to add a variable name for error message reasons

when:
def resolvedValues = ValuesResolver.coerceVariableValues(schema, [variableDefinition], RawVariables.of([variable: [a: 'x']]), graphQLContext, locale)
then:
resolvedValues.get('variable') == [a: 'x']
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one is ok - or the other is ok but not both

@@ -169,14 +169,14 @@ class GraphQLInputObjectTypeTest extends Specification {
er = graphQL.execute(ei)
then:
!er.errors.isEmpty()
er.errors[0].message == "Exception while fetching data (/f) : Exactly one key must be specified for OneOf type 'OneOf'."
er.errors[0].message == "Exactly one key must be specified for OneOf type 'OneOf'."
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now caught earlier during variable value coercion

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

Successfully merging this pull request may close these issues.

None yet

1 participant