graphql-request
graphql-request copied to clipboard
Custom parser for custom scalars
Is there support for using custom parser for schema-defined scalars? Common use case would be parsing Date
scalar fields defined in a schema to date objects.
Handling of special floating point values is another usecase
any news on this? Is this in the works still?
@zhammer were you able to figure it out?
would also like to know
any workarounds?
Here's our workaround for parsing DateTime
type (from graphql-scalars) to Date
and back. It works for our use case, but is less than ideal.
https://gist.github.com/tomfa/849adb5b7037b9b23ba59bf0d73c801b
I created a small plugin you can use with graphql-request to transform custom scalars: https://github.com/gastromatic/graphql-transform-scalars I tried already different scenarios in our project and it works well (also for union and interface types). I will add some tests in the coming days. Feedback welcome : )
This will be solved by https://github.com/jasonkuhrt/graphql-request/pull/672
Actually this was not solved by the PR. This issue is now being tracked for the TS Client here: https://github.com/jasonkuhrt/graphql-request/issues/744