-
-
Notifications
You must be signed in to change notification settings - Fork 593
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Optional union type definition ignores annotation metadata added with typing.Annotated
Describe the Bug
Following the documentation create sample definition:
import strawberry
from typing import Annotated
from fastapi import FastAPI
from strawberry.fastapi import GraphQLRouter
@strawberry.type
class A:
a: str
@strawberry.type
class B:
b: str
@strawberry.type
class Query:
u: Annotated[A | B | None, strawberry.union("C")]
schema = strawberry.Schema(query=Query)
app = FastAPI()
graphql_app = GraphQLRouter(schema)
app.include_router(graphql_app, prefix="/graphql")
Checking schema introspection in gql client will show u as "AB" type instead of "C".
Now remove None from annotation and check again - you'll see correct definition.
System Information
- Operating system: bookworm
- Python version: 3.13
- Strawberry version (if applicable): 0.282.0
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working