Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Excluding a field from a type by making it private #3539

Open
Eraldo opened this issue Jun 14, 2024 · 4 comments
Open

feat: Excluding a field from a type by making it private #3539

Eraldo opened this issue Jun 14, 2024 · 4 comments

Comments

@Eraldo
Copy link

Eraldo commented Jun 14, 2024

Describe the Bug/Feature

How to exclude a field from a type?

@strawberry.type(name="File")
class FileType(DjangoFileType):
    path: strawberry.Private[str]

Current: The path field still shows up in the schema.
Expected: No more path field exposed.

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
@brunodantas
Copy link
Contributor

Hmm that's already a feature. Is it not working for Django types?

https://play.strawberry.rocks/?gist=5a61a5784811fa8f38d67f259ecde617

@patrick91
Copy link
Member

@brunodantas I think the issue is with overriding another type's file (DjangoFileType in this case)

@erikwrede
Copy link
Member

erikwrede commented Jul 7, 2024

For me this seems to be a strawberry-django issue. The django orm extension should respect field overrides when building the fields dict. Should we move it over? @bellini666 @patrick91

@bellini666
Copy link
Member

For me this seems to be a strawberry-django issue. The django orm extension should respect field overrides when building the fields dict. Should we move it over? @bellini666 @patrick91

Actually, I think it is what @patrick91 said.

That DjangoFileType is a general @strawberry.type inside strawberry-django. Here is the reproduction in the playground: https://play.strawberry.rocks/?gist=ef717257ca7a2db9085bbe1a44da5192

In this case, marking bar as Private in BarType should exclude it from the schema, while still showing on FooType in that example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants