From 019e120d19bcca48f66874259e47980502b8227e Mon Sep 17 00:00:00 2001 From: Gary Pennington Date: Wed, 3 Apr 2024 09:40:56 +0100 Subject: [PATCH] try to improve the docs based on Edward's comments Add a new paragraph to explain batching and make the changeset examples valid. --- .../feat_garypen_2002_subgraph_batching.md | 15 ++++++++++++--- .../executing-operations/query-batching.mdx | 8 ++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/.changesets/feat_garypen_2002_subgraph_batching.md b/.changesets/feat_garypen_2002_subgraph_batching.md index 2cfb6335c6..9f359ed034 100644 --- a/.changesets/feat_garypen_2002_subgraph_batching.md +++ b/.changesets/feat_garypen_2002_subgraph_batching.md @@ -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 \ No newline at end of file +By [@garypen](https://github.com/garypen) in https://github.com/apollographql/router/pull/4661 diff --git a/docs/source/executing-operations/query-batching.mdx b/docs/source/executing-operations/query-batching.mdx index 80916fcd39..3bb60a9633 100644 --- a/docs/source/executing-operations/query-batching.mdx +++ b/docs/source/executing-operations/query-batching.mdx @@ -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.