Skip to content

Commit 9345ea0

Browse files
committed
add support for int values in float type
1 parent 586de0a commit 9345ea0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Types/GraphQLFloat.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class GraphQLFloat extends GraphQLScalarType
2020
*/
2121
public function serialize($outputValue): ?float
2222
{
23-
if (!is_float($outputValue) and $outputValue !== null) {
23+
if (!is_float($outputValue) and !is_int($outputValue) and $outputValue !== null) {
2424
throw new GraphQLError(
2525
"Value \"$outputValue\" is not of type \"{$this->getName()}\"."
2626
);
@@ -60,7 +60,7 @@ public function parseLiteral($valueNode, $variables): float
6060
*/
6161
public function parseValue($value): ?float
6262
{
63-
if (!is_float($value) and $value !== null) {
63+
if (!is_float($value) and !is_int($value) and $value !== null) {
6464
throw new GraphQLError(
6565
"Value \"$value\" is not of type \"{$this->getName()}\"."
6666
);

0 commit comments

Comments
 (0)