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


PHP Type::nonNull方法代码示例

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


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

示例1: getDefaultSchema

 /**
  * @return Schema
  */
 protected function getDefaultSchema()
 {
     $Being = new InterfaceType(['name' => 'Being', 'fields' => ['name' => ['type' => Type::string()]]]);
     $Pet = new InterfaceType(['name' => 'Pet', 'fields' => ['name' => ['type' => Type::string()]]]);
     $DogCommand = new EnumType(['name' => 'DogCommand', 'values' => ['SIT' => ['value' => 0], 'HEEL' => ['value' => 1], 'DOWN' => ['value' => 3]]]);
     $Dog = new ObjectType(['name' => 'Dog', 'fields' => ['name' => ['type' => Type::string()], 'nickname' => ['type' => Type::string()], 'barkVolume' => ['type' => Type::int()], 'barks' => ['type' => Type::boolean()], 'doesKnowCommand' => ['type' => Type::boolean(), 'args' => ['dogCommand' => ['type' => $DogCommand]]], 'isHousetrained' => ['type' => Type::boolean(), 'args' => ['atOtherHomes' => ['type' => Type::boolean(), 'defaultValue' => true]]], 'isAtLocation' => ['type' => Type::boolean(), 'args' => ['x' => ['type' => Type::int()], 'y' => ['type' => Type::int()]]]], 'interfaces' => [$Being, $Pet]]);
     $FurColor = new EnumType(['name' => 'FurColor', 'values' => ['BROWN' => ['value' => 0], 'BLACK' => ['value' => 1], 'TAN' => ['value' => 2], 'SPOTTED' => ['value' => 3]]]);
     $Cat = new ObjectType(['name' => 'Cat', 'fields' => ['name' => ['type' => Type::string()], 'nickname' => ['type' => Type::string()], 'meows' => ['type' => Type::boolean()], 'meowVolume' => ['type' => Type::int()], 'furColor' => ['type' => $FurColor]], 'interfaces' => [$Being, $Pet]]);
     $CatOrDog = new UnionType(['name' => 'CatOrDog', 'types' => [$Dog, $Cat], 'resolveType' => function ($value) {
         // not used for validation
         return null;
     }]);
     $Intelligent = new InterfaceType(['name' => 'Intelligent', 'fields' => ['iq' => ['type' => Type::int()]]]);
     $Human = $this->humanType = new ObjectType(['name' => 'Human', 'interfaces' => [$Being, $Intelligent], 'fields' => ['name' => ['args' => ['surname' => ['type' => Type::boolean()]], 'type' => Type::string()], 'pets' => ['type' => Type::listOf($Pet)], 'relatives' => ['type' => function () {
         return Type::listOf($this->humanType);
     }]]]);
     $Alien = new ObjectType(['name' => 'Alien', 'interfaces' => [$Being, $Intelligent], 'fields' => ['iq' => ['type' => Type::int()], 'numEyes' => ['type' => Type::int()]]]);
     $DogOrHuman = new UnionType(['name' => 'DogOrHuman', 'types' => [$Dog, $Human], 'resolveType' => function () {
         // not used for validation
         return null;
     }]);
     $HumanOrAlien = new UnionType(['name' => 'HumanOrAlien', 'types' => [$Human, $Alien], 'resolveType' => function () {
         // not used for validation
         return null;
     }]);
     $ComplexInput = new InputObjectType(['name' => 'ComplexInput', 'fields' => ['requiredField' => ['type' => Type::nonNull(Type::boolean())], 'intField' => ['type' => Type::int()], 'stringField' => ['type' => Type::string()], 'booleanField' => ['type' => Type::boolean()], 'stringListField' => ['type' => Type::listOf(Type::string())]]]);
     $ComplicatedArgs = new ObjectType(['name' => 'ComplicatedArgs', 'fields' => ['intArgField' => ['type' => Type::string(), 'args' => ['intArg' => ['type' => Type::int()]]], 'nonNullIntArgField' => ['type' => Type::string(), 'args' => ['nonNullIntArg' => ['type' => Type::nonNull(Type::int())]]], 'stringArgField' => ['type' => Type::string(), 'args' => ['stringArg' => ['type' => Type::string()]]], 'booleanArgField' => ['type' => Type::string(), 'args' => ['booleanArg' => ['type' => Type::boolean()]]], 'enumArgField' => ['type' => Type::string(), 'args' => ['enumArg' => ['type' => $FurColor]]], 'floatArgField' => ['type' => Type::string(), 'args' => ['floatArg' => ['type' => Type::float()]]], 'idArgField' => ['type' => Type::string(), 'args' => ['idArg' => ['type' => Type::id()]]], 'stringListArgField' => ['type' => Type::string(), 'args' => ['stringListArg' => ['type' => Type::listOf(Type::string())]]], 'complexArgField' => ['type' => Type::string(), 'args' => ['complexArg' => ['type' => $ComplexInput]]], 'multipleReqs' => ['type' => Type::string(), 'args' => ['req1' => ['type' => Type::nonNull(Type::int())], 'req2' => ['type' => Type::nonNull(Type::int())]]], 'multipleOpts' => ['type' => Type::string(), 'args' => ['opt1' => ['type' => Type::int(), 'defaultValue' => 0], 'opt2' => ['type' => Type::int(), 'defaultValue' => 0]]], 'multipleOptAndReq' => ['type' => Type::string(), 'args' => ['req1' => ['type' => Type::nonNull(Type::int())], 'req2' => ['type' => Type::nonNull(Type::int())], 'opt1' => ['type' => Type::int(), 'defaultValue' => 0], 'opt2' => ['type' => Type::int(), 'defaultValue' => 0]]]]]);
     $queryRoot = new ObjectType(['name' => 'QueryRoot', 'fields' => ['human' => ['args' => ['id' => ['type' => Type::id()]], 'type' => $Human], 'alien' => ['type' => $Alien], 'dog' => ['type' => $Dog], 'cat' => ['type' => $Cat], 'pet' => ['type' => $Pet], 'catOrDog' => ['type' => $CatOrDog], 'dogOrHuman' => ['type' => $DogOrHuman], 'humanOrAlien' => ['type' => $HumanOrAlien], 'complicatedArgs' => ['type' => $ComplicatedArgs]]]);
     $defaultSchema = new Schema($queryRoot);
     return $defaultSchema;
 }
