strawberry-graphql/strawberry

Descriptions don't work with pydantic decorators

Opened this issue · 2 comments

Describe the Bug

Works as expected with regular @strawberry.input decorator

@strawberry.input
class User:
    id: str = strawberry.field(description="Id of the user")
    name: str | None = strawberry.field(description="Name of the user", deprecation_reason="No longer used")
input User {
  """Id of the user"""
  id: String!    

  """Name of the user"""
  name: String @deprecated(reason: "No longer used")
}

Doesn't work as expected with @strawberry.experimental.pydantic.input decorator

class UserPyd(BaseModel):
  id: str
  name: str | None

@strawberry.experimental.pydantic.input(model=UserPyd)
class User:
    id: str = strawberry.field(description="Id of the user")
    name: str | None = strawberry.field(description="Name of the user", deprecation_reason="No longer used")
input User {
  id: String!
  name: String @deprecated(reason: "No longer used")
}

System Information

  • Operating system: Ubuntu
  • Strawberry version (if applicable): 0.227.3

Additional Context

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar

As a sanity check, does removing the pass change anything? It definitely shouldn't but, just in case I suppose...

@strawberry.experimental.pydantic.input(model=UserPyd)
class User:
    id: str = strawberry.field(description="Id of the user")
    name: str | None = strawberry.field(description="Name of the user", deprecation_reason="No longer used")
    pass

Thanks for catching the typo! Unfortunately doesn't impact the bug