connectionDefinition() public static method

public static connectionDefinition ( AbstractType $type, null | string $name = null, array $config = [] ) : ObjectType
$type Youshido\GraphQL\Type\AbstractType
$name null | string
$config array
return Youshido\GraphQL\Type\Object\ObjectType
Esempio n. 1
0
 public function testConnectionDefinition()
 {
     $connection = Connection::connectionDefinition(new TestObjectType(), 'user');
     $this->assertEquals($connection->getName(), 'userConnection');
     $this->assertTrue($connection->hasField('pageInfo'));
     $this->assertTrue($connection->hasField('edges'));
 }
Esempio n. 2
0
 public function build($config)
 {
     $config->addField(new GlobalIdField(self::TYPE_KEY))->addField('factionId', ['type' => new IntType(), 'resolve' => function ($value) {
         return $value['id'];
     }])->addField('name', ['type' => TypeMap::TYPE_STRING, 'description' => 'The name of the faction.'])->addField('ships', ['type' => Connection::connectionDefinition(new ShipType()), 'description' => 'The ships used by the faction', 'args' => Connection::connectionArgs(), 'resolve' => function ($value = null, $args = [], $type = null) {
         return ArrayConnection::connectionFromArray(array_map(function ($id) {
             return TestDataProvider::getShip($id);
         }, $value['ships']), $args);
     }]);
 }