开发者ID:rtuin,项目名称:graphql-php,代码行数:34,代码来源:TestCase.php

示例2: resolveType

 /**
  * @param string $name
  * @return Type
  */
 public function resolveType($name)
 {
     if (preg_match('#^(.+)\\!$#', $name, $regs)) {
         return Type::nonNull($this->resolveType($regs[1]));
     }
     if (preg_match('#^\\[(.+)\\]$#', $name, $regs)) {
         return Type::listOf($this->resolveType($regs[1]));
     }
     switch ($name) {
         case Type::INT:
             return Type::int();
         case Type::STRING:
             return Type::string();
         case Type::BOOLEAN:
             return Type::boolean();
         case Type::FLOAT:
             return Type::float();
         case Type::ID:
             return Type::id();
         default:
             if (!isset($this->types[$name])) {
                 throw new \InvalidArgumentException(sprintf('Type "%s" is not defined', $name));
             }
             return $this->types[$name];
     }
 }
开发者ID:jmcclell,项目名称:graphql-mapper,代码行数:30,代码来源:TypeResolver.php

示例3: setUp

 public function setUp()
 {
     $this->syncError = new Error('sync');
     $this->nonNullSyncError = new Error('nonNullSync');
     $this->throwingData = ['sync' => function () {
         throw $this->syncError;
     }, 'nonNullSync' => function () {
         throw $this->nonNullSyncError;
     }, 'nest' => function () {
         return $this->throwingData;
     }, 'nonNullNest' => function () {
         return $this->throwingData;
     }];
     $this->nullingData = ['sync' => function () {
         return null;
     }, 'nonNullSync' => function () {
         return null;
     }, 'nest' => function () {
         return $this->nullingData;
     }, 'nonNullNest' => function () {
         return $this->nullingData;
     }];
     $dataType = new ObjectType(['name' => 'DataType', 'fields' => ['sync' => ['type' => Type::string()], 'nonNullSync' => ['type' => Type::nonNull(Type::string())], 'nest' => ['type' => function () use(&$dataType) {
         return $dataType;
     }], 'nonNullNest' => ['type' => function () use(&$dataType) {
         return Type::nonNull($dataType);
     }]]]);
     $this->schema = new Schema($dataType);
 }
开发者ID:andytruong,项目名称:graphql-php,代码行数:29,代码来源:NonNullTest.php

