There are good possible use cases for allowing the usage of Optional[strawberry.auto]
when using pydantic support.
I am using (and loving) the strawberry pydantic support. I presently have the use case for creating an input type based on a pydantic model, but I want all of the fields to be optional. For example:
class User(BaseModel):
name: str
age: int
# I'd like to do this, but it does not work
@strawberry.experimental.pydantic.input(model=User)
class UserInput:
name: Optional[strawberry.auto]
age: Optional[strawberry.auto]
The reason I want to do this, is to allow the API user to provide any of the fields in UserInput
, and update the underlying user only for the fields that were present.
The error that running this code gave me is: TypeError: Union[arg, ...]: each arg must be a type. Got <auto>.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too