From 3ebafd59188a676d08c5769c9cf9f0c5e3625e51 Mon Sep 17 00:00:00 2001 From: Marvin Froeder Date: Wed, 3 Dec 2025 13:55:11 -0300 Subject: [PATCH 1/3] Add GraphQL schema linting to CI Signed-off-by: Marvin Froeder --- .github/workflows/build.yml | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4772e9bb..f2eeeb52 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -211,9 +211,40 @@ jobs: tags: datasqrl/examples:${{ matrix.tag && matrix.tag != '' && matrix.tag || matrix.path }} platforms: linux/amd64,linux/arm64 + lint-graphql: + name: Lint GraphQL Schemas + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Lint GraphQL schemas + run: | + docker run --rm -v "$PWD":/app -w /app node:18-slim bash -c ' + SCHEMAS=$(find . -name "*.graphqls" -type f) + if [ -z "$SCHEMAS" ]; then + echo "No GraphQL schemas found" + exit 0 + fi + + LINT_OPTS="--rules fields-are-camel-cased,types-are-capitalized,enum-values-all-caps,input-object-values-are-camel-cased" + FAILED=0 + + for schema in $SCHEMAS; do + echo "Checking $schema..." + output=$(npx graphql-schema-linter $LINT_OPTS "$schema" 2>&1) + result=$? + echo "$output" | grep -v "^npm" + if [ $result -ne 0 ]; then + FAILED=1 + fi + done + + exit $FAILED + ' + ci-summary: name: build ✅ summary - needs: build + needs: [build, lint-graphql] runs-on: ubuntu-latest if: always() steps: From 3a3e1062b94045b34b3b20d8031182a09dac11ec Mon Sep 17 00:00:00 2001 From: Marvin Froeder Date: Wed, 3 Dec 2025 13:57:15 -0300 Subject: [PATCH 2/3] Fix GraphQL schema naming and add ::group:: to lint output Signed-off-by: Marvin Froeder --- .github/workflows/build.yml | 39 +++++++++---------- logistics-shipping-geodata/logistics.graphqls | 6 +-- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f2eeeb52..fb223623 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -219,28 +219,27 @@ jobs: - name: Lint GraphQL schemas run: | - docker run --rm -v "$PWD":/app -w /app node:18-slim bash -c ' - SCHEMAS=$(find . -name "*.graphqls" -type f) - if [ -z "$SCHEMAS" ]; then - echo "No GraphQL schemas found" - exit 0 + SCHEMAS=$(find . -name "*.graphqls" -type f) + if [ -z "$SCHEMAS" ]; then + echo "No GraphQL schemas found" + exit 0 + fi + + LINT_OPTS="--rules fields-are-camel-cased,types-are-capitalized,enum-values-all-caps,input-object-values-are-camel-cased" + FAILED=0 + + for schema in $SCHEMAS; do + echo "::group::Checking $schema" + output=$(docker run --rm -v "$PWD":/app -w /app node:18-slim npx graphql-schema-linter $LINT_OPTS "$schema" 2>&1) + result=$? + echo "$output" | grep -v "^npm" + echo "::endgroup::" + if [ $result -ne 0 ]; then + FAILED=1 fi + done - LINT_OPTS="--rules fields-are-camel-cased,types-are-capitalized,enum-values-all-caps,input-object-values-are-camel-cased" - FAILED=0 - - for schema in $SCHEMAS; do - echo "Checking $schema..." - output=$(npx graphql-schema-linter $LINT_OPTS "$schema" 2>&1) - result=$? - echo "$output" | grep -v "^npm" - if [ $result -ne 0 ]; then - FAILED=1 - fi - done - - exit $FAILED - ' + exit $FAILED ci-summary: name: build ✅ summary diff --git a/logistics-shipping-geodata/logistics.graphqls b/logistics-shipping-geodata/logistics.graphqls index 92436d0e..cfe8cb95 100644 --- a/logistics-shipping-geodata/logistics.graphqls +++ b/logistics-shipping-geodata/logistics.graphqls @@ -14,9 +14,9 @@ scalar DateTime scalar Long type Query { - Shipment(id: Long!, limit: Int = 10, offset: Int = 0): [Shipment!] - Vehicle(limit: Int = 10, offset: Int = 0): [Vehicle!] - Customer(email: String, id: Long, limit: Int = 10, offset: Int = 0): [Customer!] + shipment(id: Long!, limit: Int = 10, offset: Int = 0): [Shipment!] + vehicle(limit: Int = 10, offset: Int = 0): [Vehicle!] + customer(email: String, id: Long, limit: Int = 10, offset: Int = 0): [Customer!] } type Shipment { From f8d62d443908d184ea7b16a4fd8d84a58f03000b Mon Sep 17 00:00:00 2001 From: Marvin Froeder Date: Wed, 3 Dec 2025 14:02:32 -0300 Subject: [PATCH 3/3] Revert schema change and add ignore rule for Query fields Signed-off-by: Marvin Froeder --- .github/workflows/build.yml | 3 ++- logistics-shipping-geodata/logistics.graphqls | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fb223623..8f0cc0fd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -226,11 +226,12 @@ jobs: fi LINT_OPTS="--rules fields-are-camel-cased,types-are-capitalized,enum-values-all-caps,input-object-values-are-camel-cased" + IGNORE='{"fields-are-camel-cased":["Query.Shipment","Query.Vehicle","Query.Customer"]}' FAILED=0 for schema in $SCHEMAS; do echo "::group::Checking $schema" - output=$(docker run --rm -v "$PWD":/app -w /app node:18-slim npx graphql-schema-linter $LINT_OPTS "$schema" 2>&1) + output=$(docker run --rm -v "$PWD":/app -w /app node:18-slim npx graphql-schema-linter $LINT_OPTS --ignore "$IGNORE" "$schema" 2>&1) result=$? echo "$output" | grep -v "^npm" echo "::endgroup::" diff --git a/logistics-shipping-geodata/logistics.graphqls b/logistics-shipping-geodata/logistics.graphqls index cfe8cb95..92436d0e 100644 --- a/logistics-shipping-geodata/logistics.graphqls +++ b/logistics-shipping-geodata/logistics.graphqls @@ -14,9 +14,9 @@ scalar DateTime scalar Long type Query { - shipment(id: Long!, limit: Int = 10, offset: Int = 0): [Shipment!] - vehicle(limit: Int = 10, offset: Int = 0): [Vehicle!] - customer(email: String, id: Long, limit: Int = 10, offset: Int = 0): [Customer!] + Shipment(id: Long!, limit: Int = 10, offset: Int = 0): [Shipment!] + Vehicle(limit: Int = 10, offset: Int = 0): [Vehicle!] + Customer(email: String, id: Long, limit: Int = 10, offset: Int = 0): [Customer!] } type Shipment {