Class: ElasticGraph::Apollo::GraphQL::ApolloEntityRefResolver::ForSingleId
- Inherits:
-
Object
- Object
- ElasticGraph::Apollo::GraphQL::ApolloEntityRefResolver::ForSingleId
- 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 a single id.
Instance Method Summary collapse
-
#initialize(elasticgraph_graphql:, config:) ⇒ ForSingleId
constructor
A new instance of ForSingleId.
- #resolve(field:, object:, args:, context:) ⇒ Object
Constructor Details
#initialize(elasticgraph_graphql:, config:) ⇒ ForSingleId
Returns a new instance of ForSingleId.
22 23 24 25 |
# File 'lib/elastic_graph/apollo/graphql/apollo_entity_ref_resolver.rb', line 22 def initialize(elasticgraph_graphql:, config:) @source_id_field = config.fetch(:source_id_field) @exposed_id_field = config.fetch(:exposed_id_field) end |
Instance Method Details
#resolve(field:, object:, args:, context:) ⇒ Object
27 28 29 30 31 |
# File 'lib/elastic_graph/apollo/graphql/apollo_entity_ref_resolver.rb', line 27 def resolve(field:, object:, args:, context:) if (id = object.fetch(@source_id_field)) {@exposed_id_field => id} end end |