This provides validation on @oneof input types during validation phase#3577
Merged
This provides validation on @oneof input types during validation phase#3577
Conversation
Note this is only when the AST literals are present - pure variables are handled later still just like in JS
bbakerman
commented
Apr 26, 2024
| Optional<GraphQLError> invalid = parseLiteral(value, ((GraphQLScalarType) type).getCoercing(), graphQLContext, locale); | ||
| invalid.ifPresent(graphQLError -> handleScalarError(value, (GraphQLScalarType) type, graphQLError)); | ||
| return !invalid.isPresent(); | ||
| return invalid.isEmpty(); |
Member
Author
There was a problem hiding this comment.
yellow squiggly line tweaks
bbakerman
commented
Apr 26, 2024
| } | ||
|
|
||
| boolean isValidLiteralValue(Value<?> value, GraphQLInputObjectType type, GraphQLSchema schema, GraphQLContext graphQLContext, Locale locale) { | ||
| boolean isValidLiteralValueForInputObjectType(Value<?> value, GraphQLInputObjectType type, GraphQLSchema schema, GraphQLContext graphQLContext, Locale locale) { |
Member
Author
There was a problem hiding this comment.
renamed the method to make it clearer on what its doing
bbakerman
commented
Apr 26, 2024
|
|
||
| def "invalid @oneOf argument - has more than 1 key - case #why"() { | ||
| when: | ||
| def validationErrors = validate(query) |
Member
Author
There was a problem hiding this comment.
uses a common specification schema under the covers
bbakerman
commented
Apr 26, 2024
| then: | ||
| validationErrors.size() == 1 | ||
| validationErrors.get(0).getValidationErrorType() == ValidationErrorType.WrongType | ||
| < 8000 /td> | validationErrors.get(0).message == "Validation error (WrongType@[oneOfField]) : Exactly one key must be specified for argument 'oneOfArg' of @oneOf input type 'oneOfInputType'" |
Member
Author
There was a problem hiding this comment.
I am not a fan of our validation error messages - and I made them!
One day I wish these where better!
Fixed tests and error messages
Closed
dondonz
reviewed
Jun 2, 2024
dondonz
approved these changes
Jun 2, 2024
Co-authored-by: dondonz <13839920+dondonz@users.noreply.github.com>
Contributor
|
Thanks for doing this! |
Member
Thanks so much for suggesting the improvements! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note this is only when the AST literals are present - pure variables are handled later still just like in JS
#3572
so
f(arg : { a : "x", b: $y})will be handled but notf(arg:$variable)which uses the existing code and still is lazy at this stagere: #3572