-
Notifications
You must be signed in to change notification settings - Fork 280
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
add a JSON manipulation plugin stage #5865
base: dev
Are you sure you want to change the base?
Conversation
this stage will sit between the router stage and supergraph stage, and allow 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.
@Geal, please consider creating a changeset entry in |
CI performance tests
|
not plugged to anything yet
no plugins yet, some tests are failing
extensions and variables are serialized as a string, so we need to deserialize them again
|| response | ||
.as_object() | ||
.and_then(|o| o.get("payload")) | ||
.and_then(|v| v.as_object()) | ||
.map(|o| !o.is_empty()) | ||
.unwrap_or(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it won't work, it's more complicated than this IIRC
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you see cases where it would fail, that I could add to unit tests?
&& response | ||
.as_object() | ||
.and_then(|o| o.get("payload")) | ||
.and_then(|v| v.as_object()) | ||
.is_none() | ||
&& response | ||
.as_object() | ||
.and_then(|o| o.get("errors")) | ||
.and_then(|v| v.as_array()) | ||
.map(|v| v.is_empty()) | ||
.unwrap_or(true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here. I think we make a difference between Some(Null)
and None
_ => response.into(), | ||
}, | ||
}; | ||
serde_json_bytes::to_value(r).unwrap() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use expect
✅ Docs Preview ReadyNo new or changed pages found. |
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:
serde_json_bytes::Value
natively instead of the similar type fromserde_json
Questions that we should ask:
JsonServerService
the right name for it?Checklist
Complete the checklist (and note appropriate exceptions) before the PR is marked ready-for-review.
Exceptions
Note any exceptions here
Notes
Footnotes
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. ↩
Configuration is an important part of many changes. Where applicable please try to document configuration examples. ↩
Tick whichever testing boxes are applicable. If you are adding Manual Tests, please document the manual testing (extensively) in the Exceptions. ↩