Sha256: 6a8e14d10b65e6e00afd8a4ca6b7da52825ca7bd3755abe2539759c4d7216baf

Contents?: true

Size: 948 Bytes

Versions: 23

Compression:

Stored size: 948 Bytes

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
  include GraphQL::DefinitionHelpers::DefinedByConfig
  attr_accessor :on, :arguments, :name, :description
  defined_by_config :on, :arguments, :name, :description, :resolve

  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 resolve(arguments, proc)
    @resolve_proc.call(arguments, proc)
  end

  def resolve=(resolve_proc)
    @resolve_proc = resolve_proc
  end

  def to_s
    "<GraphQL::Directive #{name}>"
  end
end

require 'graphql/directive/include_directive'
require 'graphql/directive/skip_directive'

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
graphql-0.11.1 lib/graphql/directive.rb
graphql-0.11.0 lib/graphql/directive.rb
graphql-0.10.9 lib/graphql/directive.rb
graphql-0.10.8 lib/graphql/directive.rb
graphql-0.10.7 lib/graphql/directive.rb
graphql-0.10.6 lib/graphql/directive.rb
graphql-0.10.5 lib/graphql/directive.rb
graphql-0.10.4 lib/graphql/directive.rb
graphql-0.10.3 lib/graphql/directive.rb
graphql-0.10.2 lib/graphql/directive.rb
graphql-0.10.1 lib/graphql/directive.rb
graphql-0.10.0 lib/graphql/directive.rb
graphql-0.9.5 lib/graphql/directive.rb
graphql-0.9.4 lib/graphql/directive.rb
graphql-0.9.3 lib/graphql/directive.rb
graphql-0.9.2 lib/graphql/directive.rb
graphql-0.8.1 lib/graphql/directive.rb
graphql-0.8.0 lib/graphql/directive.rb
graphql-0.7.1 lib/graphql/directive.rb
graphql-0.7.0 lib/graphql/directive.rb