Class: ElasticGraph::GraphQL::Resolvers::ListRecords

Inherits:
Object
  • Object
show all
Defined in:
lib/elastic_graph/graphql/resolvers/list_records.rb

Overview

Responsible for fetching a a list of records of a particular type

Instance Method Summary collapse

Instance Method Details

#can_resolve?(field:, object:) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/elastic_graph/graphql/resolvers/list_records.rb', line 17

def can_resolve?(field:, object:)
  field.parent_type.name == :Query && field.type.collection?
end

#resolve(field:, context:, lookahead:) ⇒ Object



21
22
23
24
25
# File 'lib/elastic_graph/graphql/resolvers/list_records.rb', line 21

def resolve(field:, context:, lookahead:, **)
  query = yield
  response = QuerySource.execute_one(query, for_context: context)
  RelayConnection.maybe_wrap(response, field: field, context: context, lookahead: lookahead, query: query)
end