Feature/graphql error handling#88
Merged
joadan merged 1 commit intoLinq2GraphQL:mainfrom Apr 21, 2026
Merged
Conversation
…ption resilience - Add GraphQueryError with Extensions, ErrorCode, Locations, Path - Add GraphErrorCode enum (Apollo + Hot Chocolate codes) - Add GraphResult<T> with Data, Errors, Extensions, HasErrors, HasData - Add ExecuteWithResultAsync() for queries, mutations, cursor paging - Add ProcessResponseFull() parsing full GraphQL response (data+errors+extensions) - Handle WS error/complete messages, SSE event:error - Add SafeProcessMessage for subscription resilience - Add 32 error handling tests (99 total pass) - Add Error Handling docs to README
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.
Problem
The generated client silently swallowed GraphQL errors. ExecuteAsync threw a bare exception with no structured error data — no extensions, no error codes, no locations, no paths. Subscription errors were completely lost. There was no way to access both data and errors from a partial response.
Solution
Full GraphQL error propagation following the GraphQL spec §7.1 Response Format (https://spec.graphql.org/October2021/#sec-Response):
What's New
API
Existing — backward compatible, now with rich error details:
New — Result API, no exceptions:
Changes
Core — QueryExecutor.cs, GraphQueryExecute.cs, GraphBaseExecute.cs, GraphCursorPager.cs
→ ProcessResponseFull, ExecuteRawAsync, ExecuteWithResultAsync, paging variants
Types — GraphErrorCode.cs (new), GraphResult.cs (new), GraphQueryExecutionException.cs
→ Error classification (Apollo + Hot Chocolate codes), result wrapper, extensions on error
Subscriptions — WSClient.cs, SSEClient.cs, GraphSubscriptionExecute.cs, WebsocketRequestTypes.cs
→ WS error/complete messages, SSE event: error, SafeProcessMessage resilience
Tests — ErrorHandlingTests.cs (new), Query.cs (test server)
→ 32 new tests (99 total pass), error-raising test endpoints
Docs — README.md
→ Error Handling section with examples
Backward Compatibility
Fully backward compatible. ExecuteAsync() signature unchanged. New APIs are additive opt-in.