From 9be012154cd38753b33be3afc18783add7a77b27 Mon Sep 17 00:00:00 2001 From: Jeremiah VALERIE Date: Tue, 4 May 2021 15:14:16 +0200 Subject: [PATCH] Fix default value close #838 --- src/Generator/TypeBuilder.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Generator/TypeBuilder.php b/src/Generator/TypeBuilder.php index 3704a0556..9ff61ebfe 100644 --- a/src/Generator/TypeBuilder.php +++ b/src/Generator/TypeBuilder.php @@ -729,8 +729,14 @@ public function buildField(array $fieldConfig, string $fieldname) $field->addItem('useStrictAccess', false); } - if ('input-object' === $this->type && isset($c->validation)) { - $field->addItem('validation', $this->buildValidationRules($c->validation)); + if ('input-object' === $this->type) { + if (property_exists($c, 'defaultValue')) { + $field->addItem('defaultValue', $c->defaultValue); + } + + if (isset($c->validation)) { + $field->addItem('validation', $this->buildValidationRules($c->validation)); + } } return $field; @@ -770,8 +776,8 @@ public function buildArg(array $argConfig, string $argName): Collection $arg->addIfNotEmpty('description', $c->description); } - if (isset($c->defaultValue)) { - $arg->addIfNotEmpty('defaultValue', $c->defaultValue); + if (property_exists($c, 'defaultValue')) { + $arg->addItem('defaultValue', $c->defaultValue); } if (!empty($c->validation)) {