Skip to content

Commit f1acbd7

Browse files
jopemachineclaude
andcommitted
fix(BA-5830): switch app_config_fragment GQL fields from dict[str, Any] to JSON scalar
`dump-gql-schema` failed with `Unexpected type 'dict[str, typing.Any]'` when Strawberry tried to resolve `AppConfigFragment.config` and the bulk-input `config` fields. Match BA-5829's choice and use the strawberry `JSON` scalar so the schema can build. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent f2a5a98 commit f1acbd7

2 files changed

Lines changed: 12 additions & 15 deletions

File tree

src/ai/backend/manager/api/gql/app_config_fragment/types/bulk_inputs.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from __future__ import annotations
44

5-
from typing import Any
5+
from strawberry.scalars import JSON
66

77
from ai.backend.common.dto.manager.v2.app_config_fragment.request import (
88
AdminAppConfigFragmentItemInput as AdminItemInputDTO,
@@ -46,7 +46,7 @@
4646
)
4747
class AdminAppConfigFragmentItemInputGQL(PydanticInputMixin[AdminItemInputDTO]):
4848
key: AppConfigFragmentKeyInputGQL = gql_field(description="Natural-key identifier.")
49-
config: dict[str, Any] = gql_field(description="Raw configuration payload.")
49+
config: JSON = gql_field(description="Raw configuration payload.")
5050

5151

5252
@gql_pydantic_input(
@@ -91,7 +91,7 @@ class AdminBulkPurgeAppConfigFragmentInputGQL(PydanticInputMixin[AdminBulkPurgeI
9191
)
9292
class MyAppConfigFragmentItemInputGQL(PydanticInputMixin[MyItemInputDTO]):
9393
name: str = gql_field(description="Policy name.")
94-
config: dict[str, Any] = gql_field(description="Raw configuration payload.")
94+
config: JSON = gql_field(description="Raw configuration payload.")
9595

9696

9797
@gql_pydantic_input(

src/ai/backend/manager/api/gql/app_config_fragment/types/node.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,26 @@
33
from __future__ import annotations
44

55
from datetime import datetime
6-
from typing import Any
76
from uuid import UUID
87

8+
from strawberry.scalars import JSON
9+
910
from ai.backend.common.dto.manager.v2.app_config_fragment.response import AppConfigFragmentNode
1011
from ai.backend.common.dto.manager.v2.app_config_fragment.types import AppConfigScopeType
1112
from ai.backend.common.meta.meta import NEXT_RELEASE_VERSION
1213
from ai.backend.manager.api.gql.decorators import (
1314
BackendAIGQLMeta,
14-
gql_enum,
1515
gql_field,
1616
gql_pydantic_type,
1717
)
1818
from ai.backend.manager.api.gql.pydantic_compat import PydanticOutputMixin
1919

20-
# Register the shared DTO enum as a Strawberry type.
21-
AppConfigScopeTypeGQL = gql_enum(
22-
BackendAIGQLMeta(
23-
added_version=NEXT_RELEASE_VERSION,
24-
description="App-config scope type.",
25-
),
26-
AppConfigScopeType,
27-
name="AppConfigScopeType",
28-
)
20+
# The shared DTO enum is auto-registered by Strawberry the first time it
21+
# is referenced as a typed field. Re-export under the ``GQL`` suffix so
22+
# other modules can write `from ... import AppConfigScopeTypeGQL`. Calling
23+
# `strawberry.enum(...)` here would clash with that auto-registration
24+
# under the same `"AppConfigScopeType"` name.
25+
AppConfigScopeTypeGQL = AppConfigScopeType
2926

3027

3128
@gql_pydantic_type(
@@ -41,6 +38,6 @@ class AppConfigFragmentGQL(PydanticOutputMixin[AppConfigFragmentNode]):
4138
scope_type: AppConfigScopeType = gql_field(description="Scope type.")
4239
scope_id: str = gql_field(description="Scope id.")
4340
name: str = gql_field(description="Policy name (FK to app_config_policies).")
44-
config: dict[str, Any] | None = gql_field(description="Raw configuration payload, or null.")
41+
config: JSON | None = gql_field(description="Raw configuration payload, or null.")
4542
created_at: datetime = gql_field(description="Creation timestamp.")
4643
updated_at: datetime | None = gql_field(description="Last update timestamp.")

0 commit comments

Comments
 (0)