Class: Rails::GraphQL::Source::Base

Inherits:
Rails::GraphQL::Source show all
Extended by:
Helpers::Unregisterable, Helpers::WithAssignment, Helpers::WithSchemaFields
Defined in:
lib/rails/graphql/source/base.rb

Direct Known Subclasses

ActiveRecordSource

Constant Summary

Constants included from Helpers::WithSchemaFields

Helpers::WithSchemaFields::TYPE_FIELD_CLASS

Constants included from Helpers::InheritedCollection

Helpers::InheritedCollection::DEFAULT_TYPES

Constants included from Helpers::WithCallbacks

Helpers::WithCallbacks::DEFAULT_EVENT_TYPES

Instance Attribute Summary

Attributes included from Helpers::Instantiable

#event

Class Method Summary collapse

Methods included from Helpers::WithSchemaFields

[], add_field, add_proxy_field, change_field, configure_field, configure_fields, disable_fields, enable_fields, enabled_fields_from, extended, field_names_for, fields_for, fields_for?, find_by_gid, find_field, find_field!, has_field?, import_all, import_all_into, import_into, safe_add_field, type_name_for, validate!

Methods included from Helpers::WithAssignment

assigned?, assigned_class, assigned_to, assigned_to=, extended, register!, safe_assigned_class, valid_assignment?

Methods included from Helpers::Unregisterable

unregister!

Methods inherited from Rails::GraphQL::Source

attach_fields!, base_name, base_type_class, find_for, find_for!, kind, schemas, step

Methods included from Helpers::InheritedCollection

#inherited_collection

Methods included from Helpers::WithNamespace

#namespace, #namespaces, #set_namespace

Methods included from Helpers::WithEvents

extended, included, #on

Methods included from Helpers::WithCallbacks

extended, included, #on

Methods included from Builder

#build_all, #build_all_sources, #built?, #method_missing, #respond_to_missing?

Class Method Details

.inputObject

Return the GraphQL input type associated with the source. It will create one if it’s not defined yet. The created class will be added to the ::GraphQL namespace with the addition of any namespace of the current class



53
54
55
56
57
# File 'lib/rails/graphql/source/base.rb', line 53

def input
  @input ||= create_type(superclass: input_class, gql_name: input_name).tap do |t|
    t.include(const_get(:InputMethods)) if const_defined?(:InputMethods, false)
  end
end

.objectObject

Return the GraphQL object type associated with the source. It will create one if it’s not defined yet. The created class will be added to the ::GraphQL namespace with the addition of any namespace of the current class



43
44
45
46
47
# File 'lib/rails/graphql/source/base.rb', line 43

def object
  @object ||= create_type(superclass: object_class, gql_name: object_name).tap do |t|
    t.include(const_get(:ObjectMethods)) if const_defined?(:ObjectMethods, false)
  end
end

.unregister!Object

Unregister all objects that this source was providing



34
35
36
37
# File 'lib/rails/graphql/source/base.rb', line 34

def unregister!
  @object = @input = nil
  super
end