-
Notifications
You must be signed in to change notification settings - Fork 273
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
Progressive override: fix query planner cache warmup #6108
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
7290a1a
integration test for progressive override
Geal 0016e2a
integrate rhai
Geal 82d68b8
test label override
Geal eac41f9
move test
Geal 7a75530
progressive override warmup test
Geal d006090
cleanup test
Geal 5aee2ec
log previously received requests on reload
Geal 38fd137
set the labels to override in context when warming up the query plann…
Geal 8b47285
fix test
Geal 487bf79
Bump CircleCI cache key
abernix 3208d6e
changeset
Geal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
### Progressive override: fix query planner cache warmup ([PR #6108](https://github.com/apollographql/router/pull/6108)) | ||
|
||
This fixes an issue in progressive override where the override labels would not be transmitted to the query planner during cache warmup, resulting in queries correctly using the overridden fields at first, but after an update, would revert to non overridden fields, and could not recover. | ||
|
||
By [@Geal](https://github.com/Geal) in https://github.com/apollographql/router/pull/6108 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
apollo-router/tests/samples/enterprise/progressive-override/basic/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Progressive override | ||
|
||
This tests subgraph field migration: https://www.apollographql.com/docs/federation/entities/migrate-fields/ |
13 changes: 13 additions & 0 deletions
13
apollo-router/tests/samples/enterprise/progressive-override/basic/configuration.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
include_subgraph_errors: | ||
all: true | ||
|
||
telemetry: | ||
exporters: | ||
logging: | ||
stdout: | ||
format: text | ||
|
||
experimental_query_planner_mode: legacy | ||
|
||
plugins: | ||
experimental.expose_query_plan: true |
17 changes: 17 additions & 0 deletions
17
apollo-router/tests/samples/enterprise/progressive-override/basic/configuration2.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
include_subgraph_errors: | ||
all: true | ||
|
||
telemetry: | ||
exporters: | ||
logging: | ||
stdout: | ||
format: text | ||
|
||
experimental_query_planner_mode: legacy | ||
|
||
rhai: | ||
scripts: "tests/samples/enterprise/progressive-override/basic/rhai" | ||
main: "main.rhai" | ||
|
||
plugins: | ||
experimental.expose_query_plan: true |
226 changes: 226 additions & 0 deletions
226
apollo-router/tests/samples/enterprise/progressive-override/basic/plan.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,226 @@ | ||
{ | ||
"enterprise": true, | ||
"actions": [ | ||
{ | ||
"type": "Start", | ||
"schema_path": "./supergraph.graphql", | ||
"configuration_path": "./configuration.yaml", | ||
"subgraphs": { | ||
"Subgraph1": { | ||
"requests": [ | ||
{ | ||
"request": { | ||
"body": { | ||
"query": "query progressive1__Subgraph1__0{percent100{__typename id}}", | ||
"operationName": "progressive1__Subgraph1__0" | ||
} | ||
}, | ||
"response": { | ||
"body": { | ||
"data": { | ||
"percent100": { | ||
"__typename": "T", | ||
"id": "1" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"Subgraph2": { | ||
"requests": [ | ||
{ | ||
"request": { | ||
"body": { | ||
"query": "query progressive1__Subgraph2__1($representations:[_Any!]!){_entities(representations:$representations){...on T{foo}}}", | ||
"operationName": "progressive1__Subgraph2__1", | ||
"variables": { | ||
"representations": [ | ||
{ | ||
"__typename": "T", | ||
"id": "1" | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"response": { | ||
"body": { | ||
"data": { | ||
"_entities": [ | ||
{ | ||
"foo": 1 | ||
} | ||
] | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"request": { | ||
"body": { | ||
"query": "query progressive2__Subgraph2__0{percent0{foo}}", | ||
"operationName": "progressive2__Subgraph2__0" | ||
} | ||
}, | ||
"response": { | ||
"body": { | ||
"data": { | ||
"percent0": { | ||
"foo": 2 | ||
} | ||
} | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
{ | ||
"type": "Request", | ||
"request": { | ||
"query": "query progressive1 { percent100 { foo } }" | ||
}, | ||
"headers": { | ||
"apollo-expose-query-plan": "false" | ||
}, | ||
"expected_response": { | ||
"data": { | ||
"percent100": { | ||
"foo": 1 | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"type": "Request", | ||
"request": { | ||
"query": "query progressive2 { percent0 { foo } }" | ||
}, | ||
"expected_response": { | ||
"data": { | ||
"percent0": { | ||
"foo": 2 | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"type": "ReloadConfiguration", | ||
"configuration_path": "./configuration2.yaml" | ||
}, | ||
{ | ||
"type": "ReloadSubgraphs", | ||
"subgraphs": { | ||
"Subgraph1": { | ||
"requests": [ | ||
{ | ||
"request": { | ||
"body": { | ||
"query": "query progressive3__Subgraph1__0{percent100{__typename id}}", | ||
"operationName": "progressive3__Subgraph1__0" | ||
} | ||
}, | ||
"response": { | ||
"body": { | ||
"data": { | ||
"percent100": { | ||
"__typename": "T", | ||
"id": "1" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"request": { | ||
"body": { | ||
"query": "query progressive4__Subgraph1__0{percent100{bar}}", | ||
"operationName": "progressive4__Subgraph1__0" | ||
} | ||
}, | ||
"response": { | ||
"body": { | ||
"data": { | ||
"percent100": { | ||
"bar": 2 | ||
} | ||
} | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"Subgraph2": { | ||
"requests": [ | ||
{ | ||
"request": { | ||
"body": { | ||
"query": "query progressive3__Subgraph2__1($representations:[_Any!]!){_entities(representations:$representations){...on T{bar}}}", | ||
"operationName": "progressive3__Subgraph2__1", | ||
"variables": { | ||
"representations": [ | ||
{ | ||
"__typename": "T", | ||
"id": "1" | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"response": { | ||
"body": { | ||
"data": { | ||
"_entities": [ | ||
{ | ||
"bar": 1 | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
{ | ||
"type": "Request", | ||
"request": { | ||
"query": "query progressive3 { percent100 { bar } }" | ||
}, | ||
"headers": { | ||
"apollo-expose-query-plan": "false" | ||
}, | ||
"expected_response": { | ||
"data": { | ||
"percent100": { | ||
"bar": 1 | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"type": "Request", | ||
"request": { | ||
"query": "query progressive4 { percent100 { bar } }" | ||
}, | ||
"headers": { | ||
"apollo-expose-query-plan": "false", | ||
"x-override": "true" | ||
}, | ||
"expected_response": { | ||
"data": { | ||
"percent100": { | ||
"bar": 2 | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"type": "Stop" | ||
} | ||
] | ||
} |
22 changes: 22 additions & 0 deletions
22
apollo-router/tests/samples/enterprise/progressive-override/basic/rhai/main.rhai
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
fn supergraph_service(service) { | ||
const request_callback = Fn("process_request"); | ||
service.map_request(request_callback); | ||
} | ||
|
||
// Add a timestamp to context which we'll use in the response. | ||
fn process_request(request) { | ||
request.context["request_start"] = Router.APOLLO_START.elapsed; | ||
let labels = request.context["apollo_override::unresolved_labels"]; | ||
print(`unresolved: ${labels}`); | ||
|
||
let override = request.context["apollo_override::labels_to_override"]; | ||
print(`override: ${override}`); | ||
|
||
|
||
if "x-override" in request.headers { | ||
if request.headers["x-override"] == "true" { | ||
request.context["apollo_override::labels_to_override"] += "bar"; | ||
} | ||
} | ||
} | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
can we remove this now?
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.
Yes. We can also leave it and just change it to
2
next time we need it. lol. (I do usually remove it.) I might just leave it for now.