示例4: baseFields

 /**
  * Fields that exist on every connection.
  *
  * @return array
  */
 protected function baseFields()
 {
     return ['pageInfo' => ['type' => Type::nonNull($this->pageInfoType), 'description' => 'Information to aid in pagination.', 'resolve' => function ($collection) {
         return $collection;
     }], 'edges' => ['type' => Type::listOf($this->edgeType), 'description' => 'Information to aid in pagination.', 'resolve' => function ($collection) {
         return $this->injectCursor($collection);
     }]];
 }
开发者ID:nuwave,项目名称:lighthouse,代码行数:13,代码来源:RelayConnectionType.php

示例5: buildDogType

 public static function buildDogType()
 {
     if (null !== self::$dogType) {
         return self::$dogType;
     }
     self::$dogType = new ObjectType(['name' => 'Dog', 'fields' => ['name' => ['type' => Type::nonNull(Type::string())], 'master' => ['type' => self::buildHumanType()]]]);
     return self::$dogType;
 }
开发者ID:webonyx,项目名称:graphql-php,代码行数:8,代码来源:QuerySecuritySchema.php

示例6: baseFields

 /**
  * Fields that exist on every connection.
  *
  * @return array
  */
 protected function baseFields()
 {
     $type = $this->type ?: $this->type();
     return ['pageInfo' => ['type' => Type::nonNull(GraphQL::type('pageInfo')), 'description' => 'Information to aid in pagination.', 'resolve' => function ($collection) {
         return $collection;
     }], 'edges' => ['type' => Type::listOf($this->buildEdgeType($this->name, $type)), 'description' => 'Information to aid in pagination.', 'resolve' => function ($collection) {
         return $this->injectCursor($collection);
     }]];
 }
开发者ID:nuwave,项目名称:laravel-graphql-relay,代码行数:14,代码来源:RelayConnectionType.php

示例7: withModifiers

 private function withModifiers($types)
 {
     return array_merge(Utils::map($types, function ($type) {
         return Type::listOf($type);
     }), Utils::map($types, function ($type) {
         return Type::nonNull($type);
     }), Utils::map($types, function ($type) {
         return Type::nonNull(Type::listOf($type));
     }));
 }
开发者ID:webonyx,项目名称:graphql-php,代码行数:10,代码来源:SchemaValidatorTest.php

示例8: testHandlesNonNullListOfNonNulls

 /**
  * @describe [T!]!
  */
 public function testHandlesNonNullListOfNonNulls()
 {
     $type = Type::nonNull(Type::listOf(Type::nonNull(Type::int())));
     // Contains values
     $this->check($type, [1, 2], ['data' => ['nest' => ['test' => [1, 2]]]]);
     // Contains null
     $this->check($type, [1, null, 2], ['data' => ['nest' => null], 'errors' => [FormattedError::create('Cannot return null for non-nullable field DataType.test.', [new SourceLocation(1, 10)])]]);
     // Returns null
     $this->check($type, null, ['data' => ['nest' => null], 'errors' => [FormattedError::create('Cannot return null for non-nullable field DataType.test.', [new SourceLocation(1, 10)])]]);
 }
开发者ID:aeshion,项目名称:ZeroPHP,代码行数:13,代码来源:ListsTest.php

示例9: pluralIdentifyingRootField

 /**
  * Returns configuration for Plural identifying root field
  *
  * type PluralIdentifyingRootFieldConfig = {
  *       argName: string,
  *       inputType: GraphQLInputType,
  *       outputType: GraphQLOutputType,
  *       resolveSingleInput: (input: any, info: GraphQLResolveInfo) => ?any,
  *       description?: ?string,
  * };
  *
  * @param array $config
  * @return array
  */
 public static function pluralIdentifyingRootField(array $config)
 {
     $inputArgs = [];
     $argName = self::getArrayValue($config, 'argName');
     $inputArgs[$argName] = ['type' => Type::nonNull(Type::listOf(Type::nonNull(self::getArrayValue($config, 'inputType'))))];
     return ['description' => isset($config['description']) ? $config['description'] : null, 'type' => Type::listOf(self::getArrayValue($config, 'outputType')), 'args' => $inputArgs, 'resolve' => function ($obj, $args, $context, ResolveInfo $info) use($argName, $config) {
         $inputs = $args[$argName];
         return array_map(function ($input) use($config, $context, $info) {
             return call_user_func(self::getArrayValue($config, 'resolveSingleInput'), $input, $context, $info);
         }, $inputs);
     }];
 }
