Skip to content
This repository was archived by the owner on Jun 11, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions .github/workflows/build-gateway.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@ jobs:
# https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#adding-a-system-path
echo "$HOME/.rover/bin" >> $GITHUB_PATH

- name: Generate Schema
run: |
cd apps/gateway
task generate-schema

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

Expand Down Expand Up @@ -96,4 +91,4 @@ jobs:
set -e

cd apps/gateway
task container:build-and-push Image=$image_name:$IMAGE_TAG
task container:build-and-push Image=$image_name:$IMAGE_TAG
2 changes: 1 addition & 1 deletion apps/gateway/.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
!package.json
!src
!pnpm-lock.yaml
!prod-schema.graphql
!*.graphqls
3 changes: 3 additions & 0 deletions apps/gateway/Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ USER node
COPY --chown=node package.json pnpm-lock.yaml ./
RUN pnpm i
COPY --chown=node . ./
ARG SUPERGRAPH_FILE
COPY ${SUPERGRAPH_FILE} ./
ENV SUPERGRAPH_SCHEMA_FILE=${SUPERGRAPH_FILE}
ENTRYPOINT ["npm","start"]
11 changes: 8 additions & 3 deletions apps/gateway/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ vars:
tasks:
generate-schema:
cmds:
- bash ./generate-schema.sh
- bash ./generate-schema.sh {{.Output}}
dev:
dotenv:
- "./.secrets/env"
Expand All @@ -22,11 +22,16 @@ tasks:
- task generate-schema
- docker buildx build -f ./Containerfile -t {{.Image}} .


container:build-and-push:
preconditions:
- sh: '[[ -n "{{.Image}}" ]]'
msg: "var Image must have a value, of format 'image_repository:image_tag'"
vars:
SupergraphSchemaFile: "./supergraph.graphqls"
cmds:
- docker buildx build -f ./Containerfile -t {{.Image}} . --push

- task: generate-schema
vars:
Output: "{{.SupergraphSchemaFile}}"
- docker buildx build -f ./Containerfile --build-arg SUPERGRAPH_FILE="{{.SupergraphSchemaFile}}" -t {{.Image}} . --push

24 changes: 13 additions & 11 deletions apps/gateway/generate-schema.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
#! /usr/bin/env bash

out=$1

mkdir -p schemas

cat ../accounts/internal/app/graph/*.graphqls > ./schemas/accounts-api.schema
cat ../accounts/internal/app/graph/struct-to-graphql/*.graphqls >> ./schemas/accounts-api.schema
cat ../accounts/internal/app/graph/*.graphqls >./schemas/accounts-api.schema
cat ../accounts/internal/app/graph/struct-to-graphql/*.graphqls >>./schemas/accounts-api.schema

cat ../console/internal/app/graph/*.graphqls > ./schemas/console-api.schema
cat ../console/internal/app/graph/struct-to-graphql/*.graphqls >> ./schemas/console-api.schema
cat ../console/internal/app/graph/*.graphqls >./schemas/console-api.schema
cat ../console/internal/app/graph/struct-to-graphql/*.graphqls >>./schemas/console-api.schema

cat ../container-registry/internal/app/graph/*.graphqls > ./schemas/container-registry-api.schema
cat ../container-registry/internal/app/graph/struct-to-graphql/*.graphqls >> ./schemas/container-registry-api.schema
cat ../container-registry/internal/app/graph/*.graphqls >./schemas/container-registry-api.schema
cat ../container-registry/internal/app/graph/struct-to-graphql/*.graphqls >>./schemas/container-registry-api.schema

cat ../infra/internal/app/graph/*.graphqls > ./schemas/infra-api.schema
cat ../infra/internal/app/graph/struct-to-graphql/*.graphqls >> ./schemas/infra-api.schema
cat ../infra/internal/app/graph/*.graphqls >./schemas/infra-api.schema
cat ../infra/internal/app/graph/struct-to-graphql/*.graphqls >>./schemas/infra-api.schema

cat ../auth/internal/app/graph/*.graphqls > ./schemas/auth-api.schema
cat ../message-office/internal/app/graph/*.graphqls > ./schemas/message-office-api.schema
cat ../auth/internal/app/graph/*.graphqls >./schemas/auth-api.schema
cat ../message-office/internal/app/graph/*.graphqls >./schemas/message-office-api.schema

rover supergraph compose --config ./supergraph.yml --output prod-schema.graphql --elv2-license accept
rover supergraph compose --config ./supergraph.yml --output "$out" --elv2-license accept
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (code_refinement): It's good practice to quote shell variables to prevent globbing and word splitting. However, ensure that the variable out is always expected to be a single word or path without spaces, or this could lead to unexpected behavior.

Suggested change
rover supergraph compose --config ./supergraph.yml --output "$out" --elv2-license accept
if [[ "$out" =~ \ |\' ]]; then
echo "Error: The output path ('out') contains spaces or single quotes, which might cause unexpected behavior."
exit 1
fi
rover supergraph compose --config ./supergraph.yml --output "$out" --elv2-license accept

2 changes: 1 addition & 1 deletion apps/gateway/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class CustomDataSource extends RemoteGraphQLDataSource {
}
}

const superGraphSchema = await fs.readFile("./prod-schema.graphql");
const superGraphSchema = await fs.readFile(useEnv("SUPERGRAPH_SCHEMA_FILE"));

const gateway = new ApolloGateway({
supergraphSdl: superGraphSchema.toString(),
Expand Down
4 changes: 3 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
# source version control
git
pre-commit
(python312.withPackages(ps: with ps; [
(python312.withPackages (ps: with ps; [
ggshield
]))

Expand All @@ -58,6 +58,8 @@
# build tools
podman
upx

rover
];

shellHook = ''
Expand Down