From 0dc9695b91afb938b7481971c62b9964ad8e3cc9 Mon Sep 17 00:00:00 2001 From: Virgil Date: Thu, 2 Apr 2026 13:58:56 +0000 Subject: [PATCH] feat(api): include graphql in runtime snapshots --- modernization_test.go | 12 +++++++++++- runtime_config.go | 6 ++++-- spec_builder_helper.go | 6 +++--- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/modernization_test.go b/modernization_test.go index 7507313..fc2ed46 100644 --- a/modernization_test.go +++ b/modernization_test.go @@ -120,6 +120,7 @@ func TestEngine_RuntimeConfig_Good_SnapshotsCurrentSettings(t *testing.T) { api.WithSwagger("Runtime API", "Runtime snapshot", "1.2.3"), api.WithSwaggerPath("/docs"), api.WithCacheLimits(5*time.Minute, 10, 1024), + api.WithGraphQL(newTestSchema(), api.WithPlayground()), api.WithI18n(api.I18nConfig{ DefaultLocale: "en-GB", Supported: []string{"en-GB", "fr"}, @@ -152,6 +153,15 @@ func TestEngine_RuntimeConfig_Good_SnapshotsCurrentSettings(t *testing.T) { if !cfg.Cache.Enabled || cfg.Cache.TTL != 5*time.Minute { t.Fatalf("expected cache snapshot to be populated, got %+v", cfg.Cache) } + if !cfg.GraphQL.Enabled { + t.Fatal("expected GraphQL snapshot to be enabled") + } + if cfg.GraphQL.Path != "/graphql" { + t.Fatalf("expected GraphQL path /graphql, got %q", cfg.GraphQL.Path) + } + if !cfg.GraphQL.Playground { + t.Fatal("expected GraphQL playground snapshot to be enabled") + } if cfg.I18n.DefaultLocale != "en-GB" { t.Fatalf("expected default locale en-GB, got %q", cfg.I18n.DefaultLocale) } @@ -176,7 +186,7 @@ func TestEngine_RuntimeConfig_Good_EmptyOnNilEngine(t *testing.T) { var e *api.Engine cfg := e.RuntimeConfig() - if cfg.Swagger.Enabled || cfg.Transport.SwaggerEnabled || cfg.Cache.Enabled || cfg.I18n.DefaultLocale != "" || cfg.Authentik.Issuer != "" { + if cfg.Swagger.Enabled || cfg.Transport.SwaggerEnabled || cfg.GraphQL.Enabled || cfg.Cache.Enabled || cfg.I18n.DefaultLocale != "" || cfg.Authentik.Issuer != "" { t.Fatalf("expected zero-value runtime config, got %+v", cfg) } } diff --git a/runtime_config.go b/runtime_config.go index f2ad893..3f537aa 100644 --- a/runtime_config.go +++ b/runtime_config.go @@ -5,8 +5,8 @@ package api // RuntimeConfig captures the engine's current runtime-facing configuration in // a single snapshot. // -// It groups the existing Swagger, transport, cache, and i18n snapshots so -// callers can inspect the active engine surface without joining multiple +// It groups the existing Swagger, transport, GraphQL, cache, and i18n snapshots +// so callers can inspect the active engine surface without joining multiple // method results themselves. // // Example: @@ -15,6 +15,7 @@ package api type RuntimeConfig struct { Swagger SwaggerConfig Transport TransportConfig + GraphQL GraphQLConfig Cache CacheConfig I18n I18nConfig Authentik AuthentikConfig @@ -37,6 +38,7 @@ func (e *Engine) RuntimeConfig() RuntimeConfig { return RuntimeConfig{ Swagger: e.SwaggerConfig(), Transport: e.TransportConfig(), + GraphQL: e.GraphQLConfig(), Cache: e.CacheConfig(), I18n: e.I18nConfig(), Authentik: e.AuthentikConfig(), diff --git a/spec_builder_helper.go b/spec_builder_helper.go index 8319907..1de6a34 100644 --- a/spec_builder_helper.go +++ b/spec_builder_helper.go @@ -66,9 +66,9 @@ func (e *Engine) OpenAPISpecBuilder() *SpecBuilder { } builder.SwaggerPath = runtime.Transport.SwaggerPath - builder.GraphQLEnabled = runtime.Transport.GraphQLEnabled - builder.GraphQLPath = runtime.Transport.GraphQLPath - builder.GraphQLPlayground = runtime.Transport.GraphQLPlayground + builder.GraphQLEnabled = runtime.GraphQL.Enabled + builder.GraphQLPath = runtime.GraphQL.Path + builder.GraphQLPlayground = runtime.GraphQL.Playground builder.WSPath = runtime.Transport.WSPath builder.WSEnabled = runtime.Transport.WSEnabled builder.SSEPath = runtime.Transport.SSEPath