From 22cee4974765e91218f786fe07eb0a520e355dee Mon Sep 17 00:00:00 2001 From: Torsten Blindert Date: Thu, 6 Dec 2018 00:55:14 +0700 Subject: [PATCH] BUGFIX: expect ->getType() to throw (cherry picked from commit 62b003643779246403c0fd71d7e7486d94c50835) --- src/Utils/SchemaExtender.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Utils/SchemaExtender.php b/src/Utils/SchemaExtender.php index fab006e..110e750 100644 --- a/src/Utils/SchemaExtender.php +++ b/src/Utils/SchemaExtender.php @@ -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;