router
router copied to clipboard
add a JSON manipulation plugin stage
Note: I am asking for an early review of this before going through all the relevant API, docs, test work to make this production ready, so we can discuss first if the pipeline changes described below make sense, or if some of them should be moved elsewhere
this stage sits between the router stage and supergraph stage, and allows request and response manipulation in JSON format, without needing explicit buffering and deserialization at the router stage, and working with data that does not serialize cleanly to GraphQL requests and response objects.
This change will only add the new stage with a private plugin part. The public plugin, rhai and coprocessor usage will come as a follow up.
Notable changes:
- batching is now handled at the JSON stage. This is a bit easier to handle since it is directly working on JSON values. Batching has been updated to use
serde_json_bytes::Valuenatively instead of the similar type fromserde_json - operations transmitted in the query string are transformed to a JSON body at the router service level, to make sure that JSON service plugins are always working with JSON bodies (in the future, headers would not be relevant anymore at that stage)
- the multipart protocol needs to work on JSON values now instead of GraphQL response objects. This makes it a bit more brittle
- APQ and persisted queries are now executed in the JSON service. They could be moved to a JSON service plugin
- query analysis now runs in the JSON service. That means that the query will be modifiable by users (once we add a plugin/rhai/coprocessor step) before going through validation, without having to deserialize and reserialize a JSON request
- this will probably have some latency overhead, because instead of going directly between bytes and GraphQL request/response objects, we go through a JSON value. Probably low overhead on the request side, and we should check on the response side if we can reduce it, because most of the data will already be in the form of a JSON value
Questions that we should ask:
- are the different tasks performed at the right point? (especially query string parsing and batching)
- which plugins should be moved from supergraph service to JSON service?
- what do we need in the request and response API at that level?
- the fact that this passes existing tests is a good sign, but are there more tests that we culd add to validate the interaction between router service, JSON service and supergraph service?
- is
JsonServerServicethe right name for it?
Checklist
Complete the checklist (and note appropriate exceptions) before the PR is marked ready-for-review.
- [ ] 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.