mirror of
https://github.com/retailcrm/graphql-php.git
synced 2025-02-16 20:33:14 +03:00
Improvements in config validation
This commit is contained in:
parent
e7cde5ecf3
commit
ffc4542cd0
@ -187,12 +187,14 @@ class Config
|
|||||||
$arrValue = ['name' => $arrValue];
|
$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)) {
|
if ($def->flags & self::KEY_AS_NAME && is_string($arrKey)) {
|
||||||
$arrValue += ['name' => $arrKey];
|
$arrValue += ['name' => $arrKey];
|
||||||
|
}
|
||||||
|
self::validateMap($typeName, $arrValue, $def->definition, "$pathStr:$arrKey");
|
||||||
}
|
}
|
||||||
self::validateMap($typeName, $arrValue, $def->definition, "$pathStr:$arrKey");
|
|
||||||
} else {
|
} else {
|
||||||
self::validateEntry($typeName, $arrKey, $arrValue, $def->definition, "$pathStr:$arrKey");
|
self::validateEntry($typeName, $arrKey, $arrValue, $def->definition, "$pathStr:$arrKey");
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,8 @@ class InputObjectType extends Type implements InputType
|
|||||||
$config['name'] = $this->tryInferName();
|
$config['name'] = $this->tryInferName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Utils::invariant(!empty($config['name']), 'Every type is expected to have name');
|
||||||
|
|
||||||
Config::validate($config, [
|
Config::validate($config, [
|
||||||
'name' => Config::NAME | Config::REQUIRED,
|
'name' => Config::NAME | Config::REQUIRED,
|
||||||
'fields' => Config::arrayOf([
|
'fields' => Config::arrayOf([
|
||||||
|
Loading…
x
Reference in New Issue
Block a user