When using Chain directly, the decodeScalarsInResponse function is called by Thunder / ThunderDescription so that scalars are applied to the response, aligning the actual values with the types expressed by InputType<GraphQLTypes[R], Z, UnionOverrideKeys<SCLR, OVERRIDESCLR>>. That is, so that the values are decoded and match the expected types.
This aligns with the documentation examples:
const listCardsAndDraw = await chain('query', {
scalars: {
JSON: {
encode: (e: unknown) => JSON.stringify(e),
decode: (e: unknown) => JSON.parse(e as string),
},
Datetime: {
decode: (e: unknown) => new Date(e as string),
encode: (e: unknown) => (e as Date).toISOString(),
},
},
})({
drawCard: {
info: true,
},
});
that implies that the (eg) DateTime scalar's decode function to have been called.
The same is not true when using useTypedQuery. The scalar decoder functions are not run. However, the types imply that they are. This means that the actual values may not align with the types.
Should the decoders be run when using useTypedQuery?
When using
Chaindirectly, thedecodeScalarsInResponsefunction is called byThunder/ThunderDescriptionso that scalars are applied to the response, aligning the actual values with the types expressed byInputType<GraphQLTypes[R], Z, UnionOverrideKeys<SCLR, OVERRIDESCLR>>. That is, so that the values are decoded and match the expected types.This aligns with the documentation examples:
that implies that the (eg)
DateTimescalar's decode function to have been called.The same is not true when using
useTypedQuery. The scalar decoder functions are not run. However, the types imply that they are. This means that the actual values may not align with the types.Should the decoders be run when using
useTypedQuery?