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

document guidance for request and response buffering #3970

Merged
merged 5 commits into from
Oct 9, 2023
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
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.