PR based workflow for Federation

Let us go over how to use the subgraph check command in CI to prevent breaking changes in production. Use our GitHub app to seamlessly approve breaking changes in the Cosmo Studio.

Usage in CI

You can run wgc subgraph check on pull requests to validate changes to your subgraphs. The CLI is aware of the environment in which it runs. Here is an example using GitHub actions:

name: Check Subgraph

on:
  pull_request:
    branches:
      - main

jobs:
  check-subgraphs:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - name: Setup Node.js
        uses: actions/setup-node@v3
        with:
          node-version: "lts/*"

      - name: Install Cosmo CLI
        run: |
          npm install -g wgc@latest

      - name: Run subgraph check
        run: |
          wgc subgraph check employees --schema ./employees.graphqls
          # Add more check commands here for more subgraphs
        env:
          COSMO_API_KEY: ${{ secrets.COSMO_API_KEY }}

GitHub App Integration

By installing the Cosmo GitHub App onto your repositories, we can apply status checks to commits in your pull request.

The check fails if composition errors or breaking changes are detected. In the case of only breaking changes, you can override the status of the check in the Studio.

Please ensure your branch is protected; otherwise, a developer can still merge a PR with a failing check.

Video Tutorial

Below is a complete video demo. (Assuming you have CI setup similar to the yaml provided above).

Last updated