Class: GraphqlRails::Model::DirectFieldResolver
- Inherits:
-
Object
- Object
- GraphqlRails::Model::DirectFieldResolver
- Defined in:
- lib/graphql_rails/model/direct_field_resolver.rb
Overview
Takes shortcuts for simple cases to minimize allocations
Class Method Summary collapse
- .call(model:, attribute_config:, method_keyword_arguments:, graphql_context:) ⇒ Object
- .simple_resolver(model:, graphql_context:, property:) ⇒ Object
Class Method Details
.call(model:, attribute_config:, method_keyword_arguments:, graphql_context:) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/graphql_rails/model/direct_field_resolver.rb', line 8 def call(model:, attribute_config:, method_keyword_arguments:, graphql_context:) property = attribute_config.property if method_keyword_arguments.empty? && !attribute_config.paginated? return simple_resolver(model: model, graphql_context: graphql_context, property: property) end CallGraphqlModelMethod.call( model: model, attribute_config: attribute_config, method_keyword_arguments: method_keyword_arguments, graphql_context: graphql_context ) end |
.simple_resolver(model:, graphql_context:, property:) ⇒ Object
23 24 25 26 27 |
# File 'lib/graphql_rails/model/direct_field_resolver.rb', line 23 def simple_resolver(model:, graphql_context:, property:) return model.send(property) unless model.respond_to?(:with_graphql_context) model.with_graphql_context(graphql_context) { model.send(property) } end |