Sha256: b1793a915ad0f03859f9c9ec23e2be714bebf104652fe24a81c37a88575e8ec7
Contents?: true
Size: 761 Bytes
Versions: 13
Compression:
Stored size: 761 Bytes
Contents
module GraphQL module Models class PromiseRelationConnection < GraphQL::Relay::RelationConnection def edges # Can't do any optimization if the request is asking for the last X items, since there's # no easy way to turn it into a generalized query. return super if last relation = sliced_nodes limit = [first, last, max_page_size].compact.min relation = relation.limit(limit) if first request = RelationLoadRequest.new(relation) request.load.then do |models| models.map { |m| GraphQL::Relay::Edge.new(m, self) } end end end GraphQL::Relay::BaseConnection.register_connection_implementation(ActiveRecord::Relation, PromiseRelationConnection) end end
Version data entries
13 entries across 13 versions & 1 rubygems