Hello folks
Since recently, graphql unknown scalars are compiled into ts unknown type. This makes sense, but at the same time introduces a lot of annoying casts in the code whenever one needs to use one of these fields...
Is there a way to configure which ts type a given scalar should be compiled into ?
You can use the customScalars feature of the relay compiler (either in the CLI or using the relay-config npm package) to define this. As an example here's a snippet of the config we use (in relay.config.js)
customScalars: {
BigInt: 'String',
DateTime: 'String',
LocalDate: 'String',
LocalDateTime: 'String',
Percent: 'Int',
Probability: 'Int',
},
Note that you must map the scalars to known graphql scalar types.
Thanks, exactly what I was looking for 馃憤
Most helpful comment
You can use the
customScalarsfeature of the relay compiler (either in the CLI or using therelay-confignpm package) to define this. As an example here's a snippet of the config we use (in relay.config.js)Note that you must map the scalars to known graphql scalar types.