Swift client: scalar turned into a string

with apollo-ios 0.50.0, when I have a field of type scalar(decimal), in JSONStandardTypeConversions.swift it is attempted to be turned into a string. But since it is neither a string nor an int, it fails. Now, my patch suggestion is to test similarly to an Int if perhaps it’s a Double, then do the same. Or if iOS 15 is around, use .formatted() on a Decimal.

But, why does the client want to turn Scalar into a String in the first place? And why are the only supported scalars String and Int?



Hi Niklas -

A custom scalar is turned into a String by default and without the correct configuration it results in errors like the one you’re getting.

Are you using passthroughCustomScalars in your configuration of code generation? If not we have documentation detailing how to work with custom scalars that should help. There is also a playground working example and a previous issue with a user that experienced a similar issue to you.

It sounds like your code generation config might need a little tweaking but there is no reason it shouldn’t ultimately work.