From 43862472d8cd21de6e965d3522d1c8bb5194d833 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Syn=C3=A1=C4=8Dek?= Date: Thu, 26 Mar 2026 16:05:41 +0100 Subject: [PATCH 1/4] feat: add publishing script --- .github/workflows/deploy.yaml | 17 +++++++++++++++++ Makefile | 3 +++ package.json | 1 + plugins/products/package.json | 1 + plugins/reviews/package.json | 1 + 5 files changed, 23 insertions(+) create mode 100644 .github/workflows/deploy.yaml diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml new file mode 100644 index 0000000..701672f --- /dev/null +++ b/.github/workflows/deploy.yaml @@ -0,0 +1,17 @@ +name: CI + +on: + push: + branches: + - main + +jobs: + deploy: + runs-on: ubuntu-latest + env: + COSMO_API_KEY: ${{ secrets.COSMO_API_KEY }} + steps: + - uses: actions/checkout@v6.0.2 + - uses: ./.github/actions/setup + - run: make check-subgraphs + - run: make publish-ci diff --git a/Makefile b/Makefile index 20c3e92..786c178 100644 --- a/Makefile +++ b/Makefile @@ -26,6 +26,9 @@ docker-local: generate: @pnpm generate +publish-ci: + @pnpm publish:ci + # Test all plugins test: @pnpm test diff --git a/package.json b/package.json index 9649c80..3c904ef 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "generate": "pnpm -r generate", "lint": "pnpm -r lint", "lint:ci": "pnpm -r lint:ci", + "publish:ci": "pnpm -r --workspace-concurrency=1 publish:ci", "test": "pnpm -r test", "test:ci": "pnpm -r --workspace-concurrency=1 test:ci", "start": "pnpm build && pnpm compose && make docker-local && docker run --rm -p 3002:3002 cosmo-demo-local" diff --git a/plugins/products/package.json b/plugins/products/package.json index f5e52af..6fa150b 100644 --- a/plugins/products/package.json +++ b/plugins/products/package.json @@ -11,6 +11,7 @@ "generate": "wgc router plugin generate .", "lint": "golangci-lint run ./...", "lint:ci": "golangci-lint run --allow-parallel-runners ./...", + "publish:ci": "wgc router plugin publish --namespace default --label graph=demo --fail-on-composition-error .", "test": "wgc router plugin test .", "test:ci": "wgc router plugin test . --yes" }, diff --git a/plugins/reviews/package.json b/plugins/reviews/package.json index d82d366..526242b 100644 --- a/plugins/reviews/package.json +++ b/plugins/reviews/package.json @@ -11,6 +11,7 @@ "generate": "wgc router plugin generate .", "lint": "golangci-lint run ./...", "lint:ci": "golangci-lint run --allow-parallel-runners ./...", + "publish:ci": "wgc router plugin publish --namespace default --label graph=demo --fail-on-composition-error .", "test": "wgc router plugin test .", "test:ci": "wgc router plugin test . --yes" }, From a925407d801e8c8a4e8cd3110aab68160392abe2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Syn=C3=A1=C4=8Dek?= Date: Thu, 26 Mar 2026 16:43:42 +0100 Subject: [PATCH 2/4] feat: subgraph checks part of CI --- .github/workflows/ci.yaml | 9 +++++++++ Makefile | 3 +++ package.json | 1 + plugins/products/package.json | 1 + plugins/reviews/package.json | 1 + 5 files changed, 15 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 84166db..e85fa42 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -47,3 +47,12 @@ jobs: with: setup-go: "true" - run: make test-ci + subgraphs-check: + name: Check GraphQL schemas + runs-on: ubuntu-latest + env: + COSMO_API_KEY: ${{ secrets.COSMO_API_KEY }} + steps: + - uses: actions/checkout@v6.0.2 + - uses: ./.github/actions/setup + - run: make check-subgraphs diff --git a/Makefile b/Makefile index 786c178..1671d61 100644 --- a/Makefile +++ b/Makefile @@ -15,6 +15,9 @@ build-ci: compose: @pnpm compose +check-subgraphs: + @pnpm subgraphs:check + # Build linux plugin binary + Docker image (run `make compose` first if config.json is missing) # for local development # Usage: make docker-local diff --git a/package.json b/package.json index 3c904ef..3be75e6 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "build": "pnpm -r build", "build:ci": "pnpm -r --workspace-concurrency=1 build:ci", "compose": "wgc router compose -i ./plugins/graph.yaml -o ./config.json", + "subgraphs:check": "pnpm -r subgraph:check", "format": "pnpm -r format", "generate": "pnpm -r generate", "lint": "pnpm -r lint", diff --git a/plugins/products/package.json b/plugins/products/package.json index 6fa150b..8833098 100644 --- a/plugins/products/package.json +++ b/plugins/products/package.json @@ -12,6 +12,7 @@ "lint": "golangci-lint run ./...", "lint:ci": "golangci-lint run --allow-parallel-runners ./...", "publish:ci": "wgc router plugin publish --namespace default --label graph=demo --fail-on-composition-error .", + "subgraph:check": "wgc subgraph check reviews --namespace default --label graph=demo --schema ./src/schema.graphql", "test": "wgc router plugin test .", "test:ci": "wgc router plugin test . --yes" }, diff --git a/plugins/reviews/package.json b/plugins/reviews/package.json index 526242b..8f84bba 100644 --- a/plugins/reviews/package.json +++ b/plugins/reviews/package.json @@ -12,6 +12,7 @@ "lint": "golangci-lint run ./...", "lint:ci": "golangci-lint run --allow-parallel-runners ./...", "publish:ci": "wgc router plugin publish --namespace default --label graph=demo --fail-on-composition-error .", + "subgraph:check": "wgc subgraph check reviews --namespace default --label graph=demo --schema ./src/schema.graphql", "test": "wgc router plugin test .", "test:ci": "wgc router plugin test . --yes" }, From a98990e59c62eec1c1ea6a43bc4809a1b5bfb2e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Syn=C3=A1=C4=8Dek?= Date: Thu, 26 Mar 2026 17:22:03 +0100 Subject: [PATCH 3/4] docs: mention secret in documentation --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5bbbe66..7e6261e 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ Run `wgc demo` and make sure you are logged in to your Cosmo Cloud account. Foll ### Implementing `averageRating` field 1. Fork this repo. -2. Add `ROUTER_TOKEN` to your CI secrets (TBD - Github workflow) +2. Create a secret named `COSMO_API_KEY` for your forked repo with your private API key ([Studio API Keys documentation](https://cosmo-docs.wundergraph.com/studio/api-keys)). 3. In `plugins/reviews/src/schema.graphql` expand the schema file: ```diff From de8ba53e6dd3a18b2b434d1f93b4c600f483c991 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Syn=C3=A1=C4=8Dek?= Date: Thu, 26 Mar 2026 17:23:08 +0100 Subject: [PATCH 4/4] docs: path to implementation file --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7e6261e..db6235a 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ Run `wgc demo` and make sure you are logged in to your Cosmo Cloud account. Foll ``` 4. Run `make generate` in `plugins/reviews` directory to generate gRPC methods. -5. Add the new field `AverageRating` to the `Product` struct, using `calculateAverageRating` function that is provided: +5. Add the new field `AverageRating` to the `Product` struct in `plugins/reviews/src/main.go`. Use the `calculateAverageRating` function that is provided to implement the calculation: ```diff @@ -62,6 +62,7 @@ func (s *ReviewsService) LookupProductById(ctx context.Context, req *service.Loo