BUGFIX: expect ->getType() to throw

This commit is contained in:
Torsten Blindert 2018-12-05 18:55:14 +01:00
parent e22b400373
commit 62b0036437

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;