-
-
Notifications
You must be signed in to change notification settings - Fork 542
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP defer support #3753
base: main
Are you sure you want to change the base?
WIP defer support #3753
Conversation
Reviewer's Guide by SourceryThis PR implements support for @defer and @stream directives. It introduces handling for multipart responses in subscriptions and modifies the GraphiQL HTML to use a newer version. Sequence diagram for incremental execution with @defersequenceDiagram
participant Client
participant Server
participant GraphQL
Client->>Server: Send GraphQL query with @defer
Server->>GraphQL: Execute query incrementally
GraphQL-->>Server: Return initial result
Server-->>Client: Send initial response
loop Subsequent Results
GraphQL-->>Server: Return deferred result
Server-->>Client: Send multipart response
end
Server-->>Client: Send end boundary
Class diagram for incremental execution resultsclassDiagram
class ExecutionResult
class ExperimentalIncrementalExecutionResults
class InitialIncrementalExecutionResult
class SubsequentIncrementalExecutionResult
class IncrementalResult
class IncrementalDeferResult
class IncrementalStreamResult
ExperimentalIncrementalExecutionResults --> InitialIncrementalExecutionResult
ExperimentalIncrementalExecutionResults --> SubsequentIncrementalExecutionResult
IncrementalResult <|-- IncrementalDeferResult
IncrementalResult <|-- IncrementalStreamResult
class IncrementalDeferResult {
+data
+errors
+path
+label
+extensions
}
class IncrementalStreamResult {
+items
+errors
+path
+label
+extensions
}
Flow diagram for multipart response handlingflowchart TD
A[Receive Query] --> B{Is Incremental?}
B -->|Yes| C[Process Initial Result]
C --> D[Send Initial Response]
D --> E[Process Subsequent Results]
E --> F{Has Next?}
F -->|Yes| E
F -->|No| G[Send End Boundary]
B -->|No| H[Process Normal Result]
H --> I[Send Response]
style B decision
style F decision
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
9e7d000
to
573fa72
Compare
CodSpeed Performance ReportMerging #3753 will improve performances by ×3.2Comparing Summary
Benchmarks breakdown
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3753 +/- ##
==========================================
- Coverage 97.27% 9.90% -87.37%
==========================================
Files 504 502 -2
Lines 33481 32388 -1093
Branches 5503 1673 -3830
==========================================
- Hits 32567 3208 -29359
- Misses 703 29024 +28321
+ Partials 211 156 -55 |
Me and Thiago spent a bit of time on this again today 😊 Here's a report of what we need to think about for next time:
We also need to think about the Not sure how can fill it in the subsequent response data, see this test for the shape: async def test_basic_defer(method: Literal["get", "post"], http_client: HttpClient):
response = await http_client.query(
method=method,
query="""{
hello
... @defer {
asyncHello
}
}""",
)
async with contextlib.aclosing(response.streaming_json()) as stream:
initial = await stream.__anext__()
assert initial == {
"data": {"hello": "Hello world"},
"incremental": [],
"hasNext": True,
# TODO: why is this None?
"extensions": None,
}
subsequent = await stream.__anext__()
assert subsequent == {
"incremental": [
{
"data": {"asyncHello": "Hello world"},
"extensions": {"example": "example"},
}
],
"hasNext": False,
# TODO: how do we fill these?
"extensions": None,
} |
Worked on this with @bellini666
Still need to check:
Summary by Sourcery
Implement support for @defer directive. This allows deferring the execution of specific fields in a query, improving initial response times.
New Features:
@defer
directive, enabling deferred execution of selected fields within a query.Tests:
@defer
directive, covering basic functionality and multipart subscriptions.