Skip to content

feat!: support partial responses#610

Open
stuebingerb wants to merge 1 commit intomainfrom
feature/support-partial-responses
Open

feat!: support partial responses#610
stuebingerb wants to merge 1 commit intomainfrom
feature/support-partial-responses

Conversation

@stuebingerb
Copy link
Copy Markdown
Owner

Adds support for proper error handling and partial responses as defined by the spec, cf. https://spec.graphql.org/September2025/#sec-Errors

KGraphQL now distinguishes between request and execution errors, and the latter now result in a response that contains both, data and errors. Execution errors result in a value of null for nullable fields, and will bubble up to their parent node for non-nullable fields. Additionally, resolvers can now raise execution errors while still returning data.

If data and errors are present in the response, the errors key is serialized first to make it more apparent that errors are present.

Behavior for request errors is unchanged, and wrapErrors configuration is still supported for now - but likely subject to change in the future.

Resolves #114

BREAKING CHANGE: relying on exceptions being thrown from query execution may no longer work as before. It is advised to specify wrapErrors = false and report an issue with the respective use case.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 15, 2026

Codecov Report

❌ Patch coverage is 86.46288% with 31 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.09%. Comparing base (e6969de) to head (c70d308).

Files with missing lines Patch % Lines
...raphql/schema/execution/ParallelRequestExecutor.kt 93.49% 3 Missing and 5 partials ⚠️
...e/kgraphql/schema/execution/ArgumentTransformer.kt 73.07% 7 Missing ⚠️
...n/com/apurebase/kgraphql/schema/scalar/Coercion.kt 22.22% 6 Missing and 1 partial ⚠️
.../schema/execution/AbstractRemoteRequestExecutor.kt 88.88% 0 Missing and 3 partials ⚠️
...purebase/kgraphql/schema/builtin/BuiltInScalars.kt 80.00% 0 Missing and 3 partials ⚠️
...m/apurebase/kgraphql/helpers/KGraphQLExtensions.kt 83.33% 0 Missing and 2 partials ⚠️
...lin/com/apurebase/kgraphql/schema/DefaultSchema.kt 90.90% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #610      +/-   ##
==========================================
+ Coverage   84.00%   84.09%   +0.08%     
==========================================
  Files         152      151       -1     
  Lines        4978     4999      +21     
  Branches      861      861              
==========================================
+ Hits         4182     4204      +22     
  Misses        495      495              
+ Partials      301      300       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Adds support for proper error handling and partial responses as
defined by the spec, cf. https://spec.graphql.org/September2025/#sec-Errors

KGraphQL now distinguishes between _request_ and _execution_ errors,
and the latter now result in a response that contains both, `data` and
`errors`. Execution errors result in a value of `null` for nullable
fields, and will bubble up to their parent node for non-nullable
fields. Additionally, resolvers can now raise execution errors while
still returning data.

If data _and_ errors are present in the response, the `errors` key is
serialized first to make it more apparent that errors are present.

Behavior for request errors is unchanged, and `wrapErrors` configuration
is still supported for now - but likely subject to change in the
future.

Resolves #114

BREAKING CHANGE: relying on exceptions being thrown from query
execution may no longer work as before. It is advised to specify
`wrapErrors = false` and report an issue with the respective use case.
@stuebingerb stuebingerb force-pushed the feature/support-partial-responses branch from acea407 to c70d308 Compare April 15, 2026 13:37
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 15, 2026

🐰 Bencher Report

Branchfeature/support-partial-responses
Testbedubuntu-latest

🚨 1 Alert

BenchmarkMeasure
Units
ViewBenchmark Result
(Result Δ%)
Lower Boundary
(Limit %)
com.apurebase.kgraphql.RequestCachingBenchmark.invalidRequestThroughput
operations / second (ops/s) x 1e3
📈 plot
🚷 threshold
🚨 alert (🔔)
144.48 ops/s x 1e3
(-35.87%)Baseline: 225.31 ops/s x 1e3
208.95 ops/s x 1e3
(144.62%)

