getParentType() public method

public getParentType ( ) : GraphQL\Type\Definition\CompositeType
return GraphQL\Type\Definition\CompositeType
 public function __invoke(ValidationContext $context)
 {
     return [Node::FIELD => function (Field $node) use($context) {
         $type = $context->getParentType();
         if ($type) {
             $fieldDef = $context->getFieldDef();
             if (!$fieldDef) {
                 return new Error(Messages::undefinedFieldMessage($node->name->value, $type->name), [$node]);
             }
         }
     }];
 }
 public function __invoke(ValidationContext $context)
 {
     return [NodeKind::INLINE_FRAGMENT => function (InlineFragmentNode $node) use($context) {
         $fragType = $context->getType();
         $parentType = $context->getParentType();
         if ($fragType && $parentType && !TypeInfo::doTypesOverlap($context->getSchema(), $fragType, $parentType)) {
             $context->reportError(new Error(self::typeIncompatibleAnonSpreadMessage($parentType, $fragType), [$node]));
         }
     }, NodeKind::FRAGMENT_SPREAD => function (FragmentSpreadNode $node) use($context) {
         $fragName = $node->name->value;
         $fragType = $this->getFragmentType($context, $fragName);
         $parentType = $context->getParentType();
         if ($fragType && $parentType && !TypeInfo::doTypesOverlap($context->getSchema(), $fragType, $parentType)) {
             $context->reportError(new Error(self::typeIncompatibleSpreadMessage($fragName, $parentType, $fragType), [$node]));
         }
     }];
 }
 public function __invoke(ValidationContext $context)
 {
     return [Node::INLINE_FRAGMENT => function (InlineFragment $node) use($context) {
         $fragType = Type::getUnmodifiedType($context->getType());
         $parentType = $context->getParentType();
         if ($fragType && $parentType && !$this->doTypesOverlap($fragType, $parentType)) {
             return new Error(Messages::typeIncompatibleAnonSpreadMessage($parentType, $fragType), [$node]);
         }
     }, Node::FRAGMENT_SPREAD => function (FragmentSpread $node) use($context) {
         $fragName = $node->name->value;
         $fragType = Type::getUnmodifiedType($this->getFragmentType($context, $fragName));
         $parentType = $context->getParentType();
         if ($fragType && $parentType && !$this->doTypesOverlap($fragType, $parentType)) {
             return new Error(Messages::typeIncompatibleSpreadMessage($fragName, $parentType, $fragType), [$node]);
         }
     }];
 }
 public function __invoke(ValidationContext $context)
 {
     return [Node::FIELD => function (Field $node) use($context) {
         $type = $context->getParentType();
         if ($type) {
             $fieldDef = $context->getFieldDef();
             if (!$fieldDef) {
                 // This isn't valid. Let's find suggestions, if any.
                 $suggestedTypes = [];
                 if ($type instanceof AbstractType) {
                     $schema = $context->getSchema();
                     $suggestedTypes = self::getSiblingInterfacesIncludingField($schema, $type, $node->name->value);
                     $suggestedTypes = array_merge($suggestedTypes, self::getImplementationsIncludingField($schema, $type, $node->name->value));
                 }
                 $context->reportError(new Error(static::undefinedFieldMessage($node->name->value, $type->name, $suggestedTypes), [$node]));
             }
         }
     }];
 }
 public function __invoke(ValidationContext $context)
 {
     return [Node::ARGUMENT => function (Argument $node) use($context) {
         $fieldDef = $context->getFieldDef();
         if ($fieldDef) {
             $argDef = null;
             foreach ($fieldDef->args as $arg) {
                 if ($arg->name === $node->name->value) {
                     $argDef = $arg;
                     break;
                 }
             }
             if (!$argDef) {
                 $parentType = $context->getParentType();
                 Utils::invariant($parentType);
                 return new Error(Messages::unknownArgMessage($node->name->value, $fieldDef->name, $parentType->name), [$node]);
             }
         }
     }];
 }
 public function __invoke(ValidationContext $context)
 {
     return [NodeKind::ARGUMENT => function (ArgumentNode $node, $key, $parent, $path, $ancestors) use($context) {
         $argumentOf = $ancestors[count($ancestors) - 1];
         if ($argumentOf->kind === NodeKind::FIELD) {
             $fieldDef = $context->getFieldDef();
             if ($fieldDef) {
                 $fieldArgDef = null;
                 foreach ($fieldDef->args as $arg) {
                     if ($arg->name === $node->name->value) {
                         $fieldArgDef = $arg;
                         break;
                     }
                 }
                 if (!$fieldArgDef) {
                     $parentType = $context->getParentType();
                     Utils::invariant($parentType);
                     $context->reportError(new Error(self::unknownArgMessage($node->name->value, $fieldDef->name, $parentType->name), [$node]));
                 }
             }
         } else {
             if ($argumentOf->kind === NodeKind::DIRECTIVE) {
                 $directive = $context->getDirective();
                 if ($directive) {
                     $directiveArgDef = null;
                     foreach ($directive->args as $arg) {
                         if ($arg->name === $node->name->value) {
                             $directiveArgDef = $arg;
                             break;
                         }
                     }
                     if (!$directiveArgDef) {
                         $context->reportError(new Error(self::unknownDirectiveArgMessage($node->name->value, $directive->name), [$node]));
                     }
                 }
             }
         }
     }];
 }