From 00b233aa03389ae808433ac85ae348c47b52a5f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89mile=20R=C3=A9?= Date: Tue, 14 Apr 2026 19:44:28 +0400 Subject: [PATCH] Fix Relay generating null query text for mutations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Relay v20 treats extend type in server schema as client extensions, causing all mutation fields to have "text": null in generated artifacts. Replace the cat-based schema concatenation with a merge script that collects all extend type Mutation blocks and produces a single type Mutation definition. The split graphql/ files remain the source of truth for gqlgen; the merged schema.graphql is generated for Relay. Signed-off-by: Émile Ré --- .gitignore | 1 + GNUmakefile | 23 ++++++++++++++++- contrib/merge-graphql-schema.sh | 44 +++++++++++++++++++++++++++++++++ relay.config.json | 9 +++---- 4 files changed, 70 insertions(+), 7 deletions(-) create mode 100755 contrib/merge-graphql-schema.sh diff --git a/.gitignore b/.gitignore index e65d0c421..99f639ee4 100644 --- a/.gitignore +++ b/.gitignore @@ -18,4 +18,5 @@ 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 diff --git a/GNUmakefile b/GNUmakefile index d1d592e96..40dede001 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -218,10 +218,30 @@ bin/probod-bootstrap: @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: $(RELAY_SCHEMAS) $(NPM) run relay +MERGE_GRAPHQL = contrib/merge-graphql-schema.sh + +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: $(CONNECT_GQL) + $(MERGE_GRAPHQL) $@ pkg/server/api/connect/v1/graphql + +pkg/server/api/console/v1/schema.graphql: $(CONSOLE_GQL) + $(MERGE_GRAPHQL) $@ pkg/server/api/console/v1/graphql + +pkg/server/api/trust/v1/schema.graphql: $(TRUST_GQL) + $(MERGE_GRAPHQL) $@ pkg/server/api/trust/v1/graphql + .PHONY: @probo/console @probo/console: NODE_ENV=production @probo/console: relay @@ -290,6 +310,7 @@ clean: ## Clean the project (node_modules and build artifacts) $(RM) -f pkg/server/api/console/v1/schema/schema.go pkg/server/api/console/v1/types/types.go $(RM) -f pkg/server/api/trust/v1/schema/schema.go pkg/server/api/trust/v1/types/types.go $(RM) -f pkg/server/api/mcp/v1/server/server.go pkg/server/api/mcp/v1/types/types.go + $(RM) -f $(RELAY_SCHEMAS) $(RM) -f pkg/llm/registry_gen.go find apps -type d -name __generated__ -exec $(RM) -rf {} + diff --git a/contrib/merge-graphql-schema.sh b/contrib/merge-graphql-schema.sh new file mode 100755 index 000000000..7b82fb5c9 --- /dev/null +++ b/contrib/merge-graphql-schema.sh @@ -0,0 +1,44 @@ +#!/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/relay.config.json b/relay.config.json index 0d25a5f91..d88213d6e 100644 --- a/relay.config.json +++ b/relay.config.json @@ -7,8 +7,7 @@ }, "projects": { "core": { - "schema": "pkg/server/api/console/v1/graphql/base.graphql", - "schemaExtensions": ["pkg/server/api/console/v1/graphql"], + "schema": "pkg/server/api/console/v1/schema.graphql", "language": "typescript", "noFutureProofEnums": true, "output": "apps/console/src/__generated__/core", @@ -23,8 +22,7 @@ } }, "iam": { - "schema": "pkg/server/api/connect/v1/graphql/base.graphql", - "schemaExtensions": ["pkg/server/api/connect/v1/graphql"], + "schema": "pkg/server/api/connect/v1/schema.graphql", "language": "typescript", "noFutureProofEnums": true, "output": "apps/console/src/__generated__/iam", @@ -39,8 +37,7 @@ } }, "trust": { - "schema": "pkg/server/api/trust/v1/graphql/base.graphql", - "schemaExtensions": ["pkg/server/api/trust/v1/graphql"], + "schema": "pkg/server/api/trust/v1/schema.graphql", "language": "typescript", "noFutureProofEnums": true, "customScalarTypes": {