Click to view all benchmark results
BenchmarkThroughputBenchmark Result
operations / second (ops/s)
(Result Δ%)
Lower Boundary
operations / second (ops/s)
(Limit %)
com.apurebase.kgraphql.FunctionExecutionBenchmark.benchmarkFunctionExecution📈 view plot
🚷 view threshold
5,976,206.90 ops/s
(+1.81%)Baseline: 5,869,764.25 ops/s
5,212,577.41 ops/s
(87.22%)
com.apurebase.kgraphql.ParallelExecutionBenchmark.queryBenchmark📈 view plot
🚷 view threshold
1.30 ops/s
(-0.20%)Baseline: 1.30 ops/s
1.30 ops/s
(99.99%)
com.apurebase.kgraphql.QueryBenchmark.executionError📈 view plot
🚷 view threshold
16,914.29 ops/s
(+0.32%)Baseline: 16,859.58 ops/s
11,655.17 ops/s
(68.91%)
com.apurebase.kgraphql.QueryBenchmark.inputFromDocument📈 view plot
🚷 view threshold
19,640.40 ops/s
(-9.70%)Baseline: 21,749.82 ops/s
16,054.30 ops/s
(81.74%)
com.apurebase.kgraphql.QueryBenchmark.inputFromVariable📈 view plot
🚷 view threshold
18,813.68 ops/s
(-8.99%)Baseline: 20,671.38 ops/s
15,516.15 ops/s
(82.47%)
com.apurebase.kgraphql.QueryBenchmark.largeList📈 view plot
🚷 view threshold
4.73 ops/s
(+5.57%)Baseline: 4.48 ops/s
3.89 ops/s
(82.26%)
com.apurebase.kgraphql.QueryBenchmark.largeListWithFragment📈 view plot
🚷 view threshold
5.27 ops/s
(+6.35%)Baseline: 4.95 ops/s
4.32 ops/s
(82.05%)
com.apurebase.kgraphql.QueryBenchmark.manyChildren📈 view plot
🚷 view threshold
179.77 ops/s
(-4.28%)Baseline: 187.81 ops/s
156.12 ops/s
(86.84%)
com.apurebase.kgraphql.QueryBenchmark.manyChildrenWithFragment📈 view plot
🚷 view threshold
197.91 ops/s
(-6.83%)Baseline: 212.42 ops/s
175.03 ops/s
(88.44%)
com.apurebase.kgraphql.QueryBenchmark.manyDataChildren📈 view plot
🚷 view threshold
8.92 ops/s
(-0.22%)Baseline: 8.94 ops/s
8.84 ops/s
(99.15%)
com.apurebase.kgraphql.QueryBenchmark.manyOperations📈 view plot
🚷 view threshold
302.12 ops/s
(+7.55%)Baseline: 280.91 ops/s
227.24 ops/s
(75.21%)
com.apurebase.kgraphql.QueryBenchmark.manyOperationsWithFragment📈 view plot
🚷 view threshold
309.90 ops/s
(+7.86%)Baseline: 287.30 ops/s
231.29 ops/s
(74.63%)
com.apurebase.kgraphql.QueryBenchmark.nestedObject📈 view plot
🚷 view threshold
7,314.75 ops/s
(-1.78%)Baseline: 7,447.16 ops/s
6,235.89 ops/s
(85.25%)
com.apurebase.kgraphql.RequestCachingBenchmark.invalidRequest📈 view plot
🚷 view threshold
🚨 view alert (🔔)
144,480.21 ops/s
(-35.87%)Baseline: 225,308.89 ops/s
208,951.99 ops/s
(144.62%)

com.apurebase.kgraphql.RequestCachingBenchmark.largeRequest📈 view plot
🚷 view threshold
7,437.61 ops/s
(-3.47%)Baseline: 7,705.19 ops/s
6,484.10 ops/s
(87.18%)
com.apurebase.kgraphql.RequestCachingBenchmark.smallRequest📈 view plot
🚷 view threshold
10,197.22 ops/s
(-9.36%)Baseline: 11,250.69 ops/s
9,170.66 ops/s
(89.93%)
com.apurebase.kgraphql.SimpleExecutionOverheadBenchmark.benchmark📈 view plot
🚷 view threshold
474,226.98 ops/s
(+0.57%)Baseline: 471,558.92 ops/s
452,575.87 ops/s
(95.43%)
🐰 View full continuous benchmarking report in Bencher

@stuebingerb
Copy link
Copy Markdown
Owner Author

stuebingerb commented Apr 15, 2026

This is part 3 of revisited error handling after #560 and #567.
The next pull request (#611) will move the current error handler from Ktor to the schema itself and use it during handleException. Another (future) pull request may then remove wrapErrors in favor of GraphQL-over-HTTP.

@stuebingerb
Copy link
Copy Markdown
Owner Author

@grumpy-programmer Sorry, this took way longer than anticipated but - following our conversation in #437 - if you're still interested in discussing error handling then I'd be happy to receive your thoughts here and in the linked pull requests 🙂

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.

Support partial responses

1 participant