A Github Action that downloads your GraphQL schema from introspection and/or the Studio registry and opens a pull request if anything changed.
This action supports converting an introspection schema to SDL and vice-versa based on the file extension. We recommend using .graphqls
to convert to SDL.
Allow Workflows to write to your repository and create pull requests:
name: Update GraphQL schema
# Check every night at midnight
on:
schedule:
- cron: "0 0 * * *"
jobs:
update:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: apollographql/update-graphql-schema@main
with:
endpoint: "https://example.com/graphql"
schema: "src/main/graphql/schema.graphqls"
# Optional HTTP settings for the download
headers: '{"Authorization": "Bearer $token", "User-Agent": "MyAction"}' # default: ""
insecure: "false" # default: "false"
# Optional pull request settings
branch: "graphql-schema" # default: "update-schema"
remote: "origin" # default: "origin"
token: "abc123" # Default: GITHUB_TOKEN
# Optional commit settings
commit_user_name: My GitHub Actions Bot # defaults to "github-actions[bot]"
commit_user_email: [email protected] # defaults to "github-actions[bot]@users.noreply.github.com"
commit_author: Author <[email protected]> # defaults to author of the commit that triggered the run
commit_message: Automated Commit # defaults to "Update GraphQL Schema"
Configuring with the Studio registry
name: Update GraphQL schema
on:
schedule:
- cron: "0 0 * * *"
jobs:
update:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: apollographql/update-graphql-schema@main
with:
key: "service:fullstack-tutorial:abc123"
schema: "src/main/graphql/schema.graphqls"
# Optional Studio registry settings
graph: "fullstack-tutorial" # defaults to being parsed from the key
graph_variant: "production" # default: "current"
# Other optional settings are the same as for introspection