REG-1909 Subgraph Preview 3a - #3624
Conversation
✅ Docs preview has no changesThe preview was not built because there were no changes. Build ID: 671f048e7666ccf6ebf68b65 ✅ AI Style Review — No Changes DetectedNo MDX files were changed in this pull request. Review Log: View detailed log
|
rover subgraph preview, swap subgraph delete to use ita5067a9 to
d4fb6b8
Compare
d4fb6b8 to
a5881f4
Compare
a5881f4 to
18ba829
Compare
18ba829 to
c8a325a
Compare
c8a325a to
fd0b6e7
Compare
fd0b6e7 to
e843a5e
Compare
e843a5e to
2cb886a
Compare
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
2cb886a to
928ea2f
Compare
928ea2f to
13e23cf
Compare
13e23cf to
397b031
Compare
5a6e02c to
6dcde67
Compare
6dcde67 to
d9244c3
Compare
d9244c3 to
7da166c
Compare
|
|
||
| /// Preview the composition impact of deleting a subgraph, via the same async | ||
| /// `composeAndFilterPreviewAsync` build `rover subgraph preview` uses. | ||
| pub async fn check( |
There was a problem hiding this comment.
I think this could be updated similarly to #3623 (comment)
|
|
||
| use super::*; | ||
|
|
||
| fn test_client(server_url: &str) -> StudioClient { |
There was a problem hiding this comment.
If we make the service changes mentioned above, we could probably get rid of this and utilize a mock_service to validate HTTP behavior directly -- then we could skip all of the unrelated StudioClient setup materials, timeouts, etc. and focus strictly on the business logic
| ) | ||
| } | ||
|
|
||
| fn test_input() -> SubgraphDeleteInput { |
There was a problem hiding this comment.
We could make this into an rstest fixture.
| .await | ||
| .unwrap(); | ||
|
|
||
| assert_eq!( |
There was a problem hiding this comment.
If we use speculoos for assertions, we can get assertions around Result types rather than unwrapping (like above).
This could change to assert_that!(response).is_ok().is_equal_to(...)
| let text = temp_env::with_var("NO_COLOR", Some("1"), || { | ||
| SubgraphPreviewOutput(response(AsyncBuildStatus::Pending)).text() | ||
| }); | ||
| assert!(text.contains("rover subgraph preview my-graph@current --build-id build-123")); |
There was a problem hiding this comment.
Can we make sure that tests are asserting on full contents for correctness? We can use indoc for better multiline tests, or write e2e tests that use snapshot assertions over text and json outputs.
| let json = SubgraphPreviewOutput(response(AsyncBuildStatus::Success)) | ||
| .json() | ||
| .unwrap(); | ||
| assert_eq!(json["build_id"], "build-123"); |
There was a problem hiding this comment.
Similar note here about asserting on the full json output.
926f36c to
1b08e24
Compare
Adds `rover subgraph preview`: composes a preview supergraph from hypothetical subgraph changes (add/update/remove, via --subgraph-changes) with optional contract filters, without publishing anything. Same async/--build-id/poll UX as `rover contract preview`. Also swaps `rover subgraph delete`'s pre-confirmation build-error check from a synchronous removeImplementingServiceAndTriggerComposition(dryRun: true) call to the new async compose-and-filter-preview path (delete::check). Holding that dry-run mutation open for the duration of composition blocked the server connection and risked timing out on large supergraphs -- the same reason this whole feature is async. Bundled with this PR rather than the subgraph-impl PR because it's a breaking change to the existing SubgraphDeleteInput/runner shape that only this PR's CLI change consumes; splitting it further would leave an intermediate commit that doesn't build. Also brings the command's print calls up to date with the simplified rover-print Print::print signature that landed on main after this branch was first written.
Follows the rover-client change making start()/result() generic over an injected Service: build the default service via the new compose_and_filter_preview_start_service/-result_service constructors before calling them.
- subgraph::delete::check now takes an injected Service (matching the start/result refactor), with a new compose_and_filter_preview_run_service default constructor wrapping preview::run via tower::service_fn. - check's tests use a rover_tower mock_service instead of MockServer, test_input converted to an rstest fixture, and assertions switched to speculoos's assert_that! over Result rather than unwrap + assert_eq!. - SubgraphPreviewOutput's text/json tests now assert on full contents (indoc for the multiline text case, a complete json! value) instead of substring/partial-field checks.
text_for_success_includes_the_schema and text_for_failure_includes_the_errors still used assert!(text.contains(...)) after the earlier pass only fixed the two explicitly-flagged tests in this file. Switched to full-value equality, matching the equivalent (already-tight) tests on the contract side.
1b08e24 to
be1ef5d
Compare
REG-1909 Subgraph Preview 3a
CLI-consumer PR (stacked on REG-1909 Subgraph Preview 2a) wiring up
rover subgraph preview, and swappingrover subgraph delete's pre-confirmation check to use it.rover subgraph previewcomposes a preview supergraph from hypothetical subgraph changes described by a--subgraph-changesYAML file (add/update a subgraph's schema or routing URL, or mark oneremove: true), with optional contract filters, without publishing anything. Same async/--build-id/poll UX and non-zero exit-on-failure asrover contract preview(REG-1909 Contract Preview 3b).rover subgraph delete's pre-confirmation build-error check now runs through this same async preview path (delete::check) instead of a synchronousremoveImplementingServiceAndTriggerComposition(dryRun: true)call. Holding that dry-run mutation open for the duration of composition blocked the server connection and risked timing out on large supergraphs — the same reason this whole feature is async.crates/rover-client/src/operations/subgraph/delete/*(a breaking change to the existingSubgraphDeleteInput/runner shape) as well as the CLI. It's bundled into this PR rather than the crate-impl PR (REG-1909 Subgraph Preview 2a) because splitting it further would leave an intermediate commit in the stack that doesn't build (theroverbinary crate's existingsubgraph deletecommand depends on the old shape until this PR's CLI change lands).SubgraphPreviewOutput: CliOutputstruct (src/command/subgraph/preview/output.rs) rather than a newRoverOutputvariant, per AGENTS.md.Also brings this command's print calls up to date with the simplified
rover-printPrint::printsignature that landed onmainafter this branch was first written.[ ] A CHANGELOG.md entry is not needed for this PR