Class: GraphQL::Directive
- Inherits:
-
ObjectType
- Object
- ObjectType
- GraphQL::Directive
- Defined in:
- lib/graph_ql/directive.rb
Constant Summary collapse
- LOCATIONS =
[ ON_OPERATION = :on_operation?, ON_FRAGMENT = :on_fragment?, ON_FIELD = :on_field?, ]
Instance Method Summary collapse
- #arguments(new_arguments = nil) ⇒ Object
-
#initialize {|_self, GraphQL::TypeDefiner.instance, GraphQL::FieldDefiner.instance, GraphQL::ArgumentDefiner.instance| ... } ⇒ Directive
constructor
A new instance of Directive.
- #resolve(proc_or_arguments, proc = nil) ⇒ Object
Methods inherited from ObjectType
#fields, #fields=, #inspect, #interfaces, #kind, #to_s
Methods included from Definable
Methods included from NonNullWithBang
Constructor Details
#initialize {|_self, GraphQL::TypeDefiner.instance, GraphQL::FieldDefiner.instance, GraphQL::ArgumentDefiner.instance| ... } ⇒ Directive
Returns a new instance of Directive.
13 14 15 16 17 |
# File 'lib/graph_ql/directive.rb', line 13 def initialize @arguments = {} @on = [] yield(self, GraphQL::TypeDefiner.instance, GraphQL::FieldDefiner.instance, GraphQL::ArgumentDefiner.instance) end |
Instance Method Details
#arguments(new_arguments = nil) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/graph_ql/directive.rb', line 28 def arguments(new_arguments=nil) if !new_arguments.nil? @arguments = new_arguments .reduce({}) {|memo, (k, v)| memo[k.to_s] = v; memo} .each { |k, v| v.respond_to?("name=") && v.name = k} end @arguments end |
#resolve(proc_or_arguments, proc = nil) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/graph_ql/directive.rb', line 19 def resolve(proc_or_arguments, proc=nil) if proc.nil? # resolve is being defined, just set it @resolve_proc = proc_or_arguments else @resolve_proc.call(proc_or_arguments, proc) end end |