Minor executor tweaks

This commit is contained in:
vladar 2016-11-07 19:52:44 +07:00
parent e6addd4644
commit 1927102183
2 changed files with 12 additions and 9 deletions

View File

@ -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;

View File

@ -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)