Skip to content

strawberry.ID as as newtype, or not #1164

Open

Description

Strawberry currently uses a newtype for ID (from str).

I'm not very familiar with graphql but I can see the reasoning behind this choice: IDs are supposed to be opaque values that you don't look inside of, but which are serialised as strings.

The drawback of a newtype is that it causes a lot of manual casting when using Strawberry if you have typechecking turned on. For example with a UUID, you must do strawberry.ID(str(a_uuid)). If you have typing turned off, passing a_uuid directly works fine.

Perhaps there is some way to make this easier?

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions