Module: GraphQL::Models
- Defined in:
- lib/graphql/activerecord.rb,
lib/graphql/models/loader.rb,
lib/graphql/models/definer.rb,
lib/graphql/models/mutator.rb,
lib/graphql/models/version.rb,
lib/graphql/models/object_type.rb,
lib/graphql/models/proxy_block.rb,
lib/graphql/models/scalar_types.rb,
lib/graphql/models/backed_by_model.rb,
lib/graphql/models/definition_helpers.rb,
lib/graphql/models/mutation_field_map.rb,
lib/graphql/models/relation_load_request.rb,
lib/graphql/models/active_record_extension.rb,
lib/graphql/models/association_load_request.rb,
lib/graphql/models/mutation_helpers/validation.rb,
lib/graphql/models/promise_relation_connection.rb,
lib/graphql/models/definition_helpers/attributes.rb,
lib/graphql/models/mutation_helpers/apply_changes.rb,
lib/graphql/models/mutation_helpers/authorization.rb,
lib/graphql/models/definition_helpers/associations.rb,
lib/graphql/models/mutation_helpers/validation_error.rb,
lib/graphql/models/mutation_helpers/print_input_fields.rb
Defined Under Namespace
Modules: ActiveRecordExtension, DefinitionHelpers, MutationHelpers, ObjectType, ScalarTypes Classes: AssociationLoadRequest, BackedByModel, Definer, Loader, Middleware, MutationFieldMap, Mutator, MutatorDefinition, PromiseRelationConnection, ProxyBlock, RelationLoadRequest
Constant Summary collapse
- VERSION =
"0.6.2"
Class Attribute Summary collapse
-
.authorize ⇒ Object
Returns the value of attribute authorize.
-
.id_for_model ⇒ Object
Returns the value of attribute id_for_model.
-
.model_from_id ⇒ Object
Returns the value of attribute model_from_id.
-
.node_interface_proc ⇒ Object
Returns the value of attribute node_interface_proc.
Class Method Summary collapse
- .authorize!(context, model, action) ⇒ Object
- .define_mutator(definer, model_type, null_behavior:, &block) ⇒ Object
- .field_info(graph_type, field_name) ⇒ Object
-
.load_association(starting_model, path, context) ⇒ Object
Returns a promise that will traverse the associations and resolve to the model at the end of the path.
- .load_relation(relation) ⇒ Object
Class Attribute Details
.authorize ⇒ Object
Returns the value of attribute authorize.
36 37 38 |
# File 'lib/graphql/activerecord.rb', line 36 def end |
.id_for_model ⇒ Object
Returns the value of attribute id_for_model.
36 37 38 |
# File 'lib/graphql/activerecord.rb', line 36 def id_for_model @id_for_model end |
.model_from_id ⇒ Object
Returns the value of attribute model_from_id.
36 37 38 |
# File 'lib/graphql/activerecord.rb', line 36 def model_from_id @model_from_id end |
.node_interface_proc ⇒ Object
Returns the value of attribute node_interface_proc.
36 37 38 |
# File 'lib/graphql/activerecord.rb', line 36 def node_interface_proc @node_interface_proc end |
Class Method Details
.authorize!(context, model, action) ⇒ Object
61 62 63 |
# File 'lib/graphql/activerecord.rb', line 61 def self.(context, model, action) .call(context, model, action) end |
.define_mutator(definer, model_type, null_behavior:, &block) ⇒ Object
65 66 67 68 69 70 |
# File 'lib/graphql/activerecord.rb', line 65 def self.define_mutator(definer, model_type, null_behavior:, &block) mutator_definition = MutatorDefinition.new(model_type, null_behavior: null_behavior) mutator_definition.field_map.instance_exec(&block) MutationHelpers.print_input_fields(mutator_definition.field_map, definer, model_type.name) mutator_definition end |
.field_info(graph_type, field_name) ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'lib/graphql/activerecord.rb', line 52 def self.field_info(graph_type, field_name) field_name = field_name.to_s = graph_type.instance_variable_get(:@field_metadata) return nil unless [field_name] end |
.load_association(starting_model, path, context) ⇒ Object
Returns a promise that will traverse the associations and resolve to the model at the end of the path. You can use this to access associated models inside custom field resolvers, without losing optimization benefits.
42 43 44 45 |
# File 'lib/graphql/activerecord.rb', line 42 def self.load_association(starting_model, path, context) path = Array.wrap(path) GraphQL::Models::DefinitionHelpers.load_and_traverse(starting_model, path, context) end |
.load_relation(relation) ⇒ Object
47 48 49 50 |
# File 'lib/graphql/activerecord.rb', line 47 def self.load_relation(relation) request = RelationLoadRequest.new(relation) request.load end |