开发者ID:ivome,项目名称:graphql-relay-php,代码行数:26,代码来源:Plural.php

示例10: testExecutesUsingASchema

    public function testExecutesUsingASchema()
    {
        $BlogArticle = null;
        $BlogImage = new ObjectType(['name' => 'Image', 'fields' => ['url' => ['type' => Type::string()], 'width' => ['type' => Type::int()], 'height' => ['type' => Type::int()]]]);
        $BlogAuthor = new ObjectType(['name' => 'Author', 'fields' => ['id' => ['type' => Type::string()], 'name' => ['type' => Type::string()], 'pic' => ['args' => ['width' => ['type' => Type::int()], 'height' => ['type' => Type::int()]], 'type' => $BlogImage, 'resolve' => function ($obj, $args) {
            return $obj['pic']($args['width'], $args['height']);
        }], 'recentArticle' => ['type' => function () use(&$BlogArticle) {
            return $BlogArticle;
        }]]]);
        $BlogArticle = new ObjectType(['name' => 'Article', 'fields' => ['id' => ['type' => Type::nonNull(Type::string())], 'isPublished' => ['type' => Type::boolean()], 'author' => ['type' => $BlogAuthor], 'title' => ['type' => Type::string()], 'body' => ['type' => Type::string()], 'keywords' => ['type' => Type::listOf(Type::string())]]]);
        $BlogQuery = new ObjectType(['name' => 'Query', 'fields' => ['article' => ['type' => $BlogArticle, 'args' => ['id' => ['type' => Type::id()]], 'resolve' => function ($_, $args) {
            return $this->article($args['id']);
        }], 'feed' => ['type' => Type::listOf($BlogArticle), 'resolve' => function () {
            return [$this->article(1), $this->article(2), $this->article(3), $this->article(4), $this->article(5), $this->article(6), $this->article(7), $this->article(8), $this->article(9), $this->article(10)];
        }]]]);
        $BlogSchema = new Schema($BlogQuery);
        $request = '
      {
        feed {
          id,
          title
        },
        article(id: "1") {
          ...articleFields,
          author {
            id,
            name,
            pic(width: 640, height: 480) {
              url,
              width,
              height
            },
            recentArticle {
              ...articleFields,
              keywords
            }
          }
        }
      }

      fragment articleFields on Article {
        id,
        isPublished,
        title,
        body,
        hidden,
        notdefined
      }
    ';
        $expected = ['data' => ['feed' => [['id' => '1', 'title' => 'My Article 1'], ['id' => '2', 'title' => 'My Article 2'], ['id' => '3', 'title' => 'My Article 3'], ['id' => '4', 'title' => 'My Article 4'], ['id' => '5', 'title' => 'My Article 5'], ['id' => '6', 'title' => 'My Article 6'], ['id' => '7', 'title' => 'My Article 7'], ['id' => '8', 'title' => 'My Article 8'], ['id' => '9', 'title' => 'My Article 9'], ['id' => '10', 'title' => 'My Article 10']], 'article' => ['id' => '1', 'isPublished' => true, 'title' => 'My Article 1', 'body' => 'This is a post', 'author' => ['id' => '123', 'name' => 'John Smith', 'pic' => ['url' => 'cdn://123', 'width' => 640, 'height' => 480], 'recentArticle' => ['id' => '1', 'isPublished' => true, 'title' => 'My Article 1', 'body' => 'This is a post', 'keywords' => ['foo', 'bar', '1', 'true', null]]]]]];
        $this->assertEquals($expected, Executor::execute($BlogSchema, Parser::parse($request))->toArray());
    }
开发者ID:andytruong,项目名称:graphql-php,代码行数:52,代码来源:ExecutorSchemaTest.php

示例11: fields

 /**
  * Fields that exist on every connection.
  *
  * @return array
  */
 public function fields()
 {
     return ['node' => ['type' => $this->type, 'description' => 'The item at the end of the edge.', 'resolve' => function ($edge) {
         return $edge;
     }], 'cursor' => ['type' => Type::nonNull(Type::string()), 'description' => 'A cursor for use in pagination.', 'resolve' => function ($edge) {
         if (is_array($edge) && isset($edge['relayCursor'])) {
             return $edge['relayCursor'];
         } elseif (is_array($edge->attributes)) {
             return $edge->attributes['relayCursor'];
         }
         return $edge->relayCursor;
     }]];
 }
