From 7e943c81052b0d39f722fcf0450c7b42fe862616 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89mile=20R=C3=A9?= Date: Fri, 19 Jun 2026 13:49:13 +0200 Subject: [PATCH] Drop merged GraphQL schema for split files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Relay no longer needs a single merged schema.graphql: each project in relay.config.json now reads the split graphql/*.graphql files directly via `schema` (base.graphql) plus `schemaExtensions`. gqlgen already consumed the split files, so the merge step only fed Relay and the optional IDE GraphQL extension. Remove the merge machinery (contrib/merge-graphql-schema.sh, the RELAY_SCHEMAS make rules, and the gitignore entry) and drop the graphql-config files (apps/trust/graphql.config.yml and the root package.json graphql field); the Relay extension provides schema-aware language features from relay.config.json on its own. relay-compiler keeps generated artifacts in sync (stale ones are removed automatically), so the relay npm script just runs the local relay-compiler and the make target delegates to it. Signed-off-by: Émile Ré --- .gitignore | 1 - GNUmakefile | 20 ++------------- apps/trust/graphql.config.yml | 5 ---- contrib/claude/make.md | 2 +- contrib/merge-graphql-schema.sh | 44 --------------------------------- package.json | 7 +----- relay.config.json | 9 ++++--- 7 files changed, 10 insertions(+), 78 deletions(-) delete mode 100644 apps/trust/graphql.config.yml delete mode 100755 contrib/merge-graphql-schema.sh diff --git a/.gitignore b/.gitignore index ba170da14..5d48a7026 100644 --- a/.gitignore +++ b/.gitignore @@ -21,7 +21,6 @@ compose/keycloak/probo-realm.json # Generated files (codegen) __generated__/ pkg/server/api/*/v1/types/types.go -pkg/server/api/*/v1/schema.graphql cfg/dev_local.yaml cfg/dev.yaml .env diff --git a/GNUmakefile b/GNUmakefile index f265ed06d..384064f7a 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -282,30 +282,14 @@ $(PROBO_AGENT_BIN): @probo/emails: $(NPM) --workspace $@ run build -RELAY_SCHEMAS = \ - pkg/server/api/connect/v1/schema.graphql \ - pkg/server/api/console/v1/schema.graphql \ - pkg/server/api/trust/v1/schema.graphql - .PHONY: relay -relay: $(RELAY_SCHEMAS) - $(NPX) relay-compiler - -MERGE_GRAPHQL = contrib/merge-graphql-schema.sh +relay: + $(NPM) run relay CONNECT_GQL = $(wildcard pkg/server/api/connect/v1/graphql/*.graphql) CONSOLE_GQL = $(wildcard pkg/server/api/console/v1/graphql/*.graphql) TRUST_GQL = $(wildcard pkg/server/api/trust/v1/graphql/*.graphql) -pkg/server/api/connect/v1/schema.graphql: pkg/server/api/connect/v1/graphql $(CONNECT_GQL) - $(MERGE_GRAPHQL) $@ pkg/server/api/connect/v1/graphql - -pkg/server/api/console/v1/schema.graphql: pkg/server/api/console/v1/graphql $(CONSOLE_GQL) - $(MERGE_GRAPHQL) $@ pkg/server/api/console/v1/graphql - -pkg/server/api/trust/v1/schema.graphql: pkg/server/api/trust/v1/graphql $(TRUST_GQL) - $(MERGE_GRAPHQL) $@ pkg/server/api/trust/v1/graphql - .PHONY: @probo/console @probo/console: NODE_ENV=production @probo/console: relay diff --git a/apps/trust/graphql.config.yml b/apps/trust/graphql.config.yml deleted file mode 100644 index 6b90c56ba..000000000 --- a/apps/trust/graphql.config.yml +++ /dev/null @@ -1,5 +0,0 @@ -schema: '../../pkg/server/api/trust/v1/schema.graphql' -extensions: - endpoints: - TrustCenter: - url: http://localhost:8080/api/trust/v1/graphql diff --git a/contrib/claude/make.md b/contrib/claude/make.md index 2840fedc5..7ed252bc2 100644 --- a/contrib/claude/make.md +++ b/contrib/claude/make.md @@ -41,7 +41,7 @@ Individual codegen is driven by `go generate`: - `go generate ./pkg/server/api/mcp/v1` — MCP (mcpgen) - `go generate ./pkg/llm` — LLM model registry from OpenRouter (`make genmodels`) -`make relay` merges split `.graphql` schema files and runs `relay-compiler`. +`make relay` runs `relay-compiler`, which reads the split `.graphql` schema files directly (via each project's `schema` + `schemaExtensions` in `relay.config.json`) and keeps generated artifacts in sync (stale ones are removed automatically). ## Coverage diff --git a/contrib/merge-graphql-schema.sh b/contrib/merge-graphql-schema.sh deleted file mode 100755 index 7b82fb5c9..000000000 --- a/contrib/merge-graphql-schema.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/sh -# Merge split GraphQL schema files into a single file for Relay. -# Strips "type Mutation" and "extend type Mutation { ... }" blocks, -# then appends a single "type Mutation { ... }" with all collected fields. -# -# Usage: merge-graphql-schema.sh - -set -eu - -output="$1" -graphql_dir="$2" -base="$graphql_dir/base.graphql" - -mutation_fields=$(mktemp) -schema_body=$(mktemp) -trap 'rm -f "$mutation_fields" "$schema_body"' EXIT - -process_file() { - awk -v mf="$mutation_fields" ' - /^type Mutation$/ { next } - /^(extend )?type Mutation \{/ { skip=1; depth=1; next } - skip { - if (/\{/) depth++ - if (/\}/) { depth--; if (depth==0) { skip=0; next } } - if (skip) { print >> mf; next } - } - { print } - ' "$1" -} - -{ - process_file "$base" - for f in "$graphql_dir"/*.graphql; do - [ "$f" = "$base" ] && continue - process_file "$f" - done -} > "$schema_body" - -{ - cat "$schema_body" - printf '\ntype Mutation {\n' - cat "$mutation_fields" - printf '}\n' -} > "$output" diff --git a/package.json b/package.json index e488e7f7c..e04294692 100644 --- a/package.json +++ b/package.json @@ -15,17 +15,12 @@ "dev": "turbo run dev", "lint": "turbo run lint", "check": "turbo run check", - "relay-clean": "find apps -type d -name __generated__ -exec rm -rf {} +", - "relay-compile": "npx relay-compiler", - "relay": "npm run relay-clean && npm run relay-compile" + "relay": "relay-compiler" }, "devDependencies": { "relay-compiler": "^21.0.1", "turbo": "^2.9.14" }, - "graphql": { - "schema": "./pkg/server/api/console/v1/graphql/" - }, "overrides": { "brace-expansion": "^5.0.5", "minimatch@3": { diff --git a/relay.config.json b/relay.config.json index 96788f962..b88f66675 100644 --- a/relay.config.json +++ b/relay.config.json @@ -10,7 +10,8 @@ }, "projects": { "core": { - "schema": "pkg/server/api/console/v1/schema.graphql", + "schema": "pkg/server/api/console/v1/graphql/base.graphql", + "schemaExtensions": ["pkg/server/api/console/v1/graphql"], "language": "typescript", "noFutureProofEnums": true, "output": "apps/console/src/__generated__/core", @@ -25,7 +26,8 @@ } }, "iam": { - "schema": "pkg/server/api/connect/v1/schema.graphql", + "schema": "pkg/server/api/connect/v1/graphql/base.graphql", + "schemaExtensions": ["pkg/server/api/connect/v1/graphql"], "language": "typescript", "noFutureProofEnums": true, "output": "apps/console/src/__generated__/iam", @@ -40,7 +42,8 @@ } }, "trust": { - "schema": "pkg/server/api/trust/v1/schema.graphql", + "schema": "pkg/server/api/trust/v1/graphql/base.graphql", + "schemaExtensions": ["pkg/server/api/trust/v1/graphql"], "language": "typescript", "noFutureProofEnums": true, "customScalarTypes": {