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

Subclass built-in scalars without creating new GraphQL type #1553

Open
RJPercival opened this issue Jun 5, 2024 · 0 comments
Open

Subclass built-in scalars without creating new GraphQL type #1553

RJPercival opened this issue Jun 5, 2024 · 0 comments

Comments

@RJPercival
Copy link

Is your feature request related to a problem? Please describe.
I'd like to be able to customise serialization logic for some scalars, e.g. a NormalizedDecimal that inherits from Decimal but calls .normalize() on the value during serialization. Unfortunately, this results in the GraphQL schema containing a new NormalizedDecimal scalar that clients don't know how to deserialize.

Describe the solution you'd like
I'd like the type to still be that of the superclass in the schema, e.g. Decimal in the above example.

Describe alternatives you've considered
I've tried overriding Scalar.get_type() to return the type of the superclass, but then the subclass doesn't function as intended, e.g. the custom serialization logic doesn't get invoked. I've also tried setting Meta.name to that of the superclass, but that also results in the custom serialization logic not being invoked.

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

No branches or pull requests

1 participant