开发者ID:nuwave,项目名称:lighthouse,代码行数:18,代码来源:EdgeType.php

示例12: fields

 /**
  * Fields available on PageInfo.
  *
  * @return array
  */
 public function fields()
 {
     return ['hasNextPage' => ['type' => Type::nonNull(Type::boolean()), 'description' => 'When paginating forwards, are there more items?', 'resolve' => function ($collection, $test) {
         if ($collection['total'] - $collection['first'] * $collection['currentPage'] > 0) {
             return true;
         }
         return false;
     }], 'hasPreviousPage' => ['type' => Type::nonNull(Type::boolean()), 'description' => 'When paginating backwards, are there more items?', 'resolve' => function ($collection) {
         if ($collection['currentPage'] > 1) {
             return true;
         }
         return false;
     }]];
 }
开发者ID:suribit,项目名称:GraphQLRelayBundle,代码行数:19,代码来源:PageInfoType.php

示例13: fields

 /**
  * Fields available on PageInfo.
  *
  * @return array
  */
 public function fields()
 {
     return ['hasNextPage' => ['type' => Type::nonNull(Type::boolean()), 'description' => 'When paginating forwards, are there more items?', 'resolve' => function ($collection) {
         if ($collection instanceof LengthAwarePaginator) {
             return $collection->hasMorePages();
         }
         return false;
     }], 'hasPreviousPage' => ['type' => Type::nonNull(Type::boolean()), 'description' => 'When paginating backwards, are there more items?', 'resolve' => function ($collection) {
         if ($collection instanceof LengthAwarePaginator) {
             return $collection->currentPage() > 1;
         }
         return false;
     }], 'startCursor' => ['type' => Type::string(), 'description' => 'When paginating backwards, the cursor to continue.', 'resolve' => function ($collection) {
         if ($collection instanceof LengthAwarePaginator) {
             return $this->encodeGlobalId('arrayconnection', $collection->firstItem() * $collection->currentPage());
         }
         return null;
     }], 'endCursor' => ['type' => Type::string(), 'description' => 'When paginating forwards, the cursor to continue.', 'resolve' => function ($collection) {
         if ($collection instanceof LengthAwarePaginator) {
             return $this->encodeGlobalId('arrayconnection', $collection->lastItem() * $collection->currentPage());
         }
         return null;
     }], 'total' => ['type' => Type::int(), 'description' => 'Total number of node in connection.', 'resolve' => function ($collection) {
         if ($collection instanceof LengthAwarePaginator) {
             return $collection->total();
         }
         return null;
     }], 'count' => ['type' => Type::int(), 'description' => 'Count of nodes in current request.', 'resolve' => function ($collection) {
         if ($collection instanceof LengthAwarePaginator) {
             return $collection->count();
         }
         return null;
     }], 'currentPage' => ['type' => Type::int(), 'description' => 'Current page of request.', 'resolve' => function ($collection) {
         if ($collection instanceof LengthAwarePaginator) {
             return $collection->currentPage();
         }
         return null;
     }], 'lastPage' => ['type' => Type::int(), 'description' => 'Last page in connection.', 'resolve' => function ($collection) {
         if ($collection instanceof LengthAwarePaginator) {
             return $collection->lastPage();
         }
         return null;
     }]];
 }
开发者ID:nuwave,项目名称:lighthouse,代码行数:49,代码来源:PageInfoType.php

