-
Notifications
You must be signed in to change notification settings - Fork 272
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
experimental support for query batching (#3837)
Things needing attention - [x] Configuration to match the design - [x] Decide if cloning `parts` is acceptable (in review) It isn't, so not cloned but re-built. - [x] Decide if cloning context for each `SupergraphRequest` is acceptable (in review) - [x] Should we do special handling if `@defer` or `subscription` detected in batch? - [x] Metrics - [x] Find someone happy to test from an appropriately configured Apollo Client and verify it works - [x] Modify Apollo telemetry to create separate root traces for each batch entry Fixes #126 <!-- start metadata --> --- **Checklist** Complete the checklist (and note appropriate exceptions) before the PR is marked ready-for-review. - [x] Changes are compatible[^1] - [x] Documentation[^2] completed - [x] Performance impact assessed and acceptable - Tests added and passing[^3] - [x] Unit Tests - [x] Integration Tests - [x] Manual Tests **Exceptions** Manual testing was performed with `curl` and [apollo client](https://www.apollographql.com/docs/react/api/link/apollo-link-batch-http/) **Notes** [^1]: It may be appropriate to bring upcoming changes to the attention of other (impacted) groups. Please endeavour to do this before seeking PR approval. The mechanism for doing this will vary considerably, so use your judgement as to how and when to do this. [^2]: Configuration is an important part of many changes. Where applicable please try to document configuration examples. [^3]: Tick whichever testing boxes are applicable. If you are adding Manual Tests, please document the manual testing (extensively) in the Exceptions. --------- Co-authored-by: Edward Huang <[email protected]> Co-authored-by: Geoffroy Couprie <[email protected]> Co-authored-by: Maria Elisabeth Schreiber <[email protected]>
- Loading branch information
1 parent
bca9d86
commit aeb5ffe
Showing
24 changed files
with
3,649 additions
and
292 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
### query batching prototype ([Issue #126](https://github.com/apollographql/router/issues/126)) | ||
|
||
An experimental implementation of query batching which adds support for client request batching to the Apollo Router. | ||
|
||
If you’re using Apollo Client, you can leverage the in-built support for batching to reduce the number of individual requests sent to the Apollo Router. | ||
|
||
Once [configured](https://www.apollographql.com/docs/react/api/link/apollo-link-batch-http/), Apollo Client will automatically combine multiple operations into a single HTTP request. The number of operations within a batch is client configurable, including the maximum number of operations in a batch and the maximum duration to wait for operations to accumulate before sending the batch request. | ||
|
||
The Apollo Router must be configured to receive batch requests, otherwise it rejects them. When processing a batch request, the router deserializes and processes each operation of a batch independently, and it responds to the client only after all operations of the batch have been completed. | ||
|
||
```yaml | ||
experimental_batching: | ||
enabled: true | ||
mode: batch_http_link | ||
``` | ||
All operations within a batch will execute concurrently with respect to each other. | ||
Do not attempt to use subscriptions or `@defer` queries within a batch as they are not supported. | ||
|
||
By [@garypen](https://github.com/garypen) in https://github.com/apollographql/router/pull/3837 |
This file contains 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
This file contains 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
This file contains 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
8 changes: 8 additions & 0 deletions
8
.../snapshots/apollo_router__configuration__metrics__test__metrics@batching.router.yaml.snap
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
source: apollo-router/src/configuration/metrics.rs | ||
expression: "&metrics.metrics" | ||
--- | ||
value.apollo.router.config.batching: | ||
- 1 | ||
- opt__mode__: batch_http_link | ||
|
This file contains 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
3 changes: 3 additions & 0 deletions
3
apollo-router/src/configuration/testdata/metrics/batching.router.yaml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
experimental_batching: | ||
enabled: true | ||
mode: batch_http_link |
This file contains 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
Oops, something went wrong.