Sha256: f621892b380beeceffe1ca0505fc294df8cdff309f244d313e9541a94a686271
Contents?: true
Size: 1.35 KB
Versions: 2
Compression:
Stored size: 1.35 KB
Contents
# This implementation of `Directive` is ... not robust. # It seems like this area of the spec is still getting worked out, so # {Directive} & {DirectiveChain} implement `@skip` and `@include` with # minimal impact on query execution. class GraphQL::Directive extend GraphQL::DefinitionHelpers::Definable attr_definable :on, :arguments, :name, :description LOCATIONS = [ ON_OPERATION = :on_operation?, ON_FRAGMENT = :on_fragment?, ON_FIELD = :on_field?, ] LOCATIONS.each do |location| define_method(location) { self.on.include?(location) } end def initialize @arguments = {} @on = [] yield( self, GraphQL::DefinitionHelpers::TypeDefiner.instance, GraphQL::DefinitionHelpers::FieldDefiner.instance, GraphQL::DefinitionHelpers::ArgumentDefiner.instance ) end 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 def arguments(new_arguments=nil) if !new_arguments.nil? @arguments = GraphQL::DefinitionHelpers::StringNamedHash.new(new_arguments).to_h end @arguments end def to_s "<GraphQL::Directive #{name}>" end end require 'graph_ql/directive/include_directive' require 'graph_ql/directive/skip_directive'
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
graphql-0.5.0 | lib/graph_ql/directive.rb |
graphql-0.4.0 | lib/graph_ql/directive.rb |