diff --git a/src/Argument/ArgumentSet.php b/src/Argument/ArgumentSet.php index 6e3cec618..b675a51a2 100644 --- a/src/Argument/ArgumentSet.php +++ b/src/Argument/ArgumentSet.php @@ -10,7 +10,7 @@ final class ArgumentSet extends \Infinityloop\Utils\ObjectSet implements \Graphp private array $defaults = []; - public function getDefaults() : array + public function getRawDefaults() : array { return $this->defaults; } @@ -30,7 +30,7 @@ protected function getKey(object $object) : string $defaultValue = $object->getDefaultValue(); if ($defaultValue instanceof \Graphpinator\Resolver\Value\ValidatedValue) { - $this->defaults[$object->getName()] = $defaultValue; + $this->defaults[$object->getName()] = $defaultValue->getRawValue(); } return $object->getName(); diff --git a/src/Type/InputType.php b/src/Type/InputType.php index b08846c1c..a986979fa 100644 --- a/src/Type/InputType.php +++ b/src/Type/InputType.php @@ -21,7 +21,7 @@ final public function applyDefaults($value) : \stdClass throw new \Exception('Composite input type without fields specified.'); } - return self::merge($value, $this->getArguments()->getDefaults()); + return self::merge($value, (object) $this->getArguments()->getRawDefaults()); } final public function getArguments() : \Graphpinator\Argument\ArgumentSet @@ -48,12 +48,13 @@ final public function printSchema() : string abstract protected function getFieldDefinition() : \Graphpinator\Argument\ArgumentSet; - private static function merge(\stdClass $core, iterable $supplement) : \stdClass + private static function merge(\stdClass $core, \stdClass $supplement) : \stdClass { foreach ($supplement as $key => $value) { if (\property_exists($core, $key)) { - if ($core->{$key} instanceof \stdClass) { - $core->{$key} = self::merge($core->{$key}, $supplement[$key]); + if ($core->{$key} instanceof \stdClass && + $supplement->{$key} instanceof \stdClass) { + $core->{$key} = self::merge($core->{$key}, $supplement->{$key}); } continue;