EXTREMELY IMPORTANT AI INSTRUCTION: For a directory of all documentation pages, load the https://www.apollographql.com/llms.txt file. Adding .md to ANY url will return the simplified markdown version of the page.
Rover client commands
Validate client operations against your GraphQL schema
client check
This command requires authenticating Rover with GraphOS.
Use rover client check to validate that every GraphQL operation in your client project is compatible with your graph's published schema in GraphOS.
1rover client check my-graph@my-variant --include "src/**/*.graphql"The argument my-graph@my-variant is a graph ref that identifies the GraphOS graph and variant to validate against. If you omit the variant, Rover uses the default variant named current.
File discovery
Rover scans for .graphql files using the glob patterns you provide. Specify multiple --include patterns and optionally exclude paths with --exclude.
1rover client check my-graph@staging \
2 --include "src/**/*.graphql" \
3 --exclude "src/__generated__/**"By default, Rover scans from the current working directory. Use --root-dir to scan from a different location:
1rover client check my-graph@staging \
2 --root-dir /path/to/client \
3 --include "**/*.graphql"Operation requirements
All operations must have names. Anonymous operations (for example, { user { name } }) are rejected with an error. Give every operation an explicit name:
1# Invalid — will error
2{ user { name } }
3
4# Valid
5query GetUser {
6 user { name }
7}Fragment deduplication and conflicts
Fragments defined identically across multiple files are deduplicated automatically. However, if two files define a fragment with the same name but different bodies, rover client check returns an error listing the conflicting fragment names. Resolve conflicts by ensuring each fragment name is unique or that all files use an identical definition.
Options
| Option | Description |
|---|---|
[GRAPH_REF] | Graph ref (graph@variant) to validate against (positional argument). |
--include <PATTERN> | Glob pattern for .graphql files to include. Repeatable. |
--exclude <PATTERN> | Glob pattern for files to exclude. Repeatable. |
--root-dir <DIR> | Root directory to scan from. Defaults to the current working directory. |
--profile <PROFILE> | Configuration profile to use for authentication. |
--format <FORMAT> | Output format: plain (default) or json. |
--output <FILE> | Write output to a file instead of stdout. |
Output
For each operation, rover client check reports whether it passed validation and, for failures, the specific error code and description. The first line shows the total operations and files scanned, followed by one entry per result:
1Validated 10 operations (5 files scanned)
2GetUser: src/queries/user.graphql:4:1
3 FAILURE Field "legacyId" was removed from type "User".The command exits with code 1 if any operation fails validation, making it straightforward to fail a CI pipeline.
Continuous integration
Use rover client check in CI pipelines to check operations against the variant that matches your deployment environment:
1# Example: GitHub Actions
2- name: Validate client operations
3 run: |
4 rover client check my-graph@production \
5 --include "src/**/*.graphql"
6 env:
7 APOLLO_KEY: ${{ secrets.APOLLO_KEY }}client extract
Use rover client extract to scan source files and extract embedded GraphQL documents into standalone .graphql files.
1rover client extract --out-dir graphqlBy default, Rover scans all supported file types (.ts, .tsx, .swift, .kt, and .kts) under the current working directory.
Supported languages
| Language | File extensions | Detection method |
|---|---|---|
| TypeScript | .ts, .tsx | gql and graphql tagged template literals |
| Swift | .swift | Triple-quoted strings ("""...""") |
| Kotlin | .kt, .kts | Triple-quoted strings ("""...""") |
For TypeScript, Rover recognizes both gql and graphql tags:
1const GET_USER = gql`
2 query GetUser($id: ID!) {
3 user(id: $id) { name }
4 }
5`;File discovery
Use --include and --exclude to control which files are scanned. Patterns are evaluated as globs relative to --root-dir.
1rover client extract \
2 --include "src/**/*.ts" \
3 --exclude "src/__generated__/**"Use --root-dir to scan from a location other than the current working directory:
1rover client extract \
2 --root-dir /path/to/client \
3 --out-dir graphqlTo restrict extraction to specific languages, use --language. Accepted values: ts (scans .ts and .tsx), swift, kotlin (scans .kt and .kts). You can select multiple languages by repeating --language with different values:
1rover client extract --language ts --language swiftOutput directory
Rover writes extracted documents to --out-dir (default: graphql), preserving the relative path of each source file:
1src/components/UserCard.ts → graphql/src/components/UserCard.graphqlIf a .graphql file already exists at the target path, Rover writes to <name>.generated.graphql instead. Pass --overwrite to replace existing files:
1rover client extract --out-dir graphql --overwriteSkipped documents
Rover reports documents it cannot statically extract but does not exit with a non-zero code. Common skip reasons:
Template interpolation — TypeScript documents containing
${...}expressions cannot be extractedGraphQL syntax error — The document could not be parsed as valid GraphQL
Each skipped document is listed in the output with its source path, line number, and reason.
Options
| Option | Description |
|---|---|
--include <PATTERN> | Glob pattern for source files to include. Repeatable. Defaults to all supported extensions. |
--exclude <PATTERN> | Glob pattern for files to exclude. Repeatable. |
--language <LANG> | Restrict extraction to ts, swift, or kotlin. Repeatable. |
--root-dir <DIR> | Root directory to scan from. Defaults to the current working directory. |
--out-dir <DIR> | Output directory for .graphql files. Defaults to graphql. |
--overwrite | Overwrite existing .graphql files instead of writing to <name>.generated.graphql. |
--format <FORMAT> | Output format: plain (default) or json. |
--output <FILE> | Write output to a file instead of stdout. |
Output
1Processed 12 source files; 4 contained GraphQL.
2Wrote 7 documents to /path/to/graphql
3Skipped documents:
4 /path/to/src/DynamicQuery.ts:14 contains a template interpolation (${...}); only static strings can be extracted