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 13, 2024
1 parent cf6a867 commit 741b027
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 27 deletions.
45 changes: 31 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,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 }}
5 changes: 2 additions & 3 deletions backend/compound_library/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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();
Expand Down
5 changes: 2 additions & 3 deletions backend/compound_soaking/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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();
Expand Down
5 changes: 2 additions & 3 deletions backend/crystal_library/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions backend/pin_packing/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions backend/targeting/src/main.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 741b027

Please sign in to comment.