Examples\StarWars\FactionType::build PHP Method

build() public method

public build ( $config )
    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);
        }]);
    }