Skip to content

Commit

Permalink
Rhai documentation: remove incorrect statement about request.subgraph…
Browse files Browse the repository at this point in the history
… fields (#3808)

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

<!-- start metadata -->

**Checklist**

Complete the checklist (and note appropriate exceptions) before a final
PR is raised.

- [ ] Changes are compatible[^1]
- [ ] Documentation[^2] completed
- [ ] Performance impact assessed and acceptable
- Tests added and passing[^3]
    - [ ] Unit Tests
    - [ ] Integration Tests
    - [ ] Manual Tests

**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.
- please raise a separate issue to automate the test and label it (or
ask for it to be labeled) as `manual test`
  • Loading branch information
garypen authored Sep 13, 2023
1 parent 6648315 commit 36cd258
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
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

0 comments on commit 36cd258

Please sign in to comment.