Sha256: 11b76add1f6026a4a8465b480ffee89ce009b6579a9121f650879590ca2e4dc3
Contents?: true
Size: 1.03 KB
Versions: 6
Compression:
Stored size: 1.03 KB
Contents
# frozen_string_literal: true module GraphQL module Relay class ConnectionResolve def initialize(field, underlying_resolve, max_page_size: nil) @field = field @underlying_resolve = underlying_resolve @max_page_size = max_page_size end def call(obj, args, ctx) nodes = @underlying_resolve.call(obj, args, ctx) if ctx.schema.lazy?(nodes) @field.prepare_lazy(nodes, args, ctx).then { |resolved_nodes| build_connection(resolved_nodes, args, obj, ctx) } else build_connection(nodes, args, obj, ctx) end end private def build_connection(nodes, args, parent, ctx) if nodes.is_a? GraphQL::ExecutionError ctx.add_error(nodes) nil else connection_class = GraphQL::Relay::BaseConnection.connection_for_nodes(nodes) connection_class.new(nodes, args, field: @field, max_page_size: @max_page_size, parent: parent, context: ctx) end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems