diff --git a/src/Type/Definition/Config.php b/src/Type/Definition/Config.php index 5eaa68a..9cc8fa5 100644 --- a/src/Type/Definition/Config.php +++ b/src/Type/Definition/Config.php @@ -187,12 +187,14 @@ class Config $arrValue = ['name' => $arrValue]; } - Utils::invariant(is_array($arrValue), $err, $arrKey, Utils::getVariableType($arrValue)); + if (!$arrValue instanceof FieldDefinition) { + Utils::invariant(is_array($arrValue), $err, $arrKey, Utils::getVariableType($arrValue)); - if ($def->flags & self::KEY_AS_NAME && is_string($arrKey)) { - $arrValue += ['name' => $arrKey]; + if ($def->flags & self::KEY_AS_NAME && is_string($arrKey)) { + $arrValue += ['name' => $arrKey]; + } + self::validateMap($typeName, $arrValue, $def->definition, "$pathStr:$arrKey"); } - self::validateMap($typeName, $arrValue, $def->definition, "$pathStr:$arrKey"); } else { self::validateEntry($typeName, $arrKey, $arrValue, $def->definition, "$pathStr:$arrKey"); } diff --git a/src/Type/Definition/InputObjectType.php b/src/Type/Definition/InputObjectType.php index 322a51a..088e542 100644 --- a/src/Type/Definition/InputObjectType.php +++ b/src/Type/Definition/InputObjectType.php @@ -29,6 +29,8 @@ class InputObjectType extends Type implements InputType $config['name'] = $this->tryInferName(); } + Utils::invariant(!empty($config['name']), 'Every type is expected to have name'); + Config::validate($config, [ 'name' => Config::NAME | Config::REQUIRED, 'fields' => Config::arrayOf([