Fix 6 GraphQL error handling deficiencies. 4 phases, 12 steps. Each step leaves codebase buildable and backward-compatible.
- File:
src/Linq2GraphQL.Client/Exceptions/GraphQueryExecutionException.cs - Action: Add
[JsonPropertyName("extensions")] public Dictionary<string, object>? Extensions { get; set; }toGraphQueryError - Effort: 2 min | Risk: Low | BC: 100%
- New File:
src/Linq2GraphQL.Client/Exceptions/GraphErrorCode.cs - Action: Enum with standard codes (UNAUTHENTICATED, FORBIDDEN, VALIDATION, etc.) +
GraphErrorCodeClassifierstatic helper - Also: Add
ErrorCodecomputed property toGraphQueryError - Effort: 10 min | Risk: Low | BC: 100%
- New File:
src/Linq2GraphQL.Client/GraphResult.cs - Action:
GraphResult<T>withData,Errors,Extensions,HasErrors,HasData - Effort: 5 min | Risk: Low | BC: 100%
- File:
src/Linq2GraphQL.Client/QueryExecutor.cs - Action: New
internal GraphResult<T> ProcessResponseFull(...)that parses data+errors+extensions. Keep existingProcessResponseas backward-compat wrapper. - Effort: 15 min | Risk: Medium | BC: 100%
- File:
src/Linq2GraphQL.Client/GraphQueryExecute.cs+QueryExecutor.cs - Action: Add
ExecuteRawAsyncto QueryExecutor, addExecuteBaseWithResultAsync+ExecuteWithResultAsyncto GraphQueryExecute - Effort: 15 min | Risk: Medium | BC: 100%
- File:
src/Linq2GraphQL.Client/GraphQueryExecute.cs+GraphCursorPager.cs - Action: Same pattern for
GraphCursorQueryExecuteand pager - Effort: 10 min | Risk: Low | BC: 100%
- Files:
WebsocketRequestTypes.cs,WebsocketResponse.cs,WSClient.cs - Action: Add message type constants, handle error/complete in WSClient message routing, propagate via OnError/OnCompleted
- Effort: 25 min | Risk: Medium | BC: Behavioral fix
- File:
GraphSubscriptionExecute.cs - Action: Replace
SelectwithSelectMany+ try/catch — skip bad messages, don't kill stream - Effort: 15 min | Risk: Medium | BC: Behavioral fix
- File:
SSEClient.cs - Action: Wrap HTTP errors in
GraphQueryRequestException, null checks, parseevent: errorSSE frames - Effort: 10 min | Risk: Low | BC: 100%
- New File:
test/Linq2GraphQL.Tests/ErrorHandlingTests.cs - Action: Test extensions deserialization, GraphResult partial data, error codes, subscription error resilience
- Effort: 20 min | Risk: Low
- Action:
dotnet build+dotnet test - Effort: 5 min
1.1 → 1.2 → 1.3 → 2.1 → 2.2 → 2.3
↘
1.1 → 3.1 → 3.2
↘ 3.3
→ 4.1 → 4.2
| Step | Risk | Mitigation |
|---|---|---|
| 1.1-1.3 | Low | Additive only, no behavioral change |
| 2.1-2.3 | Medium | Keep old APIs, add new opt-in APIs |
| 3.1-3.2 | Medium | Test with both WS protocols |
| 3.3 | Low | Defensive coding |
| 4.1-4.2 | Low | Tests are additive |