Skip to content

Ensure that values of scalars String and Int have the correct type #218

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/graphql_scalar_binary_coerce.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

-export([input/2, output/2]).

input(_, X) -> {ok, X}.
input(_, B) when is_binary(B) -> {ok, B};
input(_, _) -> {error, not_string}.

%% According to the specification, Jun2018, we should
%% accept coercion as long as we are not "loosing information"
Expand Down
3 changes: 2 additions & 1 deletion src/graphql_scalar_integer_coerce.erl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ input(Ty, X) when is_float(X) ->
end;
input(_, X) when is_integer(X), X > ?MAX_INT -> {error, not_int32_value};
input(_, X) when is_integer(X), X < ?MIN_INT -> {error, not_int32_value};
input(_, X) -> {ok, X}.
input(_, X) when is_integer(X) -> {ok, X};
input(_, _X) -> {error, not_integer}.

output(<<"Int">>, I) when is_integer(I) ->
if
Expand Down