Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/_actions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ jobs:
routing-url: https://example.com/graphql
subgraph-schema-artifact: test-update-schema
subgraph-schema-filename: test-schema.graphql
supergraph-schema-artifact: compose-supergraph-without-app
execution-config-artifact: router-exec-config
execution-config-filename: router-execution-config.json

publish: false

- name: Check Supergraph with App
Expand All @@ -47,7 +49,8 @@ jobs:
routing-url: https://example.com/graphql
subgraph-schema-artifact: test-update-schema
subgraph-schema-filename: test-schema.graphql
supergraph-schema-artifact: compose-supergraph-with-app
execution-config-artifact: router-exec-config
execution-config-filename: router-execution-config.json
github-app-id: 1010045
github-app-private-key: ${{ secrets.GRAPH_FEDERATOR }}
publish: false
41 changes: 23 additions & 18 deletions .github/workflows/_supergraph_generate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,35 @@ on:
jobs:
generate:
runs-on: ubuntu-latest
defaults:
run:
shell: bash

steps:
- name: Install Rover CLI
run: |
curl -sSL https://rover.apollo.dev/nix/latest | sh
echo "$HOME/.rover/bin" >> $GITHUB_PATH
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "24"

- name: Install Cosmo CLI
run: npm install -g wgc@latest

- name: Checkout Source
uses: actions/checkout@v4.2.2

- name: Compose Supergraph Schema
run: >
rover supergraph compose
--config supergraph-config.yaml
--elv2-license=accept
> supergraph.graphql
- name: Compose Execution Config
run: |
wgc router compose \
--input supergraph-config.yaml \
--out charts/graph/router-execution-config.json

- name: Upload New Schema Artifact
uses: actions/upload-artifact@v4.6.0
- name: Upload Execution Config Artifact
uses: actions/upload-artifact@v4
with:
name: supergraph.graphql
path: supergraph.graphql

- name: Release Supergraph Schema
if: github.event_name == 'push' && ( startsWith(github.ref, 'refs/tags/supergraph-schema@') )
name: router-execution-config.json
path: charts/graph/router-execution-config.json
- name: Release Router Execution Config
if: github.event_name == 'push' && ( startsWith(github.ref, 'refs/tags/router-execution-config@') )
uses: softprops/action-gh-release@v1
with:
files: supergraph.graphql
files: charts/graph/router-execution-config.json
12 changes: 6 additions & 6 deletions .github/workflows/_supergraph_publish.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish Supergraph Schema
name: Publish Router Execution Config

on:
workflow_call:
Expand Down Expand Up @@ -35,16 +35,16 @@ jobs:
if: steps.version.outputs.result != ''
uses: azure/setup-helm@v4.2.0

- name: Download Schema Artifact
- name: Download Router Execution Config Artifact
if: steps.version.outputs.result != ''
uses: actions/download-artifact@v4.1.8
with:
name: supergraph.graphql
path: charts/supergraph
name: router-execution-config
path: charts/graph

- name: Package Chart
if: steps.version.outputs.result != ''
run: helm package charts/supergraph --version ${{ steps.version.outputs.result }}
run: helm package charts/graph --version ${{ steps.version.outputs.result }}

- name: Generate Image Name
if: steps.version.outputs.result != ''
Expand All @@ -63,4 +63,4 @@ jobs:

- name: Publish Chart
if: steps.version.outputs.result != '' && github.event_name == 'push' && ( startsWith(github.ref, 'refs/tags') || startsWith(github.ref, 'refs/heads/main') )
run: helm push $(ls supergraph-*.tgz) ${{ env.IMAGE_REPOSITORY }}
run: helm push $(ls graph-*.tgz) ${{ env.IMAGE_REPOSITORY }}
55 changes: 32 additions & 23 deletions .github/workflows/schema_comparison.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,50 @@ on:
pull_request:

jobs:
compare_schema:
compare_execution_config:
runs-on: ubuntu-latest
steps:
- name: Install Rover CLI
run: |
curl -sSL https://rover.apollo.dev/nix/latest | sh
echo "$HOME/.rover/bin" >> $GITHUB_PATH
defaults:
run:
shell: bash

- name: Checkout main branch
uses: actions/checkout@v4.2.2
steps:
- name: Checkout main
uses: actions/checkout@v4
with:
ref: main

- name: Compose old Supergraph Schema
run: >
rover supergraph compose
--config supergraph-config.yaml
--elv2-license=accept
> /tmp/old_supergraph.graphql
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "24"

