Skip to content
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

try to improve the docs based on Edward's comments #4895

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions .changesets/feat_garypen_2002_subgraph_batching.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,26 @@ batching:
enabled: true
mode: batch_http_link
subgraph:
# Enable batching on all subgraphs
all:
enabled: true
```

```yaml
batching:
enabled: true
mode: batch_http_link
subgraph:
# Configure batching support per subgraph
subgraphs:
subgraph_1:
enabled: true
subgraph_2:
enabled:true
````
enabled: true
```

Note: `all` and `subgraphs` are mutually exclusive. This applies in general for all router subgraph configuration options.

To learn more, see [query batching in Apollo docs](https://www.apollographql.com/docs/router/executing-operations/query-batching/).

By [@garypen](https://github.com/garypen) in https://github.com/apollographql/router/pull/4661
By [@garypen](https://github.com/garypen) in https://github.com/apollographql/router/pull/4661
8 changes: 8 additions & 0 deletions docs/source/executing-operations/query-batching.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ Learn about query batching and how to configure the Apollo Router to receive que

Modern applications often require several requests to render a single page. This is usually the result of a component-based architecture where individual micro-frontends (MFE) make requests separately to fetch data relevant to them. Not only does this cause a performance overhead—different components may be requesting the same data—it can also cause a consistency issue. To combat this, MFE-based UIs batch multiple client operations, issued close together, into a single HTTP request. This is supported in Apollo Client and Apollo Server.

The router's batching support is provided by two sets of functionality:
- client batching
- subgraph batching

With client batching, the router will accept batched requests from a client and then process each batch item separately. This means that requests to subgraphs are still processed individually. i.e.: they are not presented to subgraphs in batch form.

With subgraph batching, which is an extension to client batching and requires participating subgraphs to support batching request, the router analyses input client batch requests and issues batch requests to subgraphs. The analysis may result in multiple batches or requests being issued if data is required to be present in the router execution engine before further requests can be made. See the examples below to see illustrations of how this works in practice.

The Apollo Router supports client and subgraph query batching.

If you’re using Apollo Client, you can leverage the built-in support for batching to reduce the number of individual operations sent to the router.
Expand Down
Loading