Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Commit

Permalink
Github action to check subgraph schema againt supergraph schema
Browse files Browse the repository at this point in the history
  • Loading branch information
iamvigneshwars committed Mar 11, 2024
1 parent cf6a867 commit 402a13e
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 16 deletions.
50 changes: 36 additions & 14 deletions .github/workflows/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,18 @@ jobs:
strategy:
matrix:
service:
- compound_library
- compound_soaking
- crystal_library
- soakdb_sync
- pin_packing
- targeting
- name: compound_library
publish: true
- name: compound_soaking
publish: true
- name: crystal_library
publish: true
- name: soakdb_sync
publish: false
- name: pin_packing
publish: false
- name: targeting
publish: false
runs-on: ubuntu-latest
steps:
- name: Checkout source
Expand All @@ -36,23 +42,39 @@ jobs:
with:
command: run
args: >
--package ${{ matrix.service }}
--package ${{ matrix.service.name }}
--manifest-path backend/Cargo.toml
schema
--path ${{ matrix.service }}.graphql
--path ${{ matrix.service.name }}.graphql
- name: Upload Schema Artifact
uses: actions/upload-artifact@v4.3.1
with:
name: ${{ matrix.service }}.graphql
path: ${{ matrix.service }}.graphql
name: ${{ matrix.service.name }}.graphql
path: ${{ matrix.service.name }}.graphql

- name: publish subgraph
- name: Debug APOLLO_KEY
run: echo "APOLLO_KEY=$APOLLO_KEY"
env:
APOLLO_KEY: ${{ secrets.APOLLO_KEY }}

- name: check subgraph schema
if: ${{ matrix.service.publish }}
uses: danielsinclair/rover-setup@v1
with:
args: subgraph check xchemlab@current
--schema ${{ matrix.service.name }}.graphql
--name ${{ matrix.service.name }}
env:
APOLLO_KEY: ${{ secrets.APOLLO_KEY }}

- name: publish subgraph schema
if: ${{ matrix.service.publish == true }}
uses: danielsinclair/rover-setup@v1
with:
args: subgraph publish xchemlab@current
--routing-url http://${{ matrix.service }}:80
--schema ${{ matrix.service }}.graphql
--name ${{ matrix.service }}
--routing-url http://${{ matrix.service.name }}:80
--schema ${{ matrix.service.name }}.graphql
--name ${{ matrix.service.name }}
env:
APOLLO_KEY: ${{ secrets.APOLLO_KEY }}
3 changes: 2 additions & 1 deletion backend/pin_packing/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ async fn main() {
}
Cli::Schema(args) => {
let schema = root_schema_builder().finish();
let schema_string = schema.sdl();
let export_option = async_graphql::SDLExportOptions::default().federation();
let schema_string = schema.sdl_with_options(export_option);
if let Some(path) = args.path {
let mut file = File::create(path).unwrap();
file.write_all(schema_string.as_bytes()).unwrap();
Expand Down
3 changes: 2 additions & 1 deletion backend/targeting/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ async fn main() {
}
Cli::Schema(args) => {
let schema = root_schema_builder().finish();
let schema_string = schema.sdl();
let export_option = async_graphql::SDLExportOptions::default().federation();
let schema_string = schema.sdl_with_options(export_option);
if let Some(path) = args.path {
let mut file = File::create(path).unwrap();
file.write_all(schema_string.as_bytes()).unwrap();
Expand Down

0 comments on commit 402a13e

Please sign in to comment.