Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use intelligent base primitive for scalars #39

Open
dillonkearns opened this issue Feb 8, 2018 · 1 comment
Open

Use intelligent base primitive for scalars #39

dillonkearns opened this issue Feb 8, 2018 · 1 comment

Comments

@dillonkearns
Copy link
Owner

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.

@dillonkearns
Copy link
Owner Author

dillonkearns commented Nov 27, 2018

There is now an active pull request for this change: graphql/graphql-spec#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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant