A GitHub Action that creates or updates an Apollo GraphOS schema proposal each time a pull request is opened or pushed to in a subgraph repository, and posts the proposal link back as a PR comment.
Note
Experimental reference implementation from Apollo Solutions. Not officially supported. See the official GraphOS docs for the supported workflow.
On every pull_request event (opened, synchronize, reopened):
- Reads the proposed subgraph schema file from the PR branch.
- Looks up an existing proposal whose display name matches the branch (so re-pushes update the same proposal).
- Creates a new proposal, or publishes a new revision to the existing one.
- Posts a sticky comment on the PR with the proposal URL and current status.
Add a workflow to your subgraph repo (see examples/):
# .github/workflows/proposal.yml
name: Schema Proposal
on:
pull_request:
paths:
- "schema/**.graphql"
- "schema/**.graphqls"
permissions:
contents: read
pull-requests: write
jobs:
proposal:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: apollosolutions/proposal-pr-bot@v1
with:
graph-ref: my-graph@main
subgraph-name: products
schema-file: schema/products.graphql
env:
APOLLO_KEY: ${{ secrets.APOLLO_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}| Name | Required | Description |
|---|---|---|
graph-ref |
yes | GraphOS graph ref to propose against (e.g. my-graph@main). |
subgraph-name |
yes | Name of the subgraph the schema file represents. |
schema-file |
yes | Path to the subgraph SDL file in the PR branch. |
proposal-name |
no | Display name override. Defaults to pr-<number>: <pr title>. |
summary |
no | Proposal summary. Defaults to the PR body (truncated to 2000 chars). |
api-endpoint |
no | Apollo Platform API endpoint. Defaults to studio. |
comment-marker |
no | Hidden marker used to dedupe the PR comment. Defaults to a constant. |
| Name | Required | Description |
|---|---|---|
APOLLO_KEY |
yes | A graph API key with consumer or contributor access to the proposals API. Pass via env: APOLLO_KEY: …. |
GITHUB_TOKEN |
yes | Provided automatically as secrets.GITHUB_TOKEN. Needs pull-requests: write for the comment. |
Run the step once per subgraph in a matrix or in separate jobs — each invocation
keys on subgraph-name, so proposals don't collide.
strategy:
matrix:
include:
- subgraph-name: products
schema-file: subgraphs/products/schema.graphql
- subgraph-name: reviews
schema-file: subgraphs/reviews/schema.graphqlThe action derives a deterministic display name from the PR (e.g. pr-42) and
queries the Platform API for an existing proposal with that name. If one exists,
the action publishes a new revision; otherwise it creates a new proposal. This
keeps a 1:1 mapping between PR and proposal across force-pushes.
APOLLO_KEY=service:my-graph:xxx \
GITHUB_TOKEN=ghp_xxx \
INPUT_GRAPH-REF=my-graph@main \
INPUT_SUBGRAPH-NAME=products \
INPUT_SCHEMA-FILE=./schema.graphql \
node src/index.mjs- Schema proposals
- Apollo Platform API
example-custom-check— sibling reference implementation for custom checks.
MIT