Sync GraphQL schema changes from CI

We recommend setting up a CI task to push the GraphQL schema to GraphCDN on every commit to your main/master/trunk/production branch. While this isn't required, it ensures your GraphCDN service always knows the up-to-date schema.

  1. Pull your service's latest graphcdn.yml configuration file your service with the graphcdn pull command. Specify the --service argument set to your service's name, for example:

    npx graphcdn pull --service todo-app

    Commit your service's graphcdn.yml file to your repository.

  2. Create a Personal Access Token for your account at https://graphcdn.io/dashboard/settings. Call it something like "CI"

  3. Set the GRAPHCDN_TOKEN environment variable in your CI service to your personal access token

  4. Add a task to your CI service for your production branch, which runs npx graphcdn push schema. This command will push your GraphQL schema changes to GraphCDN.

Below are specific CI provider configurations. If your CI provider is not in this list contact us at support@graphcdn.io, we'd be happy to help you configure it correctly!

CircleCI

If you are using CircleCI, you need to add a new job that runs the "npx graphcdn push command" and execute that job from your main workflow after you have finished testing/etc. Something like this:

jobs:
graphcdn:
docker:
- image: cimg/node:16.3.0
steps:
- checkout
- run: npx graphcdn push schema
workflows:
'My main workflow':
jobs:
# ...other jobs here...
- graphcdn

GitHub Actions

To do this from GitHub Actions, add a file named .github/workflows/graphcdn.yml with the following contents:

name: GraphCDN
on:
push:
branches:
- main
- master
- trunk
jobs:
main:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '14'
check-latest: true
- name: Push schema
run: npx graphcdn push schema
env:
GRAPHCDN_TOKEN: ${{ secrets.GRAPHCDN_TOKEN }}