Skip to content

Commit 4372c4b

Browse files
committed
fix(Relay::Connection) properly skip connections when ctx.skip
1 parent e6dbe99 commit 4372c4b

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

lib/graphql/compatibility/execution_specification.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,16 @@ def test_it_treats_failed_type_resolution_like_nil
418418
assert_equal false, res.key?("errors")
419419
assert_equal [SpecificationSchema::BOGUS_NODE, SpecificationSchema::BOGUS_NODE], log
420420
end
421+
422+
def test_it_skips_connections
423+
query_type = GraphQL::ObjectType.define do
424+
name "Query"
425+
connection :skipped, types[query_type], resolve: ->(o,a,c) { c.skip }
426+
end
427+
schema = GraphQL::Schema.define(query: query_type)
428+
res = schema.execute("{ skipped { __typename } }")
429+
assert_equal({"data" => nil}, res)
430+
end
421431
end
422432
end
423433
end

lib/graphql/relay/connection_resolve.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ def call(obj, args, ctx)
2727
else
2828
nodes
2929
end
30+
elsif nodes.is_a?(GraphQL::Execution::Execute::Skip)
31+
nodes
3032
else
3133
build_connection(nodes, args, parent, ctx)
3234
end

0 commit comments

Comments
 (0)