Class: Stardust::GraphQL::Mutation
- Inherits:
-
GraphQL::Schema::Mutation
- Object
- GraphQL::Schema::Mutation
- Stardust::GraphQL::Mutation
- Defined in:
- lib/stardust/graphql/mutation.rb
Class Method Summary collapse
- .argument(name, type, description = nil, loads: nil, **kwargs) ⇒ Object
- .field(name, type, description = nil, **kwargs) ⇒ Object
- .get_null ⇒ Object
- .replace_types! ⇒ Object
- .resolve_method ⇒ Object
Instance Method Summary collapse
Class Method Details
.argument(name, type, description = nil, loads: nil, **kwargs) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/stardust/graphql/mutation.rb', line 13 def self.argument(name, type, description = nil, loads: nil, **kwargs) @__types_to_lookup__ ||= [] the_file = caller[0][/[^:]+/].gsub(Rails.root.to_s, "") the_line = caller[0].split(":")[1] @__types_to_lookup__ << lambda { |klass| begin actual_type = Collector.lookup_type(type) kwargs[:prepare] = ->(obj, _ctx) { loads.find(obj) } if loads klass.method(:argument) .super_method .call(name, actual_type, description, **kwargs) rescue MissingType => e warn <<~TEXT Stardust Compilation Warning - MESSAGE: Type #{e.} is not defined. - RESULT: This mutation is not added to the graph. - FILE: #{the_file} - LINE: #{the_line} TEXT end } end |
.field(name, type, description = nil, **kwargs) ⇒ Object
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/stardust/graphql/mutation.rb', line 40 def self.field(name, type, description = nil, **kwargs) @__types_to_lookup__ ||= [] @__types_to_lookup__ << lambda { |klass| actual_type = Collector.lookup_type(type) klass.method(:field) .super_method .call(name, actual_type, description, **kwargs) } end |
.get_null ⇒ Object
9 10 11 |
# File 'lib/stardust/graphql/mutation.rb', line 9 def self.get_null @null end |
.replace_types! ⇒ Object
51 52 53 54 |
# File 'lib/stardust/graphql/mutation.rb', line 51 def self.replace_types! return unless @__types_to_lookup__ @__types_to_lookup__.each { |lookup| lookup.call(self) } end |
.resolve_method ⇒ Object
56 57 58 |
# File 'lib/stardust/graphql/mutation.rb', line 56 def self.resolve_method :resolve_wrapper end |