Open dillonkearns opened 6 years ago
There is now an active pull request for this change: https://github.com/facebook/graphql/pull/521.
It looks like, despite many users requesting they consider otherwise, ofType
must be either one of the built in scalars or null
:
Serialize as type A custom scalar may provide a built-in scalar type which describes how the custom scalar is serialized. This provides more information for how execution responses are query variable inputs are coerced. If provided, this built-in scalar can be used both for improved validation results and stricter guarantees during execution. While a custom scalar type is not required to provide a serialize as type, if one is provided it must be one of the built-in scalar types (
Int
,Float
,String
,Boolean
,ID
).
That means that it cannot be serialized as a "compound" type like a list or an object.
As discussed in #37, the Graphql spec is actively working on a proposal to have a "serializes as" field for scalars in the introspection schema. This would allow this library's generated code to know whether to expect the scalar response to be sending back a Float or Int, etc., and would allow it to send that type when arguments of a given scalar type are passed to the server.
Currently there's nothing to be done on the Elm side because no servers implement this. But I'd like to add this functionality as soon as an implementation is available, and I'd like to track the progress of server implementations here. @xtian is considering contributing to or requesting an Elixir implementation.