strawberry-graphql/strawberry

Unable to hide field in derived type

Opened this issue · 1 comments

Based on Discord discussion here: https://discord.com/channels/689806334337482765/1225406859926704188

Basically I have a type which derives from another. I want to exclude a field in my derived type. Marking as strawberry.Private in the derived class doesn't do anything.

@strawberry.type
class Foo:
    value: int = strawberry.field(description="foo")

@strawberry.type
class Bar(Foo):
    value: strawberry.Private[int]

I would expect the value field not to be exposed on type Bar in the schema.

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

Right now the only way of achieving this is to remove the field from Bar.__strawberry_definition__.fields before the Schema is created. That was suggested in the Discord discussion.