コード例 #1
0
ファイル: Relay.php プロジェクト: ivome/graphql-relay-php
 /**
  * Given a slice (subset) of an array, returns a connection object for use in
  * GraphQL.
  *
  * This function is similar to `connectionFromArray`, but is intended for use
  * cases where you know the cardinality of the connection, consider it too large
  * to materialize the entire array, and instead wish pass in a slice of the
  * total result large enough to cover the range specified in `args`.
  *
  * @param array $arraySlice
  * @param $args
  * @param $meta
  * @return array
  */
 public static function connectionFromArraySlice(array $arraySlice, $args, $meta)
 {
     return ArrayConnection::connectionFromArraySlice($arraySlice, $args, $meta);
 }
コード例 #2
0
 public function testWorksWithAnUndersizedArraySliceBothSides()
 {
     $connection = ArrayConnection::connectionFromArraySlice(array_slice($this->letters, 3, 1), ['first' => 3, 'after' => 'YXJyYXljb25uZWN0aW9uOjE='], ['sliceStart' => 3, 'arrayLength' => 5]);
     $expected = array('edges' => array(0 => array('node' => 'D', 'cursor' => 'YXJyYXljb25uZWN0aW9uOjM=')), 'pageInfo' => array('startCursor' => 'YXJyYXljb25uZWN0aW9uOjM=', 'endCursor' => 'YXJyYXljb25uZWN0aW9uOjM=', 'hasPreviousPage' => false, 'hasNextPage' => true));
     $this->assertEquals($expected, $connection);
 }