jlouis / graphql-erlang

GraphQL implementation in Erlang.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Jun2018 clarify: Make it clear that field result coercion should throw errors before data loss (#434)

jlouis opened this issue · comments

In this task, we have to go over the default coercers and make sure they coerce as the spec says. In particular, coercers may not throw away information but should fail if that would be the case. I.e.,

  • We can use 1.0 for an integer value insofar that can be converted to 1
  • We cannot use 1.2 for an integer value since truncation would throw away information
  • The int type is a 32-bit 2-complement integer value, so we should not result-coerce smaller/larger values here since the client might not be ready to handle that.

We should also create tests for these ones, so we make sure we handle them correctly. So the task is a bit more involved than simply changing the code.