BUGFIX: expect ->getType() to throw

(cherry picked from commit 62b0036437)
This commit is contained in:
Torsten Blindert 2018-12-06 00:55:14 +07:00 committed by Vladimir Razuvaev
parent 59c128c54a
commit 22cee49747

View File

@ -513,7 +513,14 @@ class SchemaExtender
$schemaExtensions[] = $def;
} elseif ($def instanceof TypeDefinitionNode) {
$typeName = isset($def->name) ? $def->name->value : null;
if ($schema->getType($typeName)) {
try {
$type = $schema->getType($typeName);
} catch (Error $error) {
$type = null;
}
if ($type) {
throw new Error('Type "' . $typeName . '" already exists in the schema. It cannot also be defined in this type definition.', [$def]);
}
$typeDefinitionMap[$typeName] = $def;