Class: ElasticGraph::Apollo::GraphQL::ApolloEntityRefResolver::ForIdList
- Inherits:
-
Object
- Object
- ElasticGraph::Apollo::GraphQL::ApolloEntityRefResolver::ForIdList
- Defined in:
- lib/elastic_graph/apollo/graphql/apollo_entity_ref_resolver.rb
Overview
GraphQL resolver for fields defined with ‘apollo_entity_ref_field` that are backed by an list of ids.
Instance Method Summary collapse
-
#initialize(elasticgraph_graphql:, config:) ⇒ ForIdList
constructor
A new instance of ForIdList.
- #resolve(field:, object:, args:, context:) ⇒ Object
Constructor Details
#initialize(elasticgraph_graphql:, config:) ⇒ ForIdList
Returns a new instance of ForIdList.
38 39 40 41 |
# File 'lib/elastic_graph/apollo/graphql/apollo_entity_ref_resolver.rb', line 38 def initialize(elasticgraph_graphql:, config:) @source_ids_field = config.fetch(:source_ids_field) @exposed_id_field = config.fetch(:exposed_id_field) end |
Instance Method Details
#resolve(field:, object:, args:, context:) ⇒ Object
43 44 45 46 47 |
# File 'lib/elastic_graph/apollo/graphql/apollo_entity_ref_resolver.rb', line 43 def resolve(field:, object:, args:, context:) object .fetch(@source_ids_field) .map { |id| {@exposed_id_field => id} } end |