Title: Bugfix: spec-compliant behaviour for non-nullable types with default values. by folone · Pull Request #2573 · graphql-java/graphql-java · GitHub
Open Graph Title: Bugfix: spec-compliant behaviour for non-nullable types with default values. by folone · Pull Request #2573 · graphql-java/graphql-java
X Title: Bugfix: spec-compliant behaviour for non-nullable types with default values. by folone · Pull Request #2573 · graphql-java/graphql-java
Description: Hi folks! Problem Graphql-java currently fails the document validation for queries that use nullable types for non-nullable schema field arguments with default values. As per spec: A notable exception to typical variable type compatibility is allowing a variable definition with a nullable type to be provided to a non‐null location as long as either that variable or that location provides a default value. Here's a discussion from 2018 where this change to the spec was adopted: graphql/graphql-spec#418. Motivating example: Schema: type Query { hello(arg: Boolean! = true) } Query: query Test($var: Boolean) { hello(arg: $var) } This is expected to pass the validation, but currently fails: ValidationError{validationErrorType=VariableTypeMismatch, queryPath=[hello], message=Validation error of type VariableTypeMismatch: Variable type 'Boolean' doesn't match expected type 'Boolean!' @ 'hello', locations=[SourceLocation{line=3, column=25}], description='Variable type 'Boolean' doesn't match expected type 'Boolean!''} Solution This patch fixes the issue by extracting the schema-defined default value for the argument (if present), and checks that in the VariablesTypeMatcher along with the original check. This also adds a regression test to exercise this fix, similar to the test in the reference GraphQL implementation.
Open Graph Description: Hi folks! Problem Graphql-java currently fails the document validation for queries that use nullable types for non-nullable schema field arguments with default values. As per spec: A notable excep...
X Description: Hi folks! Problem Graphql-java currently fails the document validation for queries that use nullable types for non-nullable schema field arguments with default values. As per spec: A notable excep...
Opengraph URL: https://github.com/graphql-java/graphql-java/pull/2573
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:248d54ba-807d-7fbe-10f1-530e216825ad |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | D432:8A973:196B52:21F642:6A616B6D |
| html-safe-nonce | 11c0a74e620ea3a454f37674e1203dc74600b49b5f2a7908bf2848a5c9183db4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENDMyOjhBOTczOjE5NkI1MjoyMUY2NDI6NkE2MTZCNkQiLCJ2aXNpdG9yX2lkIjoiNjMzMzY0MDMyMDE2MjU1Njc4MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | a1a4856dc9caa5802dda9a79ec3228f9777b6b406fa0fdc26df49821522014ca |
| hovercard-subject-tag | pull_request:749862831 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/graphql-java/graphql-java/pull/2573/files |
| twitter:image | https://avatars.githubusercontent.com/u/366132?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/366132?s=400&v=4 |
| og:image:alt | Hi folks! Problem Graphql-java currently fails the document validation for queries that use nullable types for non-nullable schema field arguments with default values. As per spec: A notable excep... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | a69385f7d268ece7ad25b131bbd70f457024811fc79afcae43785a6849b724e2 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/graphql-java/graphql-java git https://github.com/graphql-java/graphql-java.git |
| octolytics-dimension-user_id | 14289921 |
| octolytics-dimension-user_login | graphql-java |
| octolytics-dimension-repository_id | 38602457 |
| octolytics-dimension-repository_nwo | graphql-java/graphql-java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 38602457 |
| octolytics-dimension-repository_network_root_nwo | graphql-java/graphql-java |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 484cf265a1f970d5c7a5e7c37cb677d8010aa12f |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width