Skip to content

Commit

Permalink
document guidance for request and response buffering (#3970)
Browse files Browse the repository at this point in the history
Provides specific guidance on request and response buffering within the
router.

fixes: #3838

<!-- 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

**Exceptions**

*Note any exceptions here*

**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]>
  • Loading branch information
garypen and shorgi authored Oct 9, 2023
1 parent 9fd3ed4 commit 913d391
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changesets/docs_garypen_3838_document_buffering.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
### Document guidance for request and response buffering ([Issue #3838](https://github.com/apollographql/router/issues/3838))

Provides specific guidance on request and response buffering within the router.

By [@garypen](https://github.com/garypen) in https://github.com/apollographql/router/pull/3970
16 changes: 15 additions & 1 deletion docs/source/customizations/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,20 @@ flowchart LR;

Additionally, some requests and responses may happen multiple times for the same operation. With subscriptions, for example, a subgraph sends a new `SubgraphResponse` whenever data is updated. Each response object travels through all the services in the response path and interacts with any customizations you've created.

### Request and Response buffering

The router expects to execute on a stream of data. In order to work correctly and provide high performance, the following expectations must be met:

* **Request Path**: No buffering before the end of the `router_service` processing step
* **Response Path**: No buffering

> In general, it's best to avoid buffering where possible. If necessary, it is ok to do so on the request path once the `router_service` step is complete.
This guidance applies if you are:
- Modifying the router
- Creating a native Rust plugin
- Creating a custom binary

## Customization creation

To learn how to hook in to the various lifecycle stages, including examples customizations, refer to the [Rhai scripts](./rhai/) and [external coprocessing](./coprocessor/) docs.
To learn how to hook in to the various lifecycle stages, including examples customizations, refer to the [Rhai scripts](./rhai/) and [external coprocessing](./coprocessor/) docs.

0 comments on commit 913d391

Please sign in to comment.