Currently implementing the following class:
@strawberry.input
class User:
fname: str = Field(..., title='First Name')
mname: str | None = Field(None, title='Middle Name')
lname: str = Field(..., title='Last Name')
age: int = Field(..., title='Servicable age', gt=21, lt=65)
email: str
location: Coordinates
interests: List[str] | None
Adding Queries and Mutations should be straightforward from an input type
Users: List[User] = []
@strawberry.type
class Query:
@strawberry.field
def all_users(self) -> List[User]:
return Users
@strawberry.type
class Mutation:
@strawberry.mutation
def add_user(self, user: User) -> User:
Users.append(user)
return user
However, this returns the following error
TypeError: Query fields cannot be resolved. Field type must be an output type.
To solve this. I would need to not only create a new instance of User, but a second list. I think this is a needed improvement.
Since output types contain less restrictions than an input type as mentioned here.
We should be able to do the following:
@strawberry.input ----> @strawberry.type # Should be allowed.
@strawberry.type ----> @strawberry.input # Should NOT be allowed
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