mirror of
https://github.com/retailcrm/graphql-php.git
synced 2024-11-25 14:26:08 +03:00
Fixes for definition config validation after recent changes
This commit is contained in:
parent
083cb4e3f2
commit
f548de59fe
@ -21,6 +21,7 @@ class Config
|
|||||||
|
|
||||||
const REQUIRED = 65536;
|
const REQUIRED = 65536;
|
||||||
const KEY_AS_NAME = 131072;
|
const KEY_AS_NAME = 131072;
|
||||||
|
const MAYBE_THUNK = 262144;
|
||||||
|
|
||||||
private static $enableValidation = false;
|
private static $enableValidation = false;
|
||||||
|
|
||||||
@ -105,7 +106,11 @@ class Config
|
|||||||
if ($def->flags & self::REQUIRED === 0 && $value === null) {
|
if ($def->flags & self::REQUIRED === 0 && $value === null) {
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
if (($def->flags & self::MAYBE_THUNK) > 0) {
|
||||||
|
Utils::invariant(is_array($value) || is_callable($value), $err, 'array or callable');
|
||||||
|
} else {
|
||||||
Utils::invariant(is_array($value), $err, 'array');
|
Utils::invariant(is_array($value), $err, 'array');
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($def->isMap)) {
|
if (!empty($def->isMap)) {
|
||||||
if ($def->flags & self::KEY_AS_NAME) {
|
if ($def->flags & self::KEY_AS_NAME) {
|
||||||
|
@ -21,7 +21,7 @@ class InputObjectType extends Type implements InputType
|
|||||||
'type' => Config::INPUT_TYPE | Config::REQUIRED,
|
'type' => Config::INPUT_TYPE | Config::REQUIRED,
|
||||||
'defaultValue' => Config::ANY,
|
'defaultValue' => Config::ANY,
|
||||||
'description' => Config::STRING
|
'description' => Config::STRING
|
||||||
], Config::KEY_AS_NAME),
|
], Config::KEY_AS_NAME | Config::MAYBE_THUNK),
|
||||||
'description' => Config::STRING
|
'description' => Config::STRING
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ class InterfaceType extends Type implements AbstractType, OutputType, CompositeT
|
|||||||
'name' => Config::STRING,
|
'name' => Config::STRING,
|
||||||
'fields' => Config::arrayOf(
|
'fields' => Config::arrayOf(
|
||||||
FieldDefinition::getDefinition(),
|
FieldDefinition::getDefinition(),
|
||||||
Config::KEY_AS_NAME
|
Config::KEY_AS_NAME | Config::MAYBE_THUNK
|
||||||
),
|
),
|
||||||
'resolveType' => Config::CALLBACK, // function($value, ResolveInfo $info) => ObjectType
|
'resolveType' => Config::CALLBACK, // function($value, ResolveInfo $info) => ObjectType
|
||||||
'description' => Config::STRING
|
'description' => Config::STRING
|
||||||
|
@ -79,11 +79,12 @@ class ObjectType extends Type implements OutputType, CompositeType
|
|||||||
'name' => Config::STRING | Config::REQUIRED,
|
'name' => Config::STRING | Config::REQUIRED,
|
||||||
'fields' => Config::arrayOf(
|
'fields' => Config::arrayOf(
|
||||||
FieldDefinition::getDefinition(),
|
FieldDefinition::getDefinition(),
|
||||||
Config::KEY_AS_NAME
|
Config::KEY_AS_NAME | Config::MAYBE_THUNK
|
||||||
),
|
),
|
||||||
'description' => Config::STRING,
|
'description' => Config::STRING,
|
||||||
'interfaces' => Config::arrayOf(
|
'interfaces' => Config::arrayOf(
|
||||||
Config::INTERFACE_TYPE
|
Config::INTERFACE_TYPE,
|
||||||
|
Config::MAYBE_THUNK
|
||||||
),
|
),
|
||||||
'isTypeOf' => Config::CALLBACK, // ($value, ResolveInfo $info) => boolean
|
'isTypeOf' => Config::CALLBACK, // ($value, ResolveInfo $info) => boolean
|
||||||
'resolveField' => Config::CALLBACK
|
'resolveField' => Config::CALLBACK
|
||||||
|
Loading…
Reference in New Issue
Block a user