Skip to content

Commit 92cc106

Browse files
authored
Upgrade strawberry graphql to 0.246.2 and above (#777)
* Upgrade strawberry graphql to 0.236.0 and above * Upgrade strawberry to above 0.246.2 and upgrade nwa-stdlib * Change strawberry graphql to earliest failing update for debugging - revert to old imports - add temp log for models * remove blocks from strawberry_models * Fix duplicate type error in strawberry.federation.schema The problem was that the `autoregistration` unnecessarily created a type based on the output of the `pydantic_wrapper` function, which already generates the required Strawberry type. This led to the same Strawberry type being created twice at runtime, but from different locations: 1. Directly in the `pydantic_wrapper`, resulting in `strawberry.experimental.pydantic.object_type.YourStrawberryType`. 2. Indirectly in `autoregistration`, which created a type using the result of `pydantic_wrapper`, resulting in `orchestrator.graphql.autoregistration.YourStrawberryType` - with the function `create_block_strawberry_type` or `create_subscription_strawberry_type`. Previously Strawberry handled this duplication because it already needed to convert Strawberry types to GraphQL types, so we never noticed that we created the type twice. Strawberry refactored `strawberry.federation.schema` to use Strawberry types directly (removing GraphQL type conversion) in version `0.233.0`. This implementation does not unintentionally fix our duplicate types and resulted in the runtime error: `Union type _Entity can only include type YourStrawberryType once`. Removing the type create in `autoregistration` fixed this problem. * Change strawberry-graphql back to 0.246.2 or above * Add sort_by to test_product_blocks_has_previous_page * Bumpversion to 2.9.0rc1
1 parent 23edbff commit 92cc106

File tree

12 files changed

+16
-18
lines changed

12 files changed

+16
-18
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 2.8.0
2+
current_version = 2.9.0rc1
33
commit = False
44
tag = False
55
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(rc(?P<build>\d+))?

orchestrator/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
"""This is the orchestrator workflow engine."""
1515

16-
__version__ = "2.8.0"
16+
__version__ = "2.9.0rc1"
1717

1818
from orchestrator.app import OrchestratorCore
1919
from orchestrator.settings import app_settings

orchestrator/graphql/autoregistration.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
import strawberry
1818
import structlog
1919
from more_itertools import one
20+
from strawberry import UNSET
2021
from strawberry.experimental.pydantic.conversion_types import StrawberryTypeFromPydantic
2122
from strawberry.federation.schema_directives import Key
22-
from strawberry.unset import UNSET
2323

2424
from orchestrator.domain import SUBSCRIPTION_MODEL_REGISTRY
2525
from orchestrator.domain.base import DomainModel, get_depends_on_product_block_type_list
@@ -76,8 +76,8 @@ def create_block_strawberry_type(
7676
strawberry_name: str,
7777
model: type[DomainModel],
7878
) -> type[StrawberryTypeFromPydantic[DomainModel]]:
79+
from strawberry import UNSET
7980
from strawberry.federation.schema_directives import Key
80-
from strawberry.unset import UNSET
8181

8282
federation_key_directives = [Key(fields="subscriptionInstanceId", resolvable=UNSET)]
8383

@@ -92,7 +92,7 @@ def create_block_strawberry_type(
9292
description=f"{strawberry_name} Type",
9393
use_pydantic_alias=USE_PYDANTIC_ALIAS_MODEL_MAPPING.get(strawberry_name, True),
9494
)
95-
return type(strawberry_name, (pydantic_wrapper(base_type),), {})
95+
return pydantic_wrapper(base_type)
9696

9797

9898
def create_subscription_strawberry_type(strawberry_name: str, model: type[DomainModel], interface: type) -> type:
@@ -106,7 +106,7 @@ def create_subscription_strawberry_type(strawberry_name: str, model: type[Domain
106106
description=f"{strawberry_name} Type",
107107
use_pydantic_alias=USE_PYDANTIC_ALIAS_MODEL_MAPPING.get(strawberry_name, True),
108108
)
109-
return type(strawberry_name, (pydantic_wrapper(base_type),), {})
109+
return pydantic_wrapper(base_type)
110110

111111

112112
def add_class_to_strawberry(
@@ -146,6 +146,7 @@ def register_domain_models(
146146
for product_type in SUBSCRIPTION_MODEL_REGISTRY.values()
147147
if product_type.__base_type__
148148
}
149+
149150
for key, product_type in products.items():
150151
add_class_to_strawberry(
151152
interface=interface,

orchestrator/graphql/schemas/process.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from typing import TYPE_CHECKING, Annotated
22

33
import strawberry
4+
from strawberry import UNSET
45
from strawberry.federation.schema_directives import Key
56
from strawberry.scalars import JSON
6-
from strawberry.unset import UNSET
77

88
from oauth2_lib.strawberry import authenticated_field
99
from orchestrator.db import ProcessTable, ProductTable, db

orchestrator/graphql/schemas/product.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from typing import TYPE_CHECKING, Annotated
22

33
import strawberry
4+
from strawberry import UNSET
45
from strawberry.federation.schema_directives import Key
5-
from strawberry.unset import UNSET
66

77
from oauth2_lib.strawberry import authenticated_field
88
from orchestrator.db import ProductTable

orchestrator/graphql/schemas/strawberry_pydantic_patch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import strawberry
44
from strawberry.experimental.pydantic.conversion import _convert_from_pydantic_to_strawberry_type
5-
from strawberry.field import StrawberryField
5+
from strawberry.types.field import StrawberryField
66

77
# Vendored convert_pydantic_model_to_strawberry_class from
88
# https://github.com/strawberry-graphql/strawberry/blob/d721eb33176cfe22be5e47f5bf2c21a4a022a6d6/strawberry/experimental/pydantic/conversion.py

orchestrator/graphql/schemas/subscription.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import strawberry
66
from pydantic import BaseModel
77
from sqlalchemy import select
8+
from strawberry import UNSET
89
from strawberry.federation.schema_directives import Key
9-
from strawberry.unset import UNSET
1010

1111
from oauth2_lib.strawberry import authenticated_field
1212
from orchestrator.db import FixedInputTable, ProductTable, SubscriptionTable, db

orchestrator/graphql/types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818

1919
import strawberry
2020
from graphql import GraphQLError
21-
from strawberry.custom_scalar import ScalarDefinition, ScalarWrapper
2221
from strawberry.dataloader import DataLoader
2322
from strawberry.experimental.pydantic.conversion_types import StrawberryTypeFromPydantic
2423
from strawberry.scalars import JSON
2524
from strawberry.types import Info
2625
from strawberry.types.info import RootValueType
26+
from strawberry.types.scalar import ScalarDefinition, ScalarWrapper
2727

2828
from nwastdlib.vlans import VlanRanges
2929
from oauth2_lib.fastapi import AuthManager

orchestrator/graphql/utils/override_class.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from strawberry.field import StrawberryField
1+
from strawberry.types.field import StrawberryField
22

33

44
def override_class(strawberry_class: type, fields: list[StrawberryField]) -> type:

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ dependencies = [
6060
"structlog",
6161
"typer==0.12.5",
6262
"uvicorn[standard]~=0.32.0",
63-
"nwa-stdlib~=1.7.3",
63+
"nwa-stdlib~=1.8.0",
6464
"oauth2-lib~=2.3.0",
6565
"tabulate==0.9.0",
66-
"strawberry-graphql==0.232.2",
66+
"strawberry-graphql>=0.246.2",
6767
"pydantic-forms==1.1.0",
6868
]
6969

0 commit comments

Comments
 (0)