示例14: mutationWithClientMutationId

 /**
  * Returns a GraphQLFieldConfig for the mutation described by the
  * provided MutationConfig.
  *
  * A description of a mutation consumable by mutationWithClientMutationId
  * to create a GraphQLFieldConfig for that mutation.
  *
  * The inputFields and outputFields should not include `clientMutationId`,
  * as this will be provided automatically.
  *
  * An input object will be created containing the input fields, and an
  * object will be created containing the output fields.
  *
  * mutateAndGetPayload will receieve an Object with a key for each
  * input field, and it should return an Object with a key for each
  * output field. It may return synchronously, or return a Promise.
  *
  * type MutationConfig = {
  *   name: string,
  *   inputFields: InputObjectConfigFieldMap,
  *   outputFields: GraphQLFieldConfigMap,
  *   mutateAndGetPayload: mutationFn,
  * }
  */
 public static function mutationWithClientMutationId(array $config)
 {
     $name = self::getArrayValue($config, 'name');
     $inputFields = self::getArrayValue($config, 'inputFields');
     $outputFields = self::getArrayValue($config, 'outputFields');
     $mutateAndGetPayload = self::getArrayValue($config, 'mutateAndGetPayload');
     $augmentedInputFields = function () use($inputFields) {
         $inputFieldsResolved = self::resolveMaybeThunk($inputFields);
         return array_merge($inputFieldsResolved !== null ? $inputFieldsResolved : [], ['clientMutationId' => ['type' => Type::nonNull(Type::string())]]);
     };
     $augmentedOutputFields = function () use($outputFields) {
         $outputFieldsResolved = self::resolveMaybeThunk($outputFields);
         return array_merge($outputFieldsResolved !== null ? $outputFieldsResolved : [], ['clientMutationId' => ['type' => Type::nonNull(Type::string())]]);
     };
     $outputType = new ObjectType(['name' => $name . 'Payload', 'fields' => $augmentedOutputFields]);
     $inputType = new InputObjectType(['name' => $name . 'Input', 'fields' => $augmentedInputFields]);
     return ['type' => $outputType, 'args' => ['input' => ['type' => Type::nonNull($inputType)]], 'resolve' => function ($query, $args, $context, ResolveInfo $info) use($mutateAndGetPayload) {
         $payload = call_user_func($mutateAndGetPayload, $args['input'], $context, $info);
         $payload['clientMutationId'] = $args['input']['clientMutationId'];
         return $payload;
     }];
 }
开发者ID:ivome,项目名称:graphql-relay-php,代码行数:46,代码来源:Mutation.php

示例15: setUp

 public function setUp()
 {
     $this->syncError = new \Exception('sync');
     $this->nonNullSyncError = new \Exception('nonNullSync');
     $this->promiseError = new \Exception('promise');
     $this->nonNullPromiseError = new \Exception('nonNullPromise');
     $this->throwingData = ['sync' => function () {
         throw $this->syncError;
     }, 'nonNullSync' => function () {
         throw $this->nonNullSyncError;
     }, 'promise' => function () {
         return new Promise(function () {
             throw $this->promiseError;
         });
     }, 'nonNullPromise' => function () {
         return new Promise(function () {
             throw $this->nonNullPromiseError;
         });
     }, 'nest' => function () {
         return $this->throwingData;
     }, 'nonNullNest' => function () {
         return $this->throwingData;
     }, 'promiseNest' => function () {
         return new Promise(function (callable $resolve) {
             $resolve($this->throwingData);
         });
     }, 'nonNullPromiseNest' => function () {
         return new Promise(function (callable $resolve) {
             $resolve($this->throwingData);
         });
     }];
     $this->nullingData = ['sync' => function () {
         return null;
     }, 'nonNullSync' => function () {
         return null;
     }, 'promise' => function () {
         return new Promise(function (callable $resolve) {
             return $resolve(null);
         });
     }, 'nonNullPromise' => function () {
         return new Promise(function (callable $resolve) {
             return $resolve(null);
         });
     }, 'nest' => function () {
         return $this->nullingData;
     }, 'nonNullNest' => function () {
         return $this->nullingData;
     }, 'promiseNest' => function () {
         return new Promise(function (callable $resolve) {
             $resolve($this->nullingData);
         });
     }, 'nonNullPromiseNest' => function () {
         return new Promise(function (callable $resolve) {
             $resolve($this->nullingData);
         });
     }];
     $dataType = new ObjectType(['name' => 'DataType', 'fields' => function () use(&$dataType) {
         return ['sync' => ['type' => Type::string()], 'nonNullSync' => ['type' => Type::nonNull(Type::string())], 'promise' => Type::string(), 'nonNullPromise' => Type::nonNull(Type::string()), 'nest' => $dataType, 'nonNullNest' => Type::nonNull($dataType), 'promiseNest' => $dataType, 'nonNullPromiseNest' => Type::nonNull($dataType)];
     }]);
     $this->schema = new Schema(['query' => $dataType]);
 }
开发者ID:webonyx,项目名称:graphql-php,代码行数:61,代码来源:NonNullTest.php


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