From 741b027797b290c72dca0a4e2e5daf939f88a551 Mon Sep 17 00:00:00 2001 From: iamvigneshwars Date: Mon, 11 Mar 2024 11:28:58 +0000 Subject: [PATCH] Github action to check subgraph schema againt supergraph schema --- .github/workflows/schema.yml | 45 +++++++++++++++++++--------- backend/compound_library/src/main.rs | 5 ++-- backend/compound_soaking/src/main.rs | 5 ++-- backend/crystal_library/src/main.rs | 5 ++-- backend/pin_packing/src/main.rs | 4 +-- backend/targeting/src/main.rs | 4 +-- 6 files changed, 41 insertions(+), 27 deletions(-) diff --git a/.github/workflows/schema.yml b/.github/workflows/schema.yml index 6527ee6c..ec84e47c 100644 --- a/.github/workflows/schema.yml +++ b/.github/workflows/schema.yml @@ -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 @@ -36,23 +42,34 @@ 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: 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 }} diff --git a/backend/compound_library/src/main.rs b/backend/compound_library/src/main.rs index f27a6d3b..d6e17881 100644 --- a/backend/compound_library/src/main.rs +++ b/backend/compound_library/src/main.rs @@ -12,7 +12,7 @@ mod migrator; /// through various entity structs. mod tables; -use async_graphql::extensions::Tracing; +use async_graphql::{extensions::Tracing, SDLExportOptions}; use axum::{routing::get, Router, Server}; use clap::Parser; use graphql::{root_schema_builder, RootSchema}; @@ -132,8 +132,7 @@ async fn main() { } Cli::Schema(args) => { let schema = root_schema_builder().finish(); - let export_option = async_graphql::SDLExportOptions::default().federation(); - let schema_string = schema.sdl_with_options(export_option); + let schema_string = schema.sdl_with_options(SDLExportOptions::default().federation()); if let Some(path) = args.path { let mut file = File::create(path).unwrap(); file.write_all(schema_string.as_bytes()).unwrap(); diff --git a/backend/compound_soaking/src/main.rs b/backend/compound_soaking/src/main.rs index e740f53a..9f4ade8f 100644 --- a/backend/compound_soaking/src/main.rs +++ b/backend/compound_soaking/src/main.rs @@ -12,7 +12,7 @@ mod migrator; /// and subscriptions. It defines how data is queried and mutated through the API. mod tables; -use async_graphql::extensions::Tracing; +use async_graphql::{extensions::Tracing, SDLExportOptions}; use axum::{routing::get, Router, Server}; use clap::Parser; use graphql::{root_schema_builder, RootSchema}; @@ -128,8 +128,7 @@ async fn main() { } Cli::Schema(args) => { let schema = root_schema_builder().finish(); - let export_option = async_graphql::SDLExportOptions::default().federation(); - let schema_string = schema.sdl_with_options(export_option); + let schema_string = schema.sdl_with_options(SDLExportOptions::default().federation()); if let Some(path) = args.path { let mut file = File::create(path).unwrap(); file.write_all(schema_string.as_bytes()).unwrap(); diff --git a/backend/crystal_library/src/main.rs b/backend/crystal_library/src/main.rs index fcf4f188..932d6718 100644 --- a/backend/crystal_library/src/main.rs +++ b/backend/crystal_library/src/main.rs @@ -12,7 +12,7 @@ mod migrator; /// through various entity structs. mod tables; -use async_graphql::extensions::Tracing; +use async_graphql::{extensions::Tracing, SDLExportOptions}; use axum::{routing::get, Router, Server}; use clap::Parser; use graphql::{root_schema_builder, RootSchema}; @@ -131,8 +131,7 @@ async fn main() { } Cli::Schema(args) => { let schema = root_schema_builder().finish(); - let export_option = async_graphql::SDLExportOptions::default().federation(); - let schema_string = schema.sdl_with_options(export_option); + let schema_string = schema.sdl_with_options(SDLExportOptions::default().federation()); if let Some(path) = args.path { let mut file = File::create(path).unwrap(); file.write_all(schema_string.as_bytes()).unwrap(); diff --git a/backend/pin_packing/src/main.rs b/backend/pin_packing/src/main.rs index 23ac36e3..3a02ddc6 100644 --- a/backend/pin_packing/src/main.rs +++ b/backend/pin_packing/src/main.rs @@ -5,7 +5,7 @@ mod migrations; mod resolvers; mod tables; -use async_graphql::extensions::Tracing; +use async_graphql::{extensions::Tracing, SDLExportOptions}; use axum::{routing::get, Router, Server}; use clap::Parser; use graphql::{root_schema_builder, RootSchema}; @@ -113,7 +113,7 @@ async fn main() { } Cli::Schema(args) => { let schema = root_schema_builder().finish(); - let schema_string = schema.sdl(); + let schema_string = schema.sdl_with_options(SDLExportOptions::default().federation()); if let Some(path) = args.path { let mut file = File::create(path).unwrap(); file.write_all(schema_string.as_bytes()).unwrap(); diff --git a/backend/targeting/src/main.rs b/backend/targeting/src/main.rs index 2d2e4f52..40fb8cd4 100644 --- a/backend/targeting/src/main.rs +++ b/backend/targeting/src/main.rs @@ -1,4 +1,4 @@ -use async_graphql::extensions::Tracing; +use async_graphql::{extensions::Tracing, SDLExportOptions}; use aws_credential_types::{provider::SharedCredentialsProvider, Credentials}; use aws_sdk_s3::{config::Region, Client}; use clap::{ArgAction::SetTrue, Parser}; @@ -125,7 +125,7 @@ async fn main() { } Cli::Schema(args) => { let schema = root_schema_builder().finish(); - let schema_string = schema.sdl(); + let schema_string = schema.sdl_with_options(SDLExportOptions::default().federation()); if let Some(path) = args.path { let mut file = File::create(path).unwrap(); file.write_all(schema_string.as_bytes()).unwrap();