Skip to content

Commit

Permalink
Add another test for lazy list values
Browse files Browse the repository at this point in the history
  • Loading branch information
rmosolgo committed Oct 8, 2020
1 parent a79ec95 commit af617b9
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions spec/graphql/schema/member/scoped_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ def items
]
end

field :lazy_items, [Item], null: false
field :lazy_items_connection, Item.connection_type, null: false, resolver_method: :lazy_items
def lazy_items
->() { items }
end

if TESTING_INTERPRETER
field :things, [Thing], null: false
def things
Expand Down Expand Up @@ -204,6 +210,28 @@ def get_item_names_with_context(ctx, field_name: "items")
assert_equal true, ctx[:proc_called]
end

it "works for lazy returned list values" do
query_str = "
{
lazyItemsConnection {
edges {
node {
name
}
}
}
lazyItems {
name
}
}
"
res = ScopeSchema.execute(query_str, context: { french: true })
names = res["data"]["lazyItemsConnection"]["edges"].map { |e| e["node"]["name"] }
assert_equal ["Trombone"], names
names2 = res["data"]["lazyItems"].map { |e| e["name"] }
assert_equal ["Trombone"], names2
end

it "is called for abstract types" do
query_str = "
{
Expand Down

0 comments on commit af617b9

Please sign in to comment.