Inheritance: extends Type, implements GraphQL\Type\Definition\AbstractType, implements OutputType, implements CompositeType
コード例 #1
0
 public function __construct()
 {
     $config = ['name' => 'SearchResultType', 'types' => function () {
         return [Types::story(), Types::user()];
     }, 'resolveType' => function ($value) {
         if ($value instanceof Story) {
             return Types::story();
         } else {
             if ($value instanceof User) {
                 return Types::user();
             }
         }
     }];
     parent::__construct($config);
 }
コード例 #2
0
 /**
  * @it allows a thunk for Union\'s types
  */
 public function testAllowsThunkForUnionTypes()
 {
     $union = new UnionType(['name' => 'ThunkUnion', 'types' => function () {
         return [$this->objectType];
     }]);
     $types = $union->getTypes();
     $this->assertEquals(1, count($types));
     $this->assertSame($this->objectType, $types[0]);
 }