Title: Coerce field arguments before invoking data fetchers by andimarek · Pull Request #4522 · graphql-java/graphql-java · GitHub
Open Graph Title: Coerce field arguments before invoking data fetchers by andimarek · Pull Request #4522 · graphql-java/graphql-java
X Title: Coerce field arguments before invoking data fetchers by andimarek · Pull Request #4522 · graphql-java/graphql-java
Description: Argument coercion currently runs only when something reads a field's arguments. A data fetcher that ignores them can therefore return a result for invalid inputs; one that reads them can perform side effects before coercion fails. For example, query($v: String = "default") { f(arg: [$v]) } with {"v": null} passes document and variable validation against f(arg: [String!]!): String, but argument coercion must fail before calling f. This complements #4507, which added the non-null checks themselves. Force the existing memoized argument supplier before invoking either a regular or lightweight data fetcher, inside the existing exception-handling boundary. This preserves field-error handling, null propagation, instrumentation, and DataLoader dispatch. Fields without argument definitions keep lazy environment construction. Adds 45 Spock cases covering queries, mutation side effects and ordering, subscriptions, nested inputs, property/lightweight fetchers, aliases and list paths, skipped/unreached fields, deferred results, scalar coercion/memoization, exception handlers, and all three DataLoader dispatch modes. On master, 36 of these cases fail; with this change, all 45 pass. Validation: ./gradlew test testng jacocoTestReport on Java 25 passed (6,223 tests, zero failures, 57 existing skips). The local per-class coverage comparison against the committed baseline found no regressions. Exploratory local JMH comparison with master (Java 25, 2 forks, 3 × 1s warmup, 5 × 1s measurement): a 100-item query took 15.1 → 15.7 µs without arguments, 57.9 → 57.8 µs when fetchers read literal arguments, and 15.8 → 53.8 µs when property fetchers ignored literal arguments. The latter now performs the required coercion. The existing ExecutionBenchmark measured 269 → 262 µs, within measurement uncertainty. The no-argument path retains its allocation savings but does add the argument-definition check.
Open Graph Description: Argument coercion currently runs only when something reads a field's arguments. A data fetcher that ignores them can therefore return a result for invalid inputs; one that reads them can perfor...
X Description: Argument coercion currently runs only when something reads a field's arguments. A data fetcher that ignores them can therefore return a result for invalid inputs; one that reads them can pe...
Opengraph URL: https://github.com/graphql-java/graphql-java/pull/4522
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:9542ba8e-afa3-8c2f-7f53-12625d424bf3 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 97F6:17FB7:1B106FB:2245261:6B018B0D |
| html-safe-nonce | d66e5f6534686824bc92080b8d1e057407b8fc8f7ae5111756ceb1296ee5fac7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5N0Y2OjE3RkI3OjFCMTA2RkI6MjI0NTI2MTo2QjAxOEIwRCIsInZpc2l0b3JfaWQiOiIyOTE5OTI3NDAxOTQ3NDMzNzQxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 102f1c353517a474cca33966e28d81506add09577a6ecdcf541d7662c2a51945 |
| hovercard-subject-tag | pull_request:5104715094 |
| 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/4522/files |
| twitter:image | https://avatars.githubusercontent.com/u/1706744?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/1706744?s=400&v=4 |
| og:image:alt | Argument coercion currently runs only when something reads a field's arguments. A data fetcher that ignores them can therefore return a result for invalid inputs; one that reads them can perfor... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| 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 | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width