当前位置: 首页>>代码示例>>PHP>>正文


PHP Type::getNullableType方法代码示例

本文整理汇总了PHP中GraphQL\Type\Definition\Type::getNullableType方法的典型用法代码示例。如果您正苦于以下问题:PHP Type::getNullableType方法的具体用法?PHP Type::getNullableType怎么用?PHP Type::getNullableType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GraphQL\Type\Definition\Type的用法示例。


在下文中一共展示了Type::getNullableType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: enter

 /**
  * @param Node $node
  */
 function enter(Node $node)
 {
     $schema = $this->schema;
     switch ($node->kind) {
         case Node::SELECTION_SET:
             $namedType = Type::getNamedType($this->getType());
             $compositeType = null;
             if (Type::isCompositeType($namedType)) {
                 // isCompositeType is a type refining predicate, so this is safe.
                 $compositeType = $namedType;
             }
             $this->parentTypeStack[] = $compositeType;
             // push
             break;
         case Node::FIELD:
             $parentType = $this->getParentType();
             $fieldDef = null;
             if ($parentType) {
                 $fieldDef = self::getFieldDefinition($schema, $parentType, $node);
             }
             $this->fieldDefStack[] = $fieldDef;
             // push
             $this->typeStack[] = $fieldDef ? $fieldDef->getType() : null;
             // push
             break;
         case Node::DIRECTIVE:
             $this->directive = $schema->getDirective($node->name->value);
             break;
         case Node::OPERATION_DEFINITION:
             $type = null;
             if ($node->operation === 'query') {
                 $type = $schema->getQueryType();
             } else {
                 if ($node->operation === 'mutation') {
                     $type = $schema->getMutationType();
                 } else {
                     if ($node->operation === 'subscription') {
                         $type = $schema->getSubscriptionType();
                     }
                 }
             }
             $this->typeStack[] = $type;
             // push
             break;
         case Node::INLINE_FRAGMENT:
         case Node::FRAGMENT_DEFINITION:
             $typeConditionAST = $node->typeCondition;
             $outputType = $typeConditionAST ? self::typeFromAST($schema, $typeConditionAST) : $this->getType();
             $this->typeStack[] = $outputType;
             // push
             break;
         case Node::VARIABLE_DEFINITION:
             $inputType = self::typeFromAST($schema, $node->type);
             $this->inputTypeStack[] = $inputType;
             // push
             break;
         case Node::ARGUMENT:
             $fieldOrDirective = $this->getDirective() ?: $this->getFieldDef();
             $argDef = $argType = null;
             if ($fieldOrDirective) {
                 $argDef = Utils::find($fieldOrDirective->args, function ($arg) use($node) {
                     return $arg->name === $node->name->value;
                 });
                 if ($argDef) {
                     $argType = $argDef->getType();
                 }
             }
             $this->argument = $argDef;
             $this->inputTypeStack[] = $argType;
             // push
             break;
         case Node::LST:
             $listType = Type::getNullableType($this->getInputType());
             $this->inputTypeStack[] = $listType instanceof ListOfType ? $listType->getWrappedType() : null;
             // push
             break;
         case Node::OBJECT_FIELD:
             $objectType = Type::getNamedType($this->getInputType());
             $fieldType = null;
             if ($objectType instanceof InputObjectType) {
                 $tmp = $objectType->getFields();
                 $inputField = isset($tmp[$node->name->value]) ? $tmp[$node->name->value] : null;
                 $fieldType = $inputField ? $inputField->getType() : null;
             }
             $this->inputTypeStack[] = $fieldType;
             break;
     }
 }
开发者ID:aeshion,项目名称:ZeroPHP,代码行数:91,代码来源:TypeInfo.php

示例2: enter

 function enter(Node $node)
 {
     $schema = $this->_schema;
     switch ($node->kind) {
         case Node::SELECTION_SET:
             // var $compositeType: ?GraphQLCompositeType;
             $rawType = Type::getUnmodifiedType($this->getType());
             $compositeType = null;
             if (Type::isCompositeType($rawType)) {
                 // isCompositeType is a type refining predicate, so this is safe.
                 $compositeType = $rawType;
             }
             array_push($this->_parentTypeStack, $compositeType);
             break;
         case Node::FIELD:
             $parentType = $this->getParentType();
             $fieldDef = null;
             if ($parentType) {
                 $fieldDef = self::_getFieldDef($schema, $parentType, $node);
             }
             array_push($this->_fieldDefStack, $fieldDef);
             array_push($this->_typeStack, $fieldDef ? $fieldDef->getType() : null);
             break;
         case Node::OPERATION_DEFINITION:
             $type = null;
             if ($node->operation === 'query') {
                 $type = $schema->getQueryType();
             } else {
                 if ($node->operation === 'mutation') {
                     $type = $schema->getMutationType();
                 }
             }
             array_push($this->_typeStack, $type);
             break;
         case Node::INLINE_FRAGMENT:
         case Node::FRAGMENT_DEFINITION:
             $type = $schema->getType($node->typeCondition->value);
             array_push($this->_typeStack, $type);
             break;
         case Node::VARIABLE_DEFINITION:
             array_push($this->_inputTypeStack, self::typeFromAST($schema, $node->type));
             break;
         case Node::ARGUMENT:
             $field = $this->getFieldDef();
             $argType = null;
             if ($field) {
                 $argDef = Utils::find($field->args, function ($arg) use($node) {
                     return $arg->name === $node->name->value;
                 });
                 if ($argDef) {
                     $argType = $argDef->getType();
                 }
             }
             array_push($this->_inputTypeStack, $argType);
             break;
         case Node::DIRECTIVE:
             $directive = $schema->getDirective($node->name->value);
             array_push($this->_inputTypeStack, $directive ? $directive->type : null);
             break;
         case Node::ARR:
             $arrayType = Type::getNullableType($this->getInputType());
             array_push($this->_inputTypeStack, $arrayType instanceof ListOfType ? $arrayType->getWrappedType() : null);
             break;
         case Node::OBJECT_FIELD:
             $objectType = Type::getUnmodifiedType($this->getInputType());
             $fieldType = null;
             if ($objectType instanceof InputObjectType) {
                 $tmp = $objectType->getFields();
                 $inputField = isset($tmp[$node->name->value]) ? $tmp[$node->name->value] : null;
                 $fieldType = $inputField ? $inputField->getType() : null;
             }
             array_push($this->_inputTypeStack, $fieldType);
             break;
     }
 }
开发者ID:TimothyKrell,项目名称:graphql-php,代码行数:75,代码来源:TypeInfo.php


注:本文中的GraphQL\Type\Definition\Type::getNullableType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。