Skip to content

Commit 586de0a

Browse files
committed
fix: handle boolean default values in introspection correctly
1 parent 205a522 commit 586de0a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/Introspection/Introspection.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,17 @@ function ($inputValue) {
407407
//$inputValue can either be GraphQLArgument or GraphQLTypeField
408408
function ($inputValue) {
409409
$defaultValue = $inputValue->getDefaultValue();
410-
return $defaultValue !== null ? strval($defaultValue) : null;
410+
411+
// handle null
412+
if ($defaultValue === null)
413+
return null;
414+
415+
// handle booleans
416+
if (is_bool($defaultValue))
417+
return $defaultValue ? "true" : "false";
418+
419+
// handle other types
420+
return strval($defaultValue);
411421
}
412422
),
413423
new GraphQLTypeField(

0 commit comments

Comments
 (0)