-
-
Notifications
You must be signed in to change notification settings - Fork 593
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the Bug
When using SkipJsonSchema
annotation in a type union, the schema generation fails with Type
str cannot be used in a GraphQL Union
Minimal replicating example:
import strawberry
from pydantic import BaseModel
from pydantic.json_schema import SkipJsonSchema
class ModelA(BaseModel):
field_a: str | SkipJsonSchema[None] = None
@strawberry.experimental.pydantic.type(
model=ModelA,
all_fields=True,
)
class TypeA:
pass
@strawberry.type
class Query:
@strawberry.field
def example(self) -> TypeA:
return TypeA()
schema = strawberry.Schema(query=Query)
print(schema.as_str())
This pattern is useful for denoting the field as not required but without explicit type: none
in JSON schema generated from Pydantic
System Information
- Operating system: Ubuntu
- Python version: 3.13
- Strawberry version (if applicable): 0.282.0
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working