Skip to content

Commit 3d5ee4b

Browse files
committed
feat(Relay::BaseConnection) add #inspect
1 parent 09a5f2a commit 3d5ee4b

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

lib/graphql/relay/base_connection.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,10 @@ def cursor_from_node(object)
140140
raise NotImplementedError, "must return a cursor for this object/connection pair"
141141
end
142142

143+
def inspect
144+
"#<GraphQL::Relay::Connection @parent=#{@parent.inspect} @arguments=#{@arguments.to_h.inspect}>"
145+
end
146+
143147
private
144148

145149
# Return a sanitized `arguments[arg_name]` (don't allow negatives)

spec/graphql/relay/base_connection_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,17 @@ class SpecialArrayConnection < GraphQL::Relay::BaseConnection; end
4949
end
5050
end
5151

52+
describe "#inspect" do
53+
it "inspects nicely" do
54+
args = {
55+
first: 1,
56+
last: -1,
57+
}
58+
conn = GraphQL::Relay::BaseConnection.new([], args, context: context)
59+
assert_equal "#<GraphQL::Relay::Connection @parent=nil @arguments={:first=>1, :last=>-1}>", conn.inspect
60+
end
61+
end
62+
5263
describe "#encode / #decode" do
5364
module ReverseEncoder
5465
module_function

0 commit comments

Comments
 (0)