graphql-request icon indicating copy to clipboard operation
graphql-request copied to clipboard

Custom parser for custom scalars

Open zhammer opened this issue 6 years ago • 4 comments

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.

zhammer avatar Oct 23 '18 17:10 zhammer

Handling of special floating point values is another usecase

olejorgenb avatar May 28 '20 10:05 olejorgenb

any news on this? Is this in the works still?

sbousamra avatar Oct 06 '21 16:10 sbousamra

@zhammer were you able to figure it out?

aryzing avatar Sep 27 '22 23:09 aryzing

would also like to know

dan-turner avatar Sep 30 '22 23:09 dan-turner

any workarounds?

cris-santos avatar Dec 16 '22 19:12 cris-santos

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

tomfa avatar Dec 17 '22 21:12 tomfa

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 : )

co-sic avatar Jul 07 '23 15:07 co-sic

This will be solved by https://github.com/jasonkuhrt/graphql-request/pull/672

jasonkuhrt avatar Feb 29 '24 02:02 jasonkuhrt

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

jasonkuhrt avatar Mar 30 '24 16:03 jasonkuhrt