-
-
Notifications
You must be signed in to change notification settings - Fork 36
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
Allow custom serializer/deserializer for custom scalars #57
Comments
graphql-typed-client has something like this: https://github.com/helios1138/graphql-typed-client#custom-scalar-type-mapping |
Was looking for this tonight for graphql-nexus/nexus-prisma#56 (comment). |
@remorses also, is this feature on the roadmap? |
@remorses it would be really really great to have it |
fwiw I am working on making |
Using the CLI option
--scalar
, it is possible to set the Typescript type of custom scalars. However, that only modifies the generated interfaces. The actual value of the scalar is unchanged.For easier working with the scalar values after a query/subscription, they may need to be deserialized differently than the default. The same with a mutation: the scalars may need to be serialized differently than the default. While it is possible to do this manually, it would be much easier and less error-prone if this could be done by passing custom serializer/deserializer functions.
For example, a custom scalar could be "Date". The actual values will be transferred as strings. For easier usage, it would be much better if they were deserialized after a query into a Javascript Date or Luxon DateTime. For a mutation, the Date/DateTime would probably need to be serialized as string again (instead of hoping the default serialization will work).
The text was updated successfully, but these errors were encountered: