From aea902ed286df6c3c5e982bb0c80f2eb827fe711 Mon Sep 17 00:00:00 2001 From: Virgil Date: Fri, 3 Apr 2026 05:02:47 +0000 Subject: [PATCH] fix(cmd/api): forward graphql playground path to sdk specs Co-Authored-By: Virgil --- cmd/api/cmd_sdk.go | 1 + cmd/api/cmd_test.go | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/cmd/api/cmd_sdk.go b/cmd/api/cmd_sdk.go index cfffe7b..bfad014 100644 --- a/cmd/api/cmd_sdk.go +++ b/cmd/api/cmd_sdk.go @@ -111,6 +111,7 @@ func sdkSpecBuilder(cfg specBuilderConfig) (*goapi.SpecBuilder, error) { swaggerPath: cfg.swaggerPath, graphqlPath: cfg.graphqlPath, graphqlPlayground: cfg.graphqlPlayground, + graphqlPlaygroundPath: cfg.graphqlPlaygroundPath, ssePath: cfg.ssePath, wsPath: cfg.wsPath, pprofEnabled: cfg.pprofEnabled, diff --git a/cmd/api/cmd_test.go b/cmd/api/cmd_test.go index 5b50fdc..0d5396d 100644 --- a/cmd/api/cmd_test.go +++ b/cmd/api/cmd_test.go @@ -1125,6 +1125,9 @@ func TestAPISDKCmd_Good_ValidatesLanguage(t *testing.T) { if sdkCmd.Flag("sse-path") == nil { t.Fatal("expected --sse-path flag on sdk command") } + if sdkCmd.Flag("graphql-playground-path") == nil { + t.Fatal("expected --graphql-playground-path flag on sdk command") + } if sdkCmd.Flag("ws-path") == nil { t.Fatal("expected --ws-path flag on sdk command") } @@ -1208,6 +1211,7 @@ func TestAPISDKCmd_Good_TempSpecUsesMetadataFlags(t *testing.T) { swaggerPath: "/docs", graphqlPath: "/gql", graphqlPlayground: true, + graphqlPlaygroundPath: "/gql/ide", ssePath: "/events", wsPath: "/ws", pprofEnabled: true, @@ -1234,6 +1238,9 @@ func TestAPISDKCmd_Good_TempSpecUsesMetadataFlags(t *testing.T) { if err != nil { t.Fatalf("unexpected error building sdk spec: %v", err) } + if builder.GraphQLPlaygroundPath != "/gql/ide" { + t.Fatalf("expected custom GraphQL playground path to be preserved in builder, got %q", builder.GraphQLPlaygroundPath) + } groups := collectRouteGroups(sdkSpecGroupsIter()) outputFile := t.TempDir() + "/spec.json" @@ -1278,8 +1285,11 @@ func TestAPISDKCmd_Good_TempSpecUsesMetadataFlags(t *testing.T) { if got := builder.SwaggerPath; got != "/docs" { t.Fatalf("expected swagger path to be preserved in sdk spec builder, got %v", got) } - if _, ok := paths["/gql/playground"]; !ok { - t.Fatal("expected GraphQL playground path to be included in generated spec") + if _, ok := paths["/gql/ide"]; !ok { + t.Fatalf("expected custom GraphQL playground path to be included in generated spec, got keys %v", paths) + } + if _, ok := paths["/gql/playground"]; ok { + t.Fatal("expected custom GraphQL playground path to replace the default playground path") } if _, ok := paths["/events"]; !ok { t.Fatal("expected SSE path to be included in generated spec")