Module: GraphqlConnector::ServiceClassable::Queryable
- Defined in:
- lib/graphql_connector/service_classable/queryable.rb
Overview
Module that allows to build query methods within the context of service class
Constant Summary collapse
- BINDINGS =
'binding.local_variables.map do |var| [var, binding.local_variable_get(var)] end.to_h'
Instance Method Summary collapse
- #add_mutation(params: [], httparty_adapter_options: {}, returns:, **method_to_query) ⇒ Object
- #add_query(params: [], httparty_adapter_options: {}, returns:, **method_to_query) ⇒ Object
- #add_raw_query(params: [], httparty_adapter_options: {}, **method_to_raw_query) ⇒ Object
Instance Method Details
#add_mutation(params: [], httparty_adapter_options: {}, returns:, **method_to_query) ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/graphql_connector/service_classable/queryable.rb', line 34 def add_mutation(params: [], httparty_adapter_options: {}, returns:, **method_to_query) class_method_name, query_type = parse_variables(method_to_query) ensure_params_format!(returns, class_method_name, query_type) ParamsValidator.validate(params) unless params.empty? signature = method_signature(class_method_name, params) signature[:graphql_method_type] = :mutation create_method(signature, query_type, returns, ) end |
#add_query(params: [], httparty_adapter_options: {}, returns:, **method_to_query) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/graphql_connector/service_classable/queryable.rb', line 12 def add_query(params: [], httparty_adapter_options: {}, returns:, **method_to_query) class_method_name, query_type = parse_variables(method_to_query) ensure_params_format!(returns, class_method_name, query_type) ParamsValidator.validate(params) unless params.empty? signature = method_signature(class_method_name, params) signature[:graphql_method_type] = :query create_method(signature, query_type, returns, ) end |
#add_raw_query(params: [], httparty_adapter_options: {}, **method_to_raw_query) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/graphql_connector/service_classable/queryable.rb', line 23 def add_raw_query(params: [], httparty_adapter_options: {}, **method_to_raw_query) class_method_name, query_string = parse_variables(method_to_raw_query) ClassMethodValidator.validate_class_method(class_method_name, self) ClassMethodValidator.validate_element_class_type(query_string, String) ParamsValidator.validate(params) unless params.empty? signature = method_signature(class_method_name, params) raw_query_method(signature, query_string, ) end |