lib/graphql/relay/relation_connection.rb in graphql-relay-0.4.5 vs lib/graphql/relay/relation_connection.rb in graphql-relay-0.5.0
- old
+ new
@@ -1,16 +1,18 @@
module GraphQL
module Relay
class RelationConnection < BaseConnection
+ DEFAULT_ORDER = "id"
+
def cursor_from_node(item)
order_value = item.public_send(order_name)
cursor_parts = [order, order_value]
Base64.strict_encode64(cursor_parts.join(CURSOR_SEPARATOR))
end
def order
- @order ||= (super || "id")
+ @order ||= (super || DEFAULT_ORDER)
end
private
# apply first / last limit results
@@ -62,10 +64,10 @@
# Check for direction marker
def order_direction
@order_direction ||= order.start_with?("-") ? :desc : :asc
end
-
+
def table_name
@table_name ||= object.table.table_name
end
def create_order_condition(table, column, value, direction_marker)