spec/graphql/relay/relation_connection_spec.rb in graphql-relay-0.8.1 vs spec/graphql/relay/relation_connection_spec.rb in graphql-relay-0.9.0
- old
+ new
@@ -10,13 +10,13 @@
result["data"]["empire"]["bases"]["edges"].last["cursor"]
end
describe "results" do
let(:query_string) {%|
- query getShips($first: Int, $after: String, $last: Int, $before: String, $order: String, $nameIncludes: String){
+ query getShips($first: Int, $after: String, $last: Int, $before: String, $nameIncludes: String){
empire {
- bases(first: $first, after: $after, last: $last, before: $before, order: $order, nameIncludes: $nameIncludes) {
+ bases(first: $first, after: $after, last: $last, before: $before, nameIncludes: $nameIncludes) {
... basesConnection
}
}
}
@@ -56,31 +56,20 @@
result = query(query_string, "after" => last_cursor, "first" => 2)
assert_equal(["Headquarters"], get_names(result))
last_cursor = get_last_cursor(result)
+
result = query(query_string, "before" => last_cursor, "last" => 1)
assert_equal(["Shield Generator"], get_names(result))
result = query(query_string, "before" => last_cursor, "last" => 2)
assert_equal(["Death Star", "Shield Generator"], get_names(result))
- end
- it 'paginates with reverse order' do
- result = query(query_string, "first" => 2, "order" => "-name")
- assert_equal(["Shield Generator", "Headquarters"], get_names(result))
- end
+ result = query(query_string, "before" => last_cursor, "last" => 10)
+ assert_equal(["Death Star", "Shield Generator"], get_names(result))
- it 'paginates with order' do
- result = query(query_string, "first" => 2, "order" => "name")
- assert_equal(["Death Star", "Headquarters"], get_names(result))
-
- # After the last result, find the next 2:
- last_cursor = get_last_cursor(result)
-
- result = query(query_string, "after" => last_cursor, "first" => 2, "order" => "name")
- assert_equal(["Shield Generator"], get_names(result))
end
it "applies custom arguments" do
result = query(query_string, "first" => 1, "nameIncludes" => "ea")
assert_equal(["Death Star"], get_names(result))
@@ -136,11 +125,11 @@
describe "without a block" do
let(:query_string) {%|
{
empire {
- basesClone {
+ basesClone(first: 10) {
edges {
node {
name
}
}
@@ -152,15 +141,15 @@
bases = result["data"]["empire"]["basesClone"]["edges"]
assert_equal(3, bases.length)
end
end
- describe "overriding default order" do
+ describe "custom ordering" do
let(:query_string) {%|
query getBases {
empire {
- basesByName { ... basesFields }
- bases { ... basesFields }
+ basesByName(first: 30) { ... basesFields }
+ bases(first: 30) { ... basesFields }
}
}
fragment basesFields on BaseConnection {
edges {
node {