shurcooL / graphql

Package graphql provides a GraphQL client implementation.
MIT License
709 stars 282 forks source link

Automatically determine scalar types. #4

Closed dmitshur closed 7 years ago

dmitshur commented 7 years ago

Previously, I didn't know of a good way to determine scalar types automatically, so the interim solution was to require the user to specify the scalar types explicitly.

This has the downside that it makes it not possible to substitute GraphQL-specific types with equivalent other types when unmarshaling results of a query. E.g., one would have to always use githubql.DateTime and couldn't use the standard time.Time.

I've now discovered a way to determine scalar types automatically: they are structs that implement json.Unmarshaler interface.

This commit implements the change to automatic scalar type detection, and removes the no longer necessary explicit passing of scalars.