- name: Install Cosmo CLI (wgc)
run: npm install -g wgc@latest

- name: Compose old Execution Config (main)
run: |
wgc router compose \
--input supergraph-config.yaml \
--out /tmp/old_router-execution-config.json

- name: Checkout Source
uses: actions/checkout@v4.2.2

- name: Compose New Supergraph Schema
run: >
rover supergraph compose
--config supergraph-config.yaml
--elv2-license=accept
> supergraph.graphql
- name: Compose New Execution Config (PR)
run: |
wgc router compose \
--input supergraph-config.yaml \
--out router-execution-config.json

- name: Normalize JSON
run: |
jq -S . /tmp/old_router-execution-config.json > /tmp/old_sorted.json
jq -S . router-execution-config.json > /tmp/new_sorted.json

- name: Generate Schema Diff
- name: Generate Diff
run: |
git --no-pager diff --no-index --minimal /tmp/old_supergraph.graphql supergraph.graphql > diff.md || true
git --no-pager diff --no-index --minimal /tmp/old_sorted.json /tmp/new_sorted.json > diff.md || true
if [ -s diff.md ]; then echo "has_diff=true" >> $GITHUB_ENV; fi
sed -i 1,4d diff.md
sed -i '1s/^/```diff\n/; $a```' diff.md

- name: Comment PR with artefact comparison report
Expand Down
29 changes: 14 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,18 @@ Docs can be found [on github pages](https://diamondlightsource.github.io/graph-f

## Structure

- `supergraph-schema.yaml` & `schema/`: A description of how subgraph schemas and how they are composed to produce the supergraph schema.
- `supergraph-config.yaml` & `schema/`: A description of how subgraph schemas and how they are composed a runtime execution configuration for the Cosmo Router.
- `apps.yaml` & `charts/apps/`: An [ArgoCD](https://argoproj.github.io/cd/) [App-of-Apps](https://argo-cd.readthedocs.io/en/stable/operator-manual/cluster-bootstrapping/#app-of-apps-pattern) used to deploy the other charts in various configurations
- `charts/graph`: A Helm chart used to deploy the [Apollo Router](https://www.apollographql.com/docs/router/)
- `charts/graph`: A Helm chart used to deploy the [Cosmo Router](https://wundergraph.com/router-gateway/), including the generated router-execution-config.json, mounted via a ConfigMap.
- `charts/monitoring`: A Helm chart used to deploy [Prometheus](https://prometheus.io/) and [Jaeger](https://www.jaegertracing.io/) for observability
- `charts/supergraph`: A Helm chart used to deploy the supergraph schema
- `action.yaml`: A [GitHub action](https://github.com/features/actions) used to create subgraph schema update pull requests
- `mkdocs.yaml` & `docs/`: User facing documentation, built with [mkdocs](https://www.mkdocs.org/)

## Action

### Update Supergraph Schema

This workflow may be used to create or update a Subgraph Schema by adding the schema to the `schema/` directory and an entry in the `supergraph-config.yaml` of this repository.
This workflow may be used to create or update a Subgraph Schema by adding the schema to the `schema/` directory and an entry in the `supergraph-config.yaml` of this repository. The workflow composes the federated graph using Cosmo's composition pipeline and generates a new router-execution-config.json
The action can be used to simply check that the schema will federate by setting `publish` to `false`.

#### Usage
Expand All @@ -46,13 +45,13 @@ The action can be used to simply check that the schema will federate by setting
# Required.
subgraph-schema-filename:

# The name of the artifact to be created containing the supergraph schema.
# Optional. Default is 'supergraph'
supergraph-schema-artifact:
# The name of the artifact to be created containing the generated router execution config.
# Optional. Default is 'router-execution-config'
execution-config-artifact:

# The name of the supergraph schema file within the created artifact.
# Optional. Default is 'supergraph.graphql'
supergraph-schema-filename:
# The name of the generated execution config within the created artifact.
# Optional. Default is 'router-execution-config.json'
execution-config-filename:

# The ID of the GitHub App used to create the commit / pull request
# Required when publish is true.
Expand All @@ -69,10 +68,10 @@ The action can be used to simply check that the schema will federate by setting

##### Outputs

| Name | Description | Example |
| ------------------------------ | -------------------------------------------------------- | --------------------------------------------------------------------------- |
| supergraph-schema-artifact-id | The id of the artifact containing the supergraph schema | 1234 |
| supergraph-schema-artifact-url | The url of the artifact containing the supergraph schema | <https://github.com/example-org/example-repo/actions/runs/1/artifacts/1234> |
| Name | Description | Example |
| ----------------------------- | -------------------------------------------------------------- | --------------------------------------------------------------------------- |
| execution-config-artifact-id | The id of the artifact containing the router execution config | 1234 |
| execution-config-artifact-url | The url of the artifact containing the router execution config | <https://github.com/example-org/example-repo/actions/runs/1/artifacts/1234> |

##### Example

Expand All @@ -95,7 +94,7 @@ steps:
name: test-schema
path: test-schema.graphql

- name: Update Supergraph
- name: Update Composition
uses: diamondlightsource/graph-federation@main
with:
name: test
Expand Down
85 changes: 42 additions & 43 deletions action.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Update Supergraph
description: Perform Supergraph composition with appropraite subgraph schema and metadata and create PR
description: Perform supergraph composition (Cosmo) and create PR

inputs:
name:
Expand All @@ -14,32 +14,32 @@ inputs:
subgraph-schema-filename:
description: The name of the subgraph schema file within the artifact
required: true
supergraph-schema-artifact:
description: The name of the artifact to be created containing the supergraph schema
execution-config-artifact:
description: The name of the artifact to be created that contains the Cosmo router execution config
required: true
default: supergraph
supergraph-schema-filename:
description: The name of the supergraph schema file within the created artifact
default: router-execution-config
execution-config-filename:
description: The filename of the execution config JSON
required: true
default: supergraph.graphql
default: router-execution-config.json
github-app-id:
description: The ID of the GitHub App used to create the commit / pull request
required: false
github-app-private-key:
description: The private key of the GitHub App used to create the commit / pull request
required: false
publish:
description: A boolean value which determines whether a branch and pull request should be created
description: Whether to create a branch and PR
required: true
default: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}

outputs:
supergraph-schema-artifact-id:
description: The id of the artifact containing the supergraph schema
value: ${{ steps.compose.outputs.artifact-id }}
supergraph-schema-artifact-url:
description: The url of the artifact containing the supergraph schema
value: ${{ steps.compose.outputs.artifact-url }}
execution-config-artifact-id:
description: The id of the artifact containing the execution config JSON
value: ${{ steps.upload.outputs.artifact-id }}
execution-config-artifact-url:
description: The url of the artifact containing the execution config JSON
value: ${{ steps.upload.outputs.artifact-url }}

runs:
using: composite
Expand Down Expand Up @@ -75,42 +75,41 @@ runs:
shell: bash
run: mv /tmp/schema/${{ inputs.subgraph-schema-filename}} schema/${{ inputs.name }}.graphql

- name: Add Subgraph workflows to Supergraph config
- name: Update supergraph-config.yaml
shell: bash
run: >
yq -i
'
.subgraphs.${{ inputs.name }}={
"routing_url":"${{ inputs.routing-url}}",
"schema":{
"file":"schema/${{ inputs.name }}.graphql"
}
}
'
supergraph-config.yaml
run: |
yq -i '
.subgraphs += [{
"name": "${{ inputs.name }}",
"routing_url": "${{ inputs.routing-url }}",
"schema": { "file": "schema/${{ inputs.name }}.graphql" }
}]
' supergraph-config.yaml

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "24"

- name: Install Rover CLI
- name: Install Cosmo CLI
shell: bash
run: |
if ! command -v rover 2>&1 > /dev/null; then
curl -sSL https://rover.apollo.dev/nix/latest | sh
echo "$HOME/.rover/bin" >> $GITHUB_PATH
fi
run: npm install -g wgc@latest

- name: Compose Supergraph Schema
- name: Compose Execution Config
id: compose
shell: bash
run: >
rover supergraph compose
--config supergraph-config.yaml
--elv2-license=accept
> ${{ inputs.supergraph-schema-filename }}
run: |
wgc router compose \
--input supergraph-config.yaml \
--out ${{ inputs.execution-config-filename }}

- name: Upload Supergraph Artifact
id: supergraph-artifact
uses: actions/upload-artifact@v4.4.3
- name: Upload Execution Config Artifact
id: upload
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.supergraph-schema-artifact }}
path: ./${{ inputs.supergraph-schema-filename }}
name: ${{ inputs.execution-config-artifact }}
path: ./${{ inputs.execution-config-filename }}
overwrite: true

- name: Configure Git with App
shell: bash
Expand Down
Loading
Loading