From 1927102183fa034d582440229ecb93a7b53904b0 Mon Sep 17 00:00:00 2001 From: vladar Date: Mon, 7 Nov 2016 19:52:44 +0700 Subject: [PATCH] Minor executor tweaks --- src/Executor/Executor.php | 8 +++++--- src/Utils/TypeInfo.php | 13 +++++++------ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/Executor/Executor.php b/src/Executor/Executor.php index 81a895c..7722530 100644 --- a/src/Executor/Executor.php +++ b/src/Executor/Executor.php @@ -691,9 +691,11 @@ class Executor */ private static function getFieldDef(Schema $schema, ObjectType $parentType, $fieldName) { - $schemaMetaFieldDef = Introspection::schemaMetaFieldDef(); - $typeMetaFieldDef = Introspection::typeMetaFieldDef(); - $typeNameMetaFieldDef = Introspection::typeNameMetaFieldDef(); + static $schemaMetaFieldDef, $typeMetaFieldDef, $typeNameMetaFieldDef; + + $schemaMetaFieldDef = $schemaMetaFieldDef ?: Introspection::schemaMetaFieldDef(); + $typeMetaFieldDef = $typeMetaFieldDef ?: Introspection::typeMetaFieldDef(); + $typeNameMetaFieldDef = $typeNameMetaFieldDef ?: Introspection::typeNameMetaFieldDef(); if ($fieldName === $schemaMetaFieldDef->name && $schema->getQueryType() === $parentType) { return $schemaMetaFieldDef; diff --git a/src/Utils/TypeInfo.php b/src/Utils/TypeInfo.php index e7bd67f..94f4c2c 100644 --- a/src/Utils/TypeInfo.php +++ b/src/Utils/TypeInfo.php @@ -3,11 +3,11 @@ namespace GraphQL\Utils; use GraphQL\Language\AST\Field; use GraphQL\Language\AST\ListType; -use GraphQL\Language\AST\Name; use GraphQL\Language\AST\NamedType; use GraphQL\Language\AST\Node; use GraphQL\Language\AST\NonNullType; use GraphQL\Schema; +use GraphQL\Type\Definition\AbstractType; use GraphQL\Type\Definition\CompositeType; use GraphQL\Type\Definition\Directive; use GraphQL\Type\Definition\FieldArgument; @@ -19,7 +19,6 @@ use GraphQL\Type\Definition\ListOfType; use GraphQL\Type\Definition\NonNull; use GraphQL\Type\Definition\ObjectType; use GraphQL\Type\Definition\Type; -use GraphQL\Type\Definition\UnionType; use GraphQL\Type\Introspection; use GraphQL\Utils; @@ -113,8 +112,8 @@ class TypeInfo return true; } - if ($typeA instanceof InterfaceType || $typeA instanceof UnionType) { - if ($typeB instanceof InterfaceType || $typeB instanceof UnionType) { + if ($typeA instanceof AbstractType) { + if ($typeB instanceof AbstractType) { // If both types are abstract, then determine if there is any intersection // between possible concrete types of each. foreach ($schema->getPossibleTypes($typeA) as $type) { @@ -125,11 +124,13 @@ class TypeInfo return false; } + /** @var $typeB ObjectType */ // Determine if the latter type is a possible concrete type of the former. return $schema->isPossibleType($typeA, $typeB); } - if ($typeB instanceof InterfaceType || $typeB instanceof UnionType) { + if ($typeB instanceof AbstractType) { + /** @var $typeA ObjectType */ // Determine if the former type is a possible concrete type of the latter. return $schema->isPossibleType($typeB, $typeA); } @@ -142,7 +143,7 @@ class TypeInfo /** * @param Schema $schema * @param $inputTypeAst - * @return ListOfType|NonNull|Name + * @return Type * @throws \Exception */ public static function typeFromAST(Schema $schema, $inputTypeAst)