graphql-spec
graphql-spec copied to clipboard
Is there a reason graphql floats do not support Infinity and NaN?
Is there a reason graphql floats do not support Infinity and NaN? Would a proposal to add infinity and/or NaN be seriously considered?
Those values are hard to serialise, e.g. they don’t serialise in JSON. GraphQL aims for maximal compatibility and this excludes these kinds of things. However you could create your own custom scalar e.g. IEEE754Float which maybe encodes these special values as a string?
So if JSON supported serializing +/-Infinity and NaN then this would be something that could be considered?
https://stackoverflow.com/questions/1423081/json-left-out-infinity-and-nan-json-status-in-ecmascript has some insight into Infinity and NaN in JSON.