Skip to content

Commit

Permalink
Add missing spec from #3326
Browse files Browse the repository at this point in the history
  • Loading branch information
rmosolgo committed Feb 8, 2021
1 parent 1c92184 commit 15c9752
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions spec/graphql/schema/field/connection_extension_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# frozen_string_literal: true
require "spec_helper"

describe GraphQL::Schema::Field::ConnectionExtension do
class ConnectionShortcutSchema < GraphQL::Schema
class ShortcutResolveExtension < GraphQL::Schema::FieldExtension
def resolve(**rest)
["a", "b", "c", "d", "e"]
end
end
class Query < GraphQL::Schema::Object
field :names, GraphQL::Types::String.connection_type, null: false, extensions: [ShortcutResolveExtension]
def names
raise "This should never be called"
end
end

query(Query)
end

it "implements connection handling even when resolve is shortcutted" do
res = ConnectionShortcutSchema.execute("{ names(first: 2) { nodes } }")
assert_equal ["a", "b"], res["data"]["names"]["nodes"]
end
end

0 comments on commit 15c9752

Please sign in to comment.