helios1138 / graphql-typed-client

A tool that generates a strongly typed client library for any GraphQL endpoint. The client allows writing GraphQL queries as plain JS objects (with type safety, awesome code completion experience, custom scalar type mapping, type guards and more)
MIT License
212 stars 18 forks source link

Question: Does the type generation work for custom scalars? #1

Closed capaj closed 5 years ago

capaj commented 5 years ago

We use a lot of custom scalars from https://github.com/capaj/graphql-scalars, would the type def generation work even for those?

helios1138 commented 5 years ago

custom scalar types are generated as aliases to any (since we can't know anything about them)

export type DateTime = any

and then these types are used as field types, so you'll still have readable type names in code completion

capaj commented 5 years ago

thanks. It would be nice to be able to define a custom scalar and be able to define how it should deserialize. Like for example if I had DateTime, I could define it to deserialize into a moment instance instead of just being a string.

helios1138 commented 5 years ago

@capaj good idea, I will put it on the roadmap!

capaj commented 5 years ago

I'll create that as a separate issue.