/**
  * We define our faction type, which implements the node interface.
  *
  * This implements the following type system shorthand:
  *   type Faction : Node {
  *     id: String!
  *     name: String
  *     ships: ShipConnection
  *   }
  *
  * @return ObjectType
  */
 protected static function getFactionType()
 {
     if (self::$factionType === null) {
         $shipConnection = self::getShipConnection();
         $nodeDefinition = self::getNodeDefinition();
         $factionType = new ObjectType(['name' => 'Faction', 'description' => 'A faction in the Star Wars saga', 'fields' => function () use($shipConnection) {
             return ['id' => Relay::globalIdField(), 'name' => ['type' => Type::string(), 'description' => 'The name of the faction.'], 'ships' => ['type' => $shipConnection['connectionType'], 'description' => 'The ships used by the faction.', 'args' => Relay::connectionArgs(), 'resolve' => function ($faction, $args) {
                 // Map IDs from faction back to ships
                 $data = array_map(function ($id) {
                     return StarWarsData::getShip($id);
                 }, $faction['ships']);
                 return Relay::connectionFromArray($data, $args);
             }]];
         }, 'interfaces' => [$nodeDefinition['nodeInterface']]]);
         self::$factionType = $factionType;
     }
     return self::$factionType;
 }