diff --git a/.devcontainer/Dockerfile.backend b/.devcontainer/Dockerfile.backend index a68c3801..7f6f6045 100644 --- a/.devcontainer/Dockerfile.backend +++ b/.devcontainer/Dockerfile.backend @@ -8,6 +8,5 @@ RUN apt-get update \ libopencv-dev clang libclang-dev \ && rm -rf /var/lib/apt/lists/* -# Install Rover CLI for composing and precompiles rust router (gateway) for subgraphs -RUN curl -sSL https://rover.apollo.dev/nix/latest | sh\ - && curl -sSL https://router.apollo.dev/download/nix/latest | sh +# Install Rover CLI for composing subgraphs +RUN curl -sSL https://rover.apollo.dev/nix/latest | sh diff --git a/.devcontainer/docker-compose.yaml b/.devcontainer/docker-compose.yaml index 79a156b1..e517c248 100644 --- a/.devcontainer/docker-compose.yaml +++ b/.devcontainer/docker-compose.yaml @@ -1,6 +1,20 @@ version: "3.8" services: + apollo-router: + image: ghcr.io/apollographql/router:v1.41.0-rc.2 + volumes: + - ./supergraph.graphql:/dist/schema/supergraph.graphql + - ./router.yaml:/dist/config/router.yaml + ports: + - 4001:4000 + command: + - --dev + - -config + - config/router.yaml + - -supergraph + - schema/supergraph.graphql + backend: build: context: . @@ -12,6 +26,9 @@ services: OPA_URL: http://opa:8181 DATABASE_URL: postgres://postgres:password@postgres RABBITMQ_URL: amqp://rabbitmq:password@rabbitmq + CRYSTAL_LIBRARY_PORT: 8000 + COMPOUND_LIBRARY_PORT: 8001 + COMPOUND_SOAKING_PORT: 8002 frontend: image: docker.io/library/node:20.6.0-bookworm diff --git a/backend/router.yaml b/.devcontainer/router.yaml similarity index 58% rename from backend/router.yaml rename to .devcontainer/router.yaml index 59dab80b..9871cccb 100644 --- a/backend/router.yaml +++ b/.devcontainer/router.yaml @@ -1,5 +1,7 @@ +supergraph: + listen: 0.0.0.0:4000 headers: all: # Header rules for all subgraphs request: - propagate: - matching: .* \ No newline at end of file + matching: .* diff --git a/.gitignore b/.gitignore index 25e65aeb..8df3c614 100644 --- a/.gitignore +++ b/.gitignore @@ -4,8 +4,5 @@ # Developer Tooling .vscode -# Apollo router -router -backend/router # Generated supergraph schema -backend/supergraph.graphql +.devcontainer/supergraph.graphql diff --git a/backend/compound_library/src/graphql/compound_instances_res.rs b/backend/compound_library/src/graphql/compound_instances_res.rs index c8135180..622669ed 100644 --- a/backend/compound_library/src/graphql/compound_instances_res.rs +++ b/backend/compound_library/src/graphql/compound_instances_res.rs @@ -60,7 +60,7 @@ impl CompoundInstanceQuery { /// Reference resolver for compound instance in compound library subgraph #[graphql(entity)] - async fn get_compound_instance_by_id( + async fn route_compound_instance( &self, ctx: &Context<'_>, plate_id: Uuid, diff --git a/backend/compound_library/src/main.rs b/backend/compound_library/src/main.rs index 93cd63cb..de8d5322 100644 --- a/backend/compound_library/src/main.rs +++ b/backend/compound_library/src/main.rs @@ -43,7 +43,7 @@ enum Cli { #[allow(clippy::missing_docs_in_private_items)] struct ServeArgs { /// The port number to serve on. - #[arg(short, long, default_value_t = 80)] + #[arg(short, long, default_value_t = 80, env = "COMPOUND_LIBRARY_PORT")] port: u16, /// URL for the OPA server #[arg(long, env)] diff --git a/backend/compound_soaking/src/graphql/soak_compound_res.rs b/backend/compound_soaking/src/graphql/soak_compound_res.rs index c3120e19..f9dc2c44 100644 --- a/backend/compound_soaking/src/graphql/soak_compound_res.rs +++ b/backend/compound_soaking/src/graphql/soak_compound_res.rs @@ -107,7 +107,7 @@ impl SoakCompoundQuery { /// Reference resolver for crystal wells #[graphql(entity)] - async fn get_crystal_well_by_plate_id(&self, plate_id: Uuid, well_number: i16) -> CrystalWells { + async fn route_crystal_well(&self, plate_id: Uuid, well_number: i16) -> CrystalWells { CrystalWells { plate_id, well_number, @@ -116,7 +116,7 @@ impl SoakCompoundQuery { /// Reference resolver for compound wells #[graphql(entity)] - async fn get_compound_instances_by_plate_id( + async fn route_compound_instances( &self, plate_id: Uuid, well_number: i16, @@ -131,14 +131,14 @@ impl SoakCompoundQuery { #[Object] impl SoakCompoundMutation { /// Adds a soaked compound to the database - async fn add_soaked_compound( + async fn soak_compound( &self, ctx: &Context<'_>, compound_plate_id: Uuid, #[graphql(validator(minimum = 1, maximum = 288))] compound_well_number: i16, crystal_plate_id: Uuid, #[graphql(validator(minimum = 1, maximum = 288))] crystal_well_number: i16, - volume: f32, + volume: u32, ) -> async_graphql::Result { let operator_id = subject_authorization!("xchemlab.compound_soaking.write_soaked_compound", ctx).await?; diff --git a/backend/compound_soaking/src/main.rs b/backend/compound_soaking/src/main.rs index 9a7baa3e..0a3664de 100644 --- a/backend/compound_soaking/src/main.rs +++ b/backend/compound_soaking/src/main.rs @@ -41,7 +41,7 @@ enum Cli { #[derive(Debug, Parser)] #[allow(clippy::missing_docs_in_private_items)] struct ServeArgs { - #[arg(short, long, default_value_t = 80)] + #[arg(short, long, default_value_t = 80, env = "COMPOUND_SOAKING_PORT")] port: u16, #[arg(long, env)] database_url: Url, diff --git a/backend/compound_soaking/src/tables/soak_compound.rs b/backend/compound_soaking/src/tables/soak_compound.rs index d752e2d4..a8f9af00 100644 --- a/backend/compound_soaking/src/tables/soak_compound.rs +++ b/backend/compound_soaking/src/tables/soak_compound.rs @@ -23,8 +23,8 @@ pub struct Model { /// The well on the plate which the crystal is located. #[sea_orm(primary_key, auto_increment = false)] pub crystal_well_number: i16, - /// The volume of compounds soaked. - pub volume: f32, + /// The volume of compounds transferred into the crystal well. + pub volume: u32, /// The identifier of the operator which added this entry. pub operator_id: String, /// The date and time when the compound instance was added. diff --git a/backend/crystal_library/src/graphql/crystal_wells_res.rs b/backend/crystal_library/src/graphql/crystal_wells_res.rs index 6b0b3bc4..905ebe97 100644 --- a/backend/crystal_library/src/graphql/crystal_wells_res.rs +++ b/backend/crystal_library/src/graphql/crystal_wells_res.rs @@ -62,7 +62,7 @@ impl CrystalWellsQuery { /// Reference resolver for crystal wells in crystal library graphql subgraph #[graphql(entity)] - async fn find_crystal_wells_by_id( + async fn route_crystal_wells( &self, ctx: &Context<'_>, plate_id: Uuid, diff --git a/backend/crystal_library/src/main.rs b/backend/crystal_library/src/main.rs index c656482c..ed11e825 100644 --- a/backend/crystal_library/src/main.rs +++ b/backend/crystal_library/src/main.rs @@ -42,7 +42,7 @@ enum Cli { #[allow(clippy::missing_docs_in_private_items)] struct ServeArgs { /// The port number to serve on - #[arg(short, long, default_value_t = 80)] + #[arg(short, long, default_value_t = 80, env = "CRYSTAL_LIBRARY_PORT")] port: u16, /// URL for the database #[arg(long, env)] diff --git a/backend/supergraph-config.yaml b/backend/supergraph-config.yaml index a3b9245c..60728ebc 100644 --- a/backend/supergraph-config.yaml +++ b/backend/supergraph-config.yaml @@ -1,14 +1,15 @@ federation_version: 2 subgraphs: crystal_library: - routing_url: http://localhost:80 + routing_url: http://backend:8000 schema: - subgraph_url: http://localhost:80 + subgraph_url: http://backend:8000 compound_library: - routing_url: http://localhost:81 + routing_url: http://backend:8001 schema: - subgraph_url: http://localhost:81 + subgraph_url: http://backend:8001 compound_soaking: - routing_url: http://localhost:82 + routing_url: http://backend:8002 schema: - subgraph_url: http://localhost:82 \ No newline at end of file + subgraph_url: http://backend:8002 + \ No newline at end of file