Skip to content

Commit

Permalink
refactor: strawberry.union is deprecated, use Annotated instead (#347)
Browse files Browse the repository at this point in the history
Fix #343
  • Loading branch information
bellini666 authored Aug 28, 2023
1 parent c88887f commit db978aa
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions strawberry_django/mutations/fields.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

import inspect
from typing import TYPE_CHECKING, Any, Iterable
from typing import TYPE_CHECKING, Any, Iterable, Union

import strawberry
from django.core.exceptions import (
Expand All @@ -15,6 +15,7 @@
from strawberry.annotation import StrawberryAnnotation
from strawberry.field import UNRESOLVED
from strawberry.utils.str_converters import capitalize_first, to_camel_case
from typing_extensions import Annotated

from strawberry_django.arguments import argument
from strawberry_django.fields.field import (
Expand Down Expand Up @@ -125,7 +126,10 @@ def resolve_type(
types_ = (*types_, OperationInfo)

name = capitalize_first(to_camel_case(self.python_name))
resolved = strawberry.union(f"{name}Payload", types_)
resolved = Annotated[
Union[types_], # type: ignore
strawberry.union(f"{name}Payload"),
]
self.type_annotation = StrawberryAnnotation(
resolved,
namespace=getattr(self.type_annotation, "namespace", None),
Expand Down

0 comments on commit db978aa

Please sign in to comment.