diff --git a/.github/workflows/schema.yml b/.github/workflows/schema.yml index 44b0d8f9..ec84e47c 100644 --- a/.github/workflows/schema.yml +++ b/.github/workflows/schema.yml @@ -5,15 +5,24 @@ on: pull_request: jobs: - generate_schema: + generate_and_publish_schema: # Deduplicate jobs from pull requests and branch pushes within the same repo. if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository strategy: matrix: service: - - 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 @@ -33,13 +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: 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.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 de8d5322..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,7 +132,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/compound_soaking/src/main.rs b/backend/compound_soaking/src/main.rs index 0a3664de..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,7 +128,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/crystal_library/src/main.rs b/backend/crystal_library/src/main.rs index ed11e825..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,7 +131,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/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();