Given a model with a connection on a has_many association, for instance:
class Worker < ActiveRecord::Base
has_many :worked_hours, dependent: :destroy
end
WorkerType = GraphQL::ObjectType.define do
name "Worker"
field :id, !types.Int, "The id of this worker"
connection :entries, EntryType.connection_type, "Worked hours", property: :worked_hours
end
EntryType = GraphQL::ObjectType.define do
name "Entry"
field :id, !types.Int, "The id of this entry"
field :record, !types.String, "The record of this entry"
end
When running a query on the connection, the ArrayConnection subclass is used, instead of the RelationConnection. This causes any limits to be issued in memory instead of in the SQL query.
This seems to be happening because the resolver for the Connection subtype relies on the property's class, and Rails 3.2 reports a has_many association to be of class Array, whereas Rails 4+ returns AR::Relation.
Worker.first.worked_hours.class
=> Array
Thanks for sharing the details on this! I'll take a look at that connection-matching issue soon.
:metal: fixed by #343
Most helpful comment
:metal: fixed by #343