Skip to content

REG-1909 Subgraph Preview 3a - #3624

Open
sirdodger wants to merge 4 commits into
clee/preview-subgraph-implfrom
clee/preview-subgraph-cli
Open

REG-1909 Subgraph Preview 3a#3624
sirdodger wants to merge 4 commits into
clee/preview-subgraph-implfrom
clee/preview-subgraph-cli

Conversation

@sirdodger

@sirdodger sirdodger commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

REG-1909 Subgraph Preview 3a

CLI-consumer PR (stacked on REG-1909 Subgraph Preview 2a) wiring up rover subgraph preview, and swapping rover subgraph delete's pre-confirmation check to use it.

  • rover subgraph preview composes a preview supergraph from hypothetical subgraph changes described by a --subgraph-changes YAML file (add/update a subgraph's schema or routing URL, or mark one remove: true), with optional contract filters, without publishing anything. Same async/--build-id/poll UX and non-zero exit-on-failure as rover 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 synchronous removeImplementingServiceAndTriggerComposition(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.
    • This swap touches crates/rover-client/src/operations/subgraph/delete/* (a breaking change to the existing SubgraphDeleteInput/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 (the rover binary crate's existing subgraph delete command depends on the old shape until this PR's CLI change lands).
  • Output rendering goes through a dedicated SubgraphPreviewOutput: CliOutput struct (src/command/subgraph/preview/output.rs) rather than a new RoverOutput variant, per AGENTS.md.

Also brings this 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.

[ ] A CHANGELOG.md entry is not needed for this PR

@sirdodger
sirdodger requested a review from a team as a code owner August 20, 2026 19:23
@apollo-librarian

apollo-librarian Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

✅ Docs preview has no changes

The preview was not built because there were no changes.

Build ID: 671f048e7666ccf6ebf68b65
Build Logs: View logs


✅ AI Style Review — No Changes Detected

No MDX files were changed in this pull request.

Review Log: View detailed log

This review is AI-generated. Please use common sense when accepting these suggestions, as they may not always be accurate or appropriate for your specific context.

@sirdodger sirdodger changed the title Wire up rover subgraph preview, swap subgraph delete to use it REG-1909 Subgraph Preview 3a Aug 20, 2026
@sirdodger
sirdodger force-pushed the clee/preview-subgraph-cli branch from a5067a9 to d4fb6b8 Compare August 20, 2026 20:36
@sirdodger
sirdodger force-pushed the clee/preview-subgraph-cli branch from d4fb6b8 to a5881f4 Compare August 21, 2026 19:50
@sirdodger
sirdodger force-pushed the clee/preview-subgraph-cli branch from a5881f4 to 18ba829 Compare August 24, 2026 18:36
@sirdodger
sirdodger force-pushed the clee/preview-subgraph-cli branch from 18ba829 to c8a325a Compare August 24, 2026 19:54
@sirdodger
sirdodger force-pushed the clee/preview-subgraph-cli branch from c8a325a to fd0b6e7 Compare August 24, 2026 22:32
@sirdodger
sirdodger force-pushed the clee/preview-subgraph-cli branch from fd0b6e7 to e843a5e Compare August 25, 2026 05:38
@sirdodger
sirdodger force-pushed the clee/preview-subgraph-cli branch from e843a5e to 2cb886a Compare August 25, 2026 07:20
@claude

claude Bot commented Aug 25, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@sirdodger
sirdodger force-pushed the clee/preview-subgraph-cli branch from 2cb886a to 928ea2f Compare August 25, 2026 19:44
@sirdodger
sirdodger force-pushed the clee/preview-subgraph-cli branch from 928ea2f to 13e23cf Compare August 25, 2026 21:47
@sirdodger
sirdodger force-pushed the clee/preview-subgraph-cli branch from 13e23cf to 397b031 Compare August 26, 2026 16:41
@sirdodger
sirdodger force-pushed the clee/preview-subgraph-cli branch 2 times, most recently from 5a6e02c to 6dcde67 Compare August 26, 2026 18:23
@sirdodger
sirdodger force-pushed the clee/preview-subgraph-cli branch from 6dcde67 to d9244c3 Compare August 26, 2026 19:35
@sirdodger
sirdodger force-pushed the clee/preview-subgraph-cli branch from d9244c3 to 7da166c Compare August 27, 2026 20:20

/// Preview the composition impact of deleting a subgraph, via the same async
/// `composeAndFilterPreviewAsync` build `rover subgraph preview` uses.
pub async fn check(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could be updated similarly to #3623 (comment)


use super::*;

fn test_client(server_url: &str) -> StudioClient {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could make this into an rstest fixture.

.await
.unwrap();

assert_eq!(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(...)

Comment thread src/command/subgraph/preview/output.rs Outdated
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"));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/command/subgraph/preview/output.rs Outdated
let json = SubgraphPreviewOutput(response(AsyncBuildStatus::Success))
.json()
.unwrap();
assert_eq!(json["build_id"], "build-123");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar note here about asserting on the full json output.

@sirdodger
sirdodger force-pushed the clee/preview-subgraph-cli branch 2 times, most recently from 926f36c to 1b08e24 Compare September 1, 2026 01:45
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.
@sirdodger
sirdodger force-pushed the clee/preview-subgraph-cli branch from 1b08e24 to be1ef5d Compare September 1, 2026 03:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants