Rover contract Commands

For use with GraphOS contract variants


GraphOS contracts enable you to create variants of a supergraph that filter out schema elements according to inclusion and exclusion rules:

The rover contract command set enables you to interact with your existing contracts and create new ones.

Publishing a contract to GraphOS

contract publish

This command requires authenticating Rover with GraphOS.

You can use Rover to publish a new contract or publish configuration changes to an existing contract.

Run the contract publish command, like so:

Bash
1rover contract publish my-graph@my-contract-variant \
2  --source-variant my-source-variant \
3  --include-tag foo \
4  --include-tag bar \
5  --exclude-tag baz \
6  --hide-unreachable-types

The argument my-graph@my-contract-variant in the example above is a graph ref that specifies the ID of the graph you're publishing to, along with which contract variant you're creating or modifying.

If this contract variant already exists in the graph registry, its configuration is updated. Otherwise, a new contract variant is created.

Options include:

Name Description
--source-variant
The name of the source variant to use for supergraph schema filtering.The source variant must belong to the same graph as the contract variant and must be a federated variant with subgraphs.Required the first time you publish a contract.Optional after your first publish. If provided, it must match the value provided for the first publish (the source variant for a particular contract variant can't change).
--include-tag
A tag name to include when filtering. To include multiple tag names, specify --include-tag multiple times. For details, see the contract filters documentation.
Bash
1--include-tag foo --include-tag bar
To specify an empty include list, provide--no-include-tags instead of this option.Every tag name must:
  • Begin with a letter (capital or lowercase) or underscore.
  • Include only letters, numbers, underscores (_), hyphens (-), or slashes (/).
  • Have a maximum of 128 characters.
Specify either --include-tag or --no-include-tags.
--no-include-tags
Specifies an empty include list for the published contract.Provide either --include-tag or --no-include-tags.
--exclude-tag
Provide a tag name to exclude when filtering. To exclude multiple tag names, specify --exclude-tag multiple times. For details, see the contract filters documentation.
Text
1--exclude-tag foo --exclude-tag bar
To specify an empty exclude list, provide--no-exclude-tags instead of this option.Every tag name must:
  • Begin with a letter (capital or lowercase) or underscore.
  • Include only letters, numbers, underscores (_), hyphens (-), or slashes (/).
  • Have a maximum of 128 characters.
Specify either --exclude-tag or --no-exclude-tags.
--no-exclude-tags
Specifies an empty exclude list for the published contract.Provide either --exclude-tag or --no-exclude-tags.
--hide-unreachable-types
If provided, the contract automatically hides types that are unreachable from the contract schema's root fields.Specify either --hide-unreachable-types or --no-hide-unreachable-types.
--no-hide-unreachable-types
If provided, the contract doesn't automatically hide types that are unreachable from the contract schema's root fields.Provide either --hide-unreachable-types or --no-hide-unreachable-types.
--no-launch
Optional. If provided, this command does not trigger a launch in GraphOS after updating the contract configuration.

Previewing a contract

contract preview

This command requires authenticating Rover with GraphOS.

Before you publish a contract to GraphOS, preview the contract schema that your filter produces, without publishing a contract variant.

Use the contract preview command to view the resulting schema:

Bash
1rover contract preview my-graph@my-source-variant \
2  --include-tag foo \
3  --include-tag bar \
4  --exclude-tag baz \
5  --hide-unreachable-types

The argument my-graph@my-source-variant in the preceding example is a graph ref that specifies the ID of the graph and the source variant whose already-composed supergraph schema you want to filter.

Preview builds run asynchronously on GraphOS. By default, Rover starts the build and polls its status until it completes, then prints the resulting schema. See Running previews asynchronously below to instead return immediately with a build ID and check the result later.

The command supports the following options:

Name Description
--include-tag
A tag name to include in contract filters when filtering. To include multiple tag names, specify --include-tag multiple times:
Bash
1--include-tag foo --include-tag bar
Use --no-include-tags to specify an empty include list.One of --include-tag or --no-include-tags is required when starting a new preview build (not used with --build-id).
--no-include-tags
Specify an empty include list for the previewed contract.Starting a new preview build requires one of --include-tag or --no-include-tags (not used with --build-id).
--exclude-tag
A tag name to exclude when filtering. For details, see the contract filters documentation. To exclude multiple tag names, specify --exclude-tag multiple times:
Bash
1--exclude-tag foo --exclude-tag bar
To specify an empty exclude list, use --no-exclude-tags.One of --exclude-tag or --no-exclude-tags is required when starting a new preview build (not used with --build-id).
--no-exclude-tags
Use this to specify an empty contract filter list for your previewed contract.Starting a new preview build requires one of --exclude-tag or --no-exclude-tags (not used with --build-id).
--hide-unreachable-types
If provided, the preview automatically hides types that are unreachable from your contract schema's root fields. For details, see the contract filters documentation.Provide either --hide-unreachable-types or --no-hide-unreachable-types when you start a new preview build (not used with --build-id).
--no-hide-unreachable-types
If provided, the preview doesn't automatically hide types that are unreachable from your contract schema's root fields.Provide either --hide-unreachable-types or --no-hide-unreachable-types when you start a new preview build (not used with --build-id).
--async
Optional. If provided, Rover starts the preview build and immediately returns with a build ID, instead of waiting for it to complete. Use --build-id to check the build's status later.
--build-id
Optional. Use this to check the status of a previously started preview build. You can't combine this with --async or the include/exclude/hide-unreachable-types options preceding.

Running previews asynchronously

For long-running preview builds, use the --async flag to start the build and return a build ID immediately.

Bash
1rover contract preview my-graph@my-source-variant \
2  --include-tag foo --no-exclude-tags --hide-unreachable-types --async

Use --build-id to check the status of the build later:

Bash
1rover contract preview my-graph@my-source-variant --build-id <BUILD_ID>

By default (without --async), Rover CLI polls your build's status until it completes or APOLLO_CHECKS_TIMEOUT_SECONDS elapses, whichever comes first. If Rover CLI times out while polling, your build may still complete in the background. Use --build-id to check its status again.

Fetching contract details

contract describe

This command requires authenticating Rover with GraphOS.

You can use Rover to fetch the configuration of any contract variant that Rover has access to.

Run the contract describe command, like so:

Bash
1rover contract describe my-graph@my-contract-variant

The argument my-graph@my-contract-variant in the example above is a graph ref that specifies the ID of the GraphOS graph you're fetching from, along with which contract variant you're fetching.

This command prints a summary of the contract's configuration, including its source variant and include/exclude lists:

Text
1Fetching description for configuration of my-graph@my-contract-variant using credentials from the default profile.
2
3Configuration Description:
4
5Contract variant "my-graph@my-contract-variant" is derived from the source variant "my-graph@my-source-variant".
6
7Included tags:
8
9- "foo"
10- "bar"
11
12Excluded tags:
13
14- "baz"
15
16Unreachable types are automatically hidden.
17
18View the variant's full configuration at https://studio.apollographql.com/graph/my-graph/settings/variant?variant=my-contract-variant