Module: GraphQL::Types::Relay::ConnectionBehaviors

Extended by:
Forwardable
Included in:
BaseConnection
Defined in:
lib/graphql/types/relay/connection_behaviors.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.add_page_info_field(obj_type) ⇒ Object



97
98
99
# File 'lib/graphql/types/relay/connection_behaviors.rb', line 97

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

Instance Method Details

#edgesObject



108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/graphql/types/relay/connection_behaviors.rb', line 108

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

#nodesObject

By default this calls through to the ConnectionWrapper’s edge nodes method, but sometimes you need to override it to support the nodes field



104
105
106
# File 'lib/graphql/types/relay/connection_behaviors.rb', line 104

def nodes
  @object.edge_nodes
end