Class: GraphQL::Models::ProxyBlock
- Inherits:
-
Object
- Object
- GraphQL::Models::ProxyBlock
- Defined in:
- lib/graphql/models/proxy_block.rb
Instance Method Summary collapse
- #attr(name, **options) ⇒ Object
- #field(*args, &block) ⇒ Object
- #has_many_array(association, **options) ⇒ Object
- #has_many_connection(association, **options) ⇒ Object
- #has_one(association, **options) ⇒ Object
-
#initialize(graph_type, base_model_type, model_type, path, object_to_model) ⇒ ProxyBlock
constructor
A new instance of ProxyBlock.
- #proxy_to(association, &block) ⇒ Object
- #types ⇒ Object
Constructor Details
#initialize(graph_type, base_model_type, model_type, path, object_to_model) ⇒ ProxyBlock
Returns a new instance of ProxyBlock.
4 5 6 7 8 9 10 |
# File 'lib/graphql/models/proxy_block.rb', line 4 def initialize(graph_type, base_model_type, model_type, path, object_to_model) @path = path @base_model_type = base_model_type @model_type = model_type @graph_type = graph_type @object_to_model = object_to_model end |
Instance Method Details
#attr(name, **options) ⇒ Object
16 17 18 |
# File 'lib/graphql/models/proxy_block.rb', line 16 def attr(name, **) DefinitionHelpers.define_attribute(@graph_type, @base_model_type, @model_type, @path, name, @object_to_model, ) end |
#field(*args, &block) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/graphql/models/proxy_block.rb', line 36 def field(*args, &block) defined_field = GraphQL::Define::AssignObjectField.call(@graph_type, *args, &block) DefinitionHelpers.(@graph_type, defined_field.name, { macro: :field, macro_type: :custom, path: @path, base_model_type: @base_model_type, model_type: @model_type, object_to_base_model: @object_to_model }) defined_field end |
#has_many_array(association, **options) ⇒ Object
32 33 34 |
# File 'lib/graphql/models/proxy_block.rb', line 32 def has_many_array(association, **) DefinitionHelpers.define_has_many_array(@graph_type, @base_model_type, @model_type, @path, association, @object_to_model, ) end |
#has_many_connection(association, **options) ⇒ Object
28 29 30 |
# File 'lib/graphql/models/proxy_block.rb', line 28 def has_many_connection(association, **) DefinitionHelpers.define_has_many_connection(@graph_type, @base_model_type, @model_type, @path, association, @object_to_model, ) end |
#has_one(association, **options) ⇒ Object
24 25 26 |
# File 'lib/graphql/models/proxy_block.rb', line 24 def has_one(association, **) DefinitionHelpers.define_has_one(@graph_type, @base_model_type, @model_type, @path, association, @object_to_model, ) end |
#proxy_to(association, &block) ⇒ Object
20 21 22 |
# File 'lib/graphql/models/proxy_block.rb', line 20 def proxy_to(association, &block) DefinitionHelpers.define_proxy(@graph_type, @base_model_type, @model_type, @path, association, @object_to_model, &block) end |
#types ⇒ Object
12 13 14 |
# File 'lib/graphql/models/proxy_block.rb', line 12 def types GraphQL::Define::TypeDefiner.instance end |