Skip to content

Use Boolean instead of Bool. #223

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 1 commit 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
6 changes: 3 additions & 3 deletions src/graphql_builtins.erl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ standard_types_inject() ->
id => 'Int',
description => <<"Integers in the range ±2^53. The GraphQL standard only allows for 32-bit signed integers, but we can support up to the larger range."/utf8>> }},
Bool = {scalar, #{
id => 'Bool',
id => 'Boolean',
description => <<"Boolean values, either given as the *true* and *false* values of JSON, or as the strings \"true\" and \"false\"."/utf8>> }},
ID = {scalar, #{
id => 'ID',
Expand All @@ -36,7 +36,7 @@ standard_directives_inject() ->
locations => ['FIELD', 'FRAGMENT_SPREAD', 'INLINE_FRAGMENT'],
resolve_module => graphql_directives,
args => #{ <<"if">> => #{
type => 'Bool',
type => 'Boolean',
default => false,
description => <<"Wether or not the item should be skipped">> }}
}},
Expand All @@ -46,7 +46,7 @@ standard_directives_inject() ->
locations => ['FIELD', 'FRAGMENT_SPREAD', 'INLINE_FRAGMENT'],
resolve_module => graphql_directives,
args => #{ <<"if">> => #{
type => 'Bool',
type => 'Boolean',
default => false,
description => <<"Wether or not the item should be included">> }}
}},
Expand Down
16 changes: 8 additions & 8 deletions src/graphql_introspection.erl
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ inject() ->
description => "The fields in the object/interface",
args => #{
includeDeprecated => #{
type => 'Bool',
type => 'Boolean',
description => "Should deprecated fields be included or not",
default => false
}}},
Expand All @@ -282,7 +282,7 @@ inject() ->
description => "The possible values of an Enum",
args => #{
includeDeprecated => #{
type => 'Bool',
type => 'Boolean',
description => "Should deprecated fields be included or not",
default => false
}}},
Expand Down Expand Up @@ -313,7 +313,7 @@ inject() ->
type => '__Type',
description => "The type of the given field" },
isDeprecated => #{
type => 'Bool!',
type => 'Boolean!',
description => "True if the field is deprecated, false otherwise" },
deprecationReason => #{
type => 'String',
Expand Down Expand Up @@ -349,7 +349,7 @@ inject() ->
type => 'String',
description => "The description of the value" },
isDeprecated => #{
type => 'Bool!',
type => 'Boolean!',
description => "True if this is a deprecated field" },
deprecationReason => #{
type => 'String',
Expand Down Expand Up @@ -384,13 +384,13 @@ inject() ->
type => {non_null, ['__DirectiveLocation!']},
description => "Where the directives can be used" },
onOperation => #{
type => 'Bool',
type => 'Boolean',
description => "Not documented yet" },
onFragment => #{
type => 'Bool',
type => 'Boolean',
description => "Not documented yet" },
onField => #{
type => 'Bool',
type => 'Boolean',
description => "Not documented yet" },
args => #{
type => {non_null, ['__InputValue!']},
Expand Down Expand Up @@ -430,7 +430,7 @@ directive(Kind) ->
{<<"skip">>,
<<"exclude a selection on a conditional variable">>}
end,
{ok, Bool} = render_type(<<"Bool">>),
{ok, Bool} = render_type(<<"Boolean">>),

#{
<<"name">> => Name,
Expand Down
8 changes: 4 additions & 4 deletions src/graphql_parser.yrl
Original file line number Diff line number Diff line change
Expand Up @@ -453,10 +453,10 @@ g_ty({name, _, <<"Int">>}) -> {scalar, <<"Int">>};
g_ty({name, _, <<"int">>}) -> {scalar, <<"Int">>};
g_ty({name, _, <<"float">>}) -> {scalar, <<"Float">>};
g_ty({name, _, <<"Float">>}) -> {scalar, <<"Float">>};
g_ty({name, _, <<"bool">>}) -> {scalar, <<"Bool">>};
g_ty({name, _, <<"Bool">>}) -> {scalar, <<"Bool">>};
g_ty({name, _, <<"boolean">>}) -> {scalar, <<"Bool">>};
g_ty({name, _, <<"Boolean">>}) -> {scalar, <<"Bool">>};
g_ty({name, _, <<"bool">>}) -> {scalar, <<"Boolean">>};
g_ty({name, _, <<"Bool">>}) -> {scalar, <<"Boolean">>};
g_ty({name, _, <<"boolean">>}) -> {scalar, <<"Boolean">>};
g_ty({name, _, <<"Boolean">>}) -> {scalar, <<"Boolean">>};
g_ty({name, _, <<"id">>}) -> {scalar, <<"ID">>};
g_ty({name, _, <<"Id">>}) -> {scalar, <<"ID">>};
g_ty({name, _, <<"ID">>}) -> {scalar, <<"ID">>};
Expand Down
12 changes: 6 additions & 6 deletions src/graphql_scalar_bool_coerce.erl
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ input(_, true) -> {ok, true};
input(_, false) -> {ok, false};
input(_, _) -> {error, not_bool}.

output(<<"Bool">>, true) -> {ok, true};
output(<<"Bool">>, <<"true">>) -> {ok, true};
output(<<"Bool">>, false) -> {ok, false};
output(<<"Bool">>, <<"false">>) -> {ok, false};
output(<<"Bool">>, 0) -> {ok, false};
output(<<"Bool">>, X) when is_integer(X) -> {ok, true};
output(<<"Boolean">>, true) -> {ok, true};
output(<<"Boolean">>, <<"true">>) -> {ok, true};
output(<<"Boolean">>, false) -> {ok, false};
output(<<"Boolean">>, <<"false">>) -> {ok, false};
output(<<"Boolean">>, 0) -> {ok, false};
output(<<"Boolean">>, X) when is_integer(X) -> {ok, true};
output(_,_) -> {error, not_coercible}.
2 changes: 1 addition & 1 deletion src/graphql_schema_canonicalize.erl
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ scalar_resolve(#{ resolve_module := ModuleResolver })

scalar_resolve(#{ id := 'ID'}) -> graphql_scalar_binary_coerce;
scalar_resolve(#{ id := 'String'}) -> graphql_scalar_binary_coerce;
scalar_resolve(#{ id := 'Bool'}) -> graphql_scalar_bool_coerce;
scalar_resolve(#{ id := 'Boolean'}) -> graphql_scalar_bool_coerce;
scalar_resolve(#{ id := 'Int'}) -> graphql_scalar_integer_coerce;
scalar_resolve(#{ id := 'Float'}) -> graphql_scalar_float_coerce;
scalar_resolve(_) -> graphql_enum_coerce.
Expand Down
2 changes: 1 addition & 1 deletion test/blog.erl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ inject() ->
type => 'ID!',
description => "The ID of the article" },
isPublished => #{
type => 'Bool',
type => 'Boolean',
description => "True is the article has been published"},
author => #{
type => 'Author',
Expand Down
2 changes: 1 addition & 1 deletion test/dungeon_SUITE_data/dungeon_schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type Monster implements Node {
hitpoints : Int!
inventory : [Thing]
hp : Int!
mood(fail: Bool @private) : Mood @private
mood(fail: Boolean @private) : Mood @private
plushFactor : Float!
spikyness : Float
stats(
Expand Down
4 changes: 2 additions & 2 deletions test/dungeon_SUITE_data/query.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ query GoblinQuery($id : Id! = "bW9uc3Rlcjox") {
}
}

query GoblinQueryDirectives($id : Id! = "bW9uc3Rlcjox", $fat : Bool!) {
query GoblinQueryDirectives($id : Id! = "bW9uc3Rlcjox", $fat : Boolean!) {
goblin: monster(id: $id) {
id
name @include(if: $fat)
hitpoints
}
}

query GoblinQueryDirectivesInline($id : Id! = "bW9uc3Rlcjox", $fat : Bool!) {
query GoblinQueryDirectivesInline($id : Id! = "bW9uc3Rlcjox", $fat : Boolean!) {
goblin: monster(id: $id) {
id
... @include(if: $fat) {
Expand Down
24 changes: 12 additions & 12 deletions test/schema_pet.erl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ inject() ->
description => ["Input Object for testing uniqueness"],
fields => #{
field => #{
type => 'Bool!',
type => 'Boolean!',
description => "A bool field" }}}},
ok = graphql:insert_schema_definition(TestField),
DogCommand = {enum, #{
Expand Down Expand Up @@ -46,19 +46,19 @@ inject() ->
nickname => #{ type => 'String', description => "Nickname of the dog, if any" },
barkVolume => #{ type => 'Int', description => "Bark volume in dB" },
doesKnowCommand => #{
type => 'Bool!',
type => 'Boolean!',
description => "Does the dog know a specific command?",
args => #{
dogCommand => #{
type => 'DogCommand!',
description => "The dog command we want to ask for" }}
},
isHouseTrained => #{
type => 'Bool!',
type => 'Boolean!',
description => "Is the dog house trained",
args => #{
atOtherHomes => #{
type => 'Bool',
type => 'Boolean',
description => "Is the query including other homes?" }}
},
owner => #{
Expand Down Expand Up @@ -108,7 +108,7 @@ inject() ->
nickname => #{
type => 'String', description => "The nickname of the cat, if any" },
doesKnowCommand => #{
type => 'Bool!',
type => 'Boolean!',
description => "Does the cat know of a specific command type",
args => #{
catCommand => #{
Expand Down Expand Up @@ -157,10 +157,10 @@ inject() ->
y => #{ type => 'Int!', description => "The Y arg"}
}},
booleanArgField => #{
type => 'Bool',
type => 'Boolean',
description => "Test of a boolean arg field",
args => #{
booleanArg => #{ type => 'Bool', description => "The Bool Arg" }
booleanArg => #{ type => 'Boolean', description => "The Bool Arg" }
}},
floatArgField => #{
type => 'Float',
Expand All @@ -175,18 +175,18 @@ inject() ->
intArg => #{type => 'Int', description => "The Int Arg" }
}},
nonNullBooleanArgField => #{
type => 'Bool!',
type => 'Boolean!',
description => "Test of non-null args",
args => #{
nonNullBooleanArg => #{
type => 'Bool!',
type => 'Boolean!',
description => "The non-null bool arg" }
}},
booleanListArgField => #{
type => ['Bool'],
type => ['Boolean'],
description => "Test lists of bools",
args => #{
booleanListArg => #{ type => {non_null, ['Bool']}, description => "The list of bools"}
booleanListArg => #{ type => {non_null, ['Boolean']}, description => "The list of bools"}
}}
}}},
ok = graphql:insert_schema_definition(Arguments),
Expand All @@ -198,7 +198,7 @@ inject() ->
fields => #{
arguments => #{ type => 'Arguments', description => "More complicated Argument cases" },
field =>
#{ type => 'Bool',
#{ type => 'Boolean',
description => "Test for input object uniqueness",
args => #{
arg => #{
Expand Down