public static function connectionDefinition(AbstractType $type, $name = null, $config = [])
{
$name = $name ?: $type->getName();
$connectionFields = !empty($config['connectionFields']) ? $config['connectionFields'] : [];
$connectionType = new ObjectType(['name' => $name . 'Connection', 'description' => 'A connection to a list of items.', 'fields' => array_merge(['pageInfo' => ['type' => new NonNullType(self::getPageInfoType()), 'description' => 'Information to aid in pagination.', 'resolve' => [__CLASS__, 'getPageInfo']], 'edges' => ['type' => new ListType(self::edgeDefinition($type, $name, $config)), 'description' => 'A list of edges.', 'resolve' => [__CLASS__, 'getEdges']]], $connectionFields)]);
return $connectionType;
}