Fix Relay generating null query text for mutations
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é <emile@getprobo.com>
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -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
|
||||
|
||||
23
GNUmakefile
23
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 {} +
|
||||
|
||||
|
||||
44
contrib/merge-graphql-schema.sh
Executable file
44
contrib/merge-graphql-schema.sh
Executable file
@@ -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 <output> <graphql-dir>
|
||||
|
||||
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"
|
||||
@@ -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": {
|
||||
|
||||
Reference in New Issue
Block a user