Open schickling opened 6 years ago
Looks like this might land soon: https://github.com/facebook/graphql/pull/521
Is there any advice for what to do in the meantime? I'm not sure where to go next.
Does this mean my app has to serialize to / deserialize from string manually in the resolvers for now or is there some other workaround?
[EDIT:] Defining your own resolvers coupled with resolvers as any
is your friend.
Given that this doesn't seem to have moved forward yet, as an interim measure I'm wondering how useful it would be to have options similar to apollo client:codegen
's passthroughCustomScalars
and customScalarsPrefix
? In the case of TypeScript at least, it's then easy enough to declare
a global type definition for the scalar type name (with the option of attaching the prefix to avoid clashes with other global names). This approach has worked successfully for me with the output of apollo client:codegen
. Worth creating a PR for?
While GraphQL SDL doesn't yet support an expressive enough syntax for scalar value definitions, there is some mapping needed for custom scalars (e.g.
DateTime
in GraphQL SDL should map tostring
in TypeScript). This mapping is depending on the application's implementation and therefore needs to be configured in thegraphqlgen.yml
.Here is a proposal for the configuration format:
Additionally, we should extend the validation logic of
graphqlgen
(similar to how types <> models are validated) to always require a mapping for custom scalars.