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); }]); }
public function testConnectionArgs() { $this->assertEquals(['after' => ['type' => TypeMap::TYPE_STRING], 'first' => ['type' => TypeMap::TYPE_INT], 'before' => ['type' => TypeMap::TYPE_STRING], 'last' => ['type' => TypeMap::TYPE_INT]], Connection::connectionArgs()); }