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



168
169
170
# File 'lib/graphql/types/relay/connection_behaviors.rb', line 168

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



173
174
175
176
177
178
179
180
# File 'lib/graphql/types/relay/connection_behaviors.rb', line 173

def edges
  # Assume that whatever authorization needed to happen
  # already happened at the connection level.
  current_runtime_state = Thread.current[:__graphql_runtime_info]
  query_runtime_state = current_runtime_state[context.query]
  query_runtime_state.was_authorized_by_scope_items = @object.was_authorized_by_scope_items?
  @object.edges
end

#nodesObject



182
183
184
185
186
187
188
189
# File 'lib/graphql/types/relay/connection_behaviors.rb', line 182

def nodes
  # Assume that whatever authorization needed to happen
  # already happened at the connection level.
  current_runtime_state = Thread.current[:__graphql_runtime_info]
  query_runtime_state = current_runtime_state[context.query]
  query_runtime_state.was_authorized_by_scope_items = @object.was_authorized_by_scope_items?
  @object.nodes
end