A GitHub Action to run a schema check using the Apollo CLI and Apollo Studio (formerly Graph Manager) and post the results as a comment on a Pull Request
Create a file in your repo named .github/workflows/schema-check.yml
with the following contents:
name: Schema Check on: pull_request: types: [opened, reopened, synchronize] jobs: check_schema: name: check schema runs-on: ubuntu-latest timeout-minutes: 5 steps: - uses: actions/checkout@v2 - name: Customer API check uses: iansu/apollo-schema-check-action@v2 with: title: Customer API graph: my-customer-api variant: production localSchemaFile: 'schema.graphql' serviceName: my-service validationPeriod: P2W key: ${{ secrets.APOLLO_KEY }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
When you create a new PR that includes schema changes the results of the schema check will be posted as a comment. Here's an example of what that looks like:
Note that you won't see a comment if your PR doesn't include any schema changes. You can change this behaviour by setting alwaysComment: true
.
If you provide the path to an Apollo config file in your project any applicable settings from there will be used. If a setting is specified in the Apollo config file and in the workflow settings, the workflow setting will take precedence.
You must provide either an endpoint
to introspect your schema or the path to one or more localSchemaFile
s.
endpoint
input is REQUIRED if using the headers
input. No key The API key to use for authentication to Apollo Graph Manager Yes localSchemaFile Path to one or more local GraphQL SDL file(s). Supports comma-separated list of paths (ex. schema.graphql,extensions.graphql
) No queryCountThreshold Minimum number of requests within the requested time window for a query to be considered No queryCountThresholdPercentage Number of requests within the requested time window for a query to be considered, relative to total request count. Expected values are between 0 and 0.05 (minimum 5% of total request volume) No serviceName Provides the name of the implementing service for a federated graph. This flag will indicate that the schema is a partial schema from a federated service No title The name of the graph which will be shown in the comment No validationPeriod The size of the time window with which to validate the schema against. You may provide a number (in seconds), or an ISO8601 format duration for more granularity (see: ISO 8601 Durations Yes variant The variant to check the proposed schema against No Why use this instead of the Apollo GitHub App
This Action offers some features that the Apollo GitHub App doesn't. If you don't need these features then you should consider using it instead. The main differences are:
To publish a release use the Release workflow. When you run the workflow it will ask you for a version tag like v2.0.0
. This should be the full version number of the new release. It will also ask you for a major version number like v2
. This allows you to reference the release as either @v2
of @v2.0.0
. You can also reference the hash of the release for additional security.
After the workflow runs a draft release will be created on GitHub. Edit the release and copy the CHANGELOG entries into the description. Then publish the release, including publishing to the GitHub Marketplace.
Creating a preview ReleaseTo create a preview release use the Release Next workflow. When you run the workflow it will ask you for the name of the branch to build. This should be the feature branch that you want to test. The release will be published to the next
branch and you can use iansu/apollo-schema-check-action@next
in your workflows to test the preview release.
Made with 🥃 by Ian Sutherland (@iansu). This project is released under the MIT license.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4