Docs
Launch GraphOS Studio

Validating client operations

Confirm that all client operations are supported by your schema


You can confirm that all of the GraphQL s defined in your client application are valid against the types, s, and s in your graph's published schema. To do so, you use the apollo client:check command of the Apollo CLI:

$ apollo client:check
✔ Loading Apollo Project
✔ Checking client compatibility with service
GetTeamGrid: src/components/TeamGrid.jsx:4
FAILURE Field "league" must not have a selection since type "SportsLeague" has no subfields.
4 total operations validated
1 failure

You run this command from your client application's root. It recursively scans your project for the following:

  • GraphQL s wrapped in the gql tag
  • Client-side schema extensions wrapped in the gql tag

By combining your registered graph's with your client-side extensions, the apollo client:check command can confirm whether the shape of each defined conforms to the shape of your combined .

Make sure that your project provides a graph API key to the Apollo CLI. This both authenticates the CLI with Studio and specifies which graph's you're checking against.

Checking against a particular variant

During development, your application might be executing GraphQL s against a locally running server with a that differs somewhat from your production server's . Because s can differ, it's important to always check your s against the current for a particular environment before you push client changes to that environment.

If you represent each of your server's environments with a separate graph variant (recommended), you can check your s against a particular 's like so:

$ apollo client:check --variant=production

Using with continuous integration

Your application can incorporate client:check into its continuous delivery pipeline to help ensure that new and modified s are valid before they go live.

Here's a Circle CI configuration excerpt that incorporates the command:

config.yml
version: 2
jobs:
# ...other jobs...
# Define a separate job for each environment you validate against.
check_against_staging:
docker:
- image: circleci/node:12
steps:
- checkout
- run: npm install
# CircleCI needs global installs to be sudo
- run: sudo npm install --global apollo
# This command authenticates using the `APOLLO_KEY` environment variable.
# Don't forget to provide your API key in it.
- run: npx apollo client:check --variant=staging
Previous
Connecting to GitHub
Next
Launches
Edit on GitHubEditForumsDiscord