Docs
Launch GraphOS Studio

Rover contract commands

For use with GraphOS contract variants


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

Contract variant A
Contract variant B
Source variant
Filter schema
according to contract A
Filter schema
according to contract B
Contract schema A
Contract schema B
Supergraph
schema

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

Publishing a contract to GraphOS

contract publish

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

Run the contract publish command, like so:

rover contract publish my-graph@my-contract-variant \
--source-variant my-source-variant \
--include-tag foo \
--include-tag bar \
--exclude-tag baz \
--hide-unreachable-types

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

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

Options include:

NameDescription
--source-variant

The name of the source variant to use for filtering.

The must belong to the same graph as the contract variant. It must also be a federated variant with . If your graph uses Federation 1, you must enable its support for the @tag in Apollo Studio.

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:

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

One of --include-tag or --no-include-tags is required.

--no-include-tags

Specifies an empty include list for the published contract.

One of --include-tag or --no-include-tags is required.

--exclude-tag

A tag name to exclude when filtering. To exclude multiple tag names, specify --exclude-tag multiple times:

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

One of --exclude-tag or --no-exclude-tags is required.

--no-exclude-tags

Specifies an empty exclude list for the published contract.

One of --exclude-tag or --no-exclude-tags is required.

--hide-unreachable-types

If provided, the contract automatically hides types that are unreachable from the contract schema's root .

One of --hide-unreachable-types or --no-hide-unreachable-types is required.

--no-hide-unreachable-types

If provided, the contract does not automatically hide types that are unreachable from the contract schema's root fields.

One of --hide-unreachable-types or --no-hide-unreachable-types is required.

--no-launch

Optional. If provided, this command does not trigger a launch in GraphOS after updating the contract configuration.

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:

rover 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:

Fetching description for configuration of my-graph@my-contract-variant using credentials from the default profile.
Configuration Description:
Contract variant "my-graph@my-contract-variant" is derived from the source variant "my-graph@my-source-variant".
Included tags:
- "foo"
- "bar"
Excluded tags:
- "baz"
Unreachable types are automatically hidden.
View the variant's full configuration at https://studio.apollographql.com/graph/my-graph/settings/variant?variant=my-contract-variant
Previous
config
Next
dev
Edit on GitHubEditForumsDiscord

© 2024 Apollo Graph Inc.

Privacy Policy

Company