feat(api): include graphql in runtime snapshots

This commit is contained in:
Virgil 2026-04-02 13:58:56 +00:00
parent 0a299b79c1
commit 0dc9695b91
3 changed files with 18 additions and 6 deletions

View file

@ -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)
}
}

View file

@ -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(),

View file

@ -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