Skip to content

About

GitHub Action that creates Apollo GraphOS schema proposals from PRs

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

proposal-pr-bot

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.

What it does

On every pull_request event (opened, synchronize, reopened):

  1. Reads the proposed subgraph schema file from the PR branch.
  2. Looks up an existing proposal whose display name matches the branch (so re-pushes update the same proposal).
  3. Creates a new proposal, or publishes a new revision to the existing one.
  4. Posts a sticky comment on the PR with the proposal URL and current status.

Usage

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 }}

Inputs

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.

Secrets

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.

Monorepo / multi-subgraph support

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.graphql

How proposal matching works

The 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.

Local testing

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

See also

License

MIT

About

GitHub Action that creates Apollo GraphOS schema proposals from PRs

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors