feat: Expose Query Plan to ExecutionRequest (and improve rhai unit test patterns)#2081
feat: Expose Query Plan to ExecutionRequest (and improve rhai unit test patterns)#2081
ExecutionRequest (and improve rhai unit test patterns)#2081Conversation
Add unit tests for all rhai `request` and `response` accessors.
If a test fails, you'll see something like:
thread 'plugins::rhai::tests::it_can_process_supergraph_request' panicked at 'test failed: ErrorInFunctionCall("process_supergraph_request", "", ErrorRuntime("query: expected: #{\"first\": 1}, actual: #{\"first\": 2}", 60:9), none)', apollo-router/src/plugins/rhai.rs:1749:16
Which is telling you why the rhai script failed (expected != actual) and
where it failed: functiona name, line number character offset.
That should be enough to figure out what the problem is.
also:
- add support for reading the query_plan from an ExecutionRequest
- add contains function for context
This comment has been minimized.
This comment has been minimized.
o0Ignition0o
left a comment
There was a problem hiding this comment.
We should try to followup on this with a way to run a test directly from rhai (although i m not sure it s easily feasible ^^'
|
In staging the release, I was confused following the link to this PR from the change log, which refers to it as "Add Query Plan access to ExecutionRequest". I'm going to rename this PR on account of that, but happy to rename it back if that feels wrong. |
ExecutionRequest
|
In fact, I've re-worked the whole PR body since I'd claim that adding tests was a thing that was done on the feature, rather than the feature being an accidental outcome of adding Rhai tests? 😄. (Maybe that's how it worked out, I don't know, but it seemed odd to have them intertwined, to me doing the release.) |
ExecutionRequestExecutionRequest (and improve rhai testing story)
ExecutionRequest (and improve rhai testing story)ExecutionRequest (and improve rhai unit test patterns)
|
I think your naming is more sensible. I added the improved unit testing stuff and got carried away with it... |
Introduce support for reading the
query_planfrom anExecutionRequestAlso, adds unit tests for all rhai
requestandresponseaccessors.Now, if a test fails, you'll see something like:
Which is telling you why the rhai script failed (expected != actual) and where it failed: functiona name, line number character offset. That should be enough to figure out what the problem is.