mirror of
https://github.com/retailcrm/graphql-php.git
synced 2024-11-26 06:46:02 +03:00
Improvements in config validation
This commit is contained in:
parent
e7cde5ecf3
commit
ffc4542cd0
@ -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");
|
||||
}
|
||||
|
@ -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([
|
||||
|
Loading…
Reference in New Issue
Block a user