public function testConnectionDefinition() { $connection = Connection::connectionDefinition(new TestObjectType(), 'user'); $this->assertEquals($connection->getName(), 'userConnection'); $this->assertTrue($connection->hasField('pageInfo')); $this->assertTrue($connection->hasField('edges')); }
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); }]); }