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

Rhai documentation: remove incorrect statement about request.subgraph fields #3808

Merged
merged 3 commits into from
Sep 13, 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_fix_rhai_subgraph_docs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
### Rhai documentation: remove incorrect statement about request.subgraph fields ([PR #3808](https://github.com/apollographql/router/pull/3808))

It is possible to modify `request.subgraph` fields from a `Rhai` script and so the documentation should reflect that.

By [@garypen](https://github.com/garypen) in https://github.com/apollographql/router/pull/3808
8 changes: 3 additions & 5 deletions docs/source/customizations/rhai-api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ Note: get() may fail, so it's best to handle exceptions when using it.

## `Request` interface

All callback functions registered via `map_request` are passed a `request` object that represents the request sent by the client. This object provides the following fields, most of which a callback can modify in-place (read-write):
All callback functions registered via `map_request` are passed a `request` object that represents the request sent by the client. This object provides the following fields:

```
request.context
Expand All @@ -302,9 +302,9 @@ request.body.extensions
request.uri.host
request.uri.path
```
Note: `method` is read-only.
Note: These fields are typically modifiable, apart from `method` which is always read-only. However, when the callback service is `subgraph_service`,the only modifiable field is `request.context`.

**For `subgraph_service` callbacks only,** the `request` object provides _additional_ fields for interacting with the request that will be sent to the corresponding subgraph:
**For `subgraph_service` callbacks only,** the `request` object provides _additional_ modifiable fields for interacting with the request that will be sent to the corresponding subgraph:

```
request.subgraph.headers
Expand All @@ -316,8 +316,6 @@ request.subgraph.uri.host
request.subgraph.uri.path
```

These additional fields are shared across all subgraph invocations and are thus read-only.

### `request.context`

The context is a generic key/value store that exists for the entire lifespan of a particular client request. You can use this to share information between multiple callbacks throughout the request's lifespan.
Expand Down