module GraphQL::Types::Relay::ConnectionBehaviors
Public Class Methods
add_page_info_field(obj_type)
click to toggle source
# File lib/graphql/types/relay/connection_behaviors.rb, line 148 def add_page_info_field(obj_type) obj_type.field :page_info, GraphQL::Types::Relay::PageInfo, null: false, description: "Information to aid in pagination." end
included(child_class)
click to toggle source
# File lib/graphql/types/relay/connection_behaviors.rb, line 10 def self.included(child_class) child_class.extend(ClassMethods) child_class.extend(Relay::DefaultRelay) child_class.default_relay(true) child_class.has_nodes_field(true) child_class.node_nullable(true) child_class.edges_nullable(true) child_class.edge_nullable(true) add_page_info_field(child_class) end
Public Instance Methods
edges()
click to toggle source
# File lib/graphql/types/relay/connection_behaviors.rb, line 159 def edges if @object.is_a?(GraphQL::Pagination::Connection) @object.edges elsif context.interpreter? context.schema.after_lazy(object.edge_nodes) do |nodes| nodes.map { |n| self.class.edge_class.new(n, object) } end else # This is done by edges_instrumentation @object.edge_nodes end end
nodes()
click to toggle source
By default this calls through to the ConnectionWrapper's edge nodes method, but sometimes you need to override it to support the `nodes` field
# File lib/graphql/types/relay/connection_behaviors.rb, line 155 def nodes @object.edge_nodes end