Class: GraphQL::Directive
- Inherits:
-
Object
- Object
- GraphQL::Directive
- Defined in:
- lib/graphql/directive.rb
Overview
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.
Constant Summary collapse
- LOCATIONS =
[ ON_OPERATION = :on_operation?, ON_FRAGMENT = :on_fragment?, ON_FIELD = :on_field?, ]
- SkipDirective =
GraphQL::Directive.define do name "skip" description "Ignore this part of the query if `if` is true" on([GraphQL::Directive::ON_FIELD, GraphQL::Directive::ON_FRAGMENT]) argument :if, !GraphQL::BOOLEAN_TYPE resolve -> (arguments, proc) { if !arguments["if"] proc.call else nil end } end
- IncludeDirective =
GraphQL::Directive.define do name "include" description "Include this part of the query if `if` is true" on([GraphQL::Directive::ON_FIELD, GraphQL::Directive::ON_FRAGMENT]) argument :if, !GraphQL::BOOLEAN_TYPE resolve -> (arguments, proc) { if arguments["if"] proc.call else nil end } end
Instance Attribute Summary collapse
-
#arguments ⇒ Object
Returns the value of attribute arguments.
-
#description ⇒ Object
Returns the value of attribute description.
-
#name ⇒ Object
Returns the value of attribute name.
-
#on ⇒ Object
Returns the value of attribute on.
Instance Method Summary collapse
Methods included from GraphQL::DefinitionHelpers::DefinedByConfig
Instance Attribute Details
#arguments ⇒ Object
Returns the value of attribute arguments.
7 8 9 |
# File 'lib/graphql/directive.rb', line 7 def arguments @arguments end |
#description ⇒ Object
Returns the value of attribute description.
7 8 9 |
# File 'lib/graphql/directive.rb', line 7 def description @description end |
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/graphql/directive.rb', line 7 def name @name end |
#on ⇒ Object
Returns the value of attribute on.
7 8 9 |
# File 'lib/graphql/directive.rb', line 7 def on @on end |
Instance Method Details
#resolve(arguments, proc) ⇒ Object
20 21 22 |
# File 'lib/graphql/directive.rb', line 20 def resolve(arguments, proc) @resolve_proc.call(arguments, proc) end |
#resolve=(resolve_proc) ⇒ Object
24 25 26 |
# File 'lib/graphql/directive.rb', line 24 def resolve=(resolve_proc) @resolve_proc = resolve_proc end |
#to_s ⇒ Object
28 29 30 |
# File 'lib/graphql/directive.rb', line 28 def to_s "<GraphQL::Directive #{name}>" end |