Skip to content

Commit

Permalink
Revert "Merge pull request #1774 from rmosolgo/fix-connections"
Browse files Browse the repository at this point in the history
This reverts commit 34c0bdb, reversing
changes made to d483c91.
  • Loading branch information
rmosolgo committed Aug 20, 2018
1 parent 9b58784 commit 1e958c3
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 33 deletions.
10 changes: 3 additions & 7 deletions lib/graphql/schema/field.rb
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,9 @@ def resolve_field(obj, args, ctx)
if @resolve_proc
# Might be nil, still want to call the func in that case
@resolve_proc.call(inner_obj, args, ctx)
elsif @resolver_class
singleton_inst = @resolver_class.new(object: inner_obj, context: query_ctx)
public_send_field(singleton_inst, args, ctx)
else
public_send_field(after_obj, args, ctx)
end
Expand Down Expand Up @@ -460,13 +463,6 @@ def public_send_field(obj, graphql_args, field_ctx)

query_ctx = field_ctx.query.context
with_extensions(obj, ruby_kwargs, query_ctx) do |extended_obj, extended_args|
if @resolver_class
if extended_obj.is_a?(GraphQL::Schema::Object)
extended_obj = extended_obj.object
end
extended_obj = @resolver_class.new(object: extended_obj, context: query_ctx)
end

if extended_args.any?
extended_obj.public_send(@method_sym, **extended_args)
else
Expand Down
16 changes: 0 additions & 16 deletions spec/integration/rails/graphql/relay/connection_resolve_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,6 @@
end
end

describe "when a resolver is used" do
it "returns the items with the correct parent" do
resolver_query_str = <<-GRAPHQL
{
rebels {
shipsByResolver {
parentClassName
}
}
}
GRAPHQL
result = star_wars_query(resolver_query_str)
assert_equal "StarWars::FactionRecord", result["data"]["rebels"]["shipsByResolver"]["parentClassName"]
end
end

describe "when nil is returned" do
it "becomes null" do
result = star_wars_query(query_string, { "name" => "null" })
Expand Down
10 changes: 0 additions & 10 deletions spec/support/star_wars/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,6 @@ def parent_class_name
end
end

class ShipsByResolver < GraphQL::Schema::Resolver
type ShipConnectionWithParentType, null: false

def resolve
object.ships.map { |ship_id| StarWars::DATA["Ship"][ship_id] }
end
end

class Faction < GraphQL::Schema::Object
implements GraphQL::Relay::Node.interface

Expand All @@ -125,8 +117,6 @@ class Faction < GraphQL::Schema::Object
argument :name_includes, String, required: false
end

field :shipsByResolver, resolver: ShipsByResolver, connection: true

def ships(name_includes: nil)
all_ships = object.ships.map {|ship_id| StarWars::DATA["Ship"][ship_id] }
if name_includes
Expand Down

0 comments on commit 1e958c3

Please sign in to comment.