class GraphQL::Directive
Directives are server-defined hooks for modifying execution.
Two directives are included out-of-the-box:
-
`@skip(if: …)` Skips the tagged field if the value of `if` is true
-
`@include(if: …)` Includes the tagged field only if `if` is true
Constants
- DEFAULT_DEPRECATION_REASON
- DeprecatedDirective
- IncludeDirective
- LOCATIONS
- LOCATION_DESCRIPTIONS
- SkipDirective
Attributes
arguments[RW]
arguments_class[RW]
ast_node[RW]
default_directive[W]
@api private
description[RW]
locations[RW]
name[RW]
Public Class Methods
new()
click to toggle source
# File lib/graphql/directive.rb, line 62 def initialize @arguments = {} @default_directive = false end
Public Instance Methods
default_directive?()
click to toggle source
@return [Boolean] Is this directive supplied by default? (eg `@skip`)
# File lib/graphql/directive.rb, line 84 def default_directive? @default_directive end
on_field?()
click to toggle source
# File lib/graphql/directive.rb, line 71 def on_field? locations.include?(FIELD) end
on_fragment?()
click to toggle source
# File lib/graphql/directive.rb, line 75 def on_fragment? locations.include?(FRAGMENT_SPREAD) && locations.include?(INLINE_FRAGMENT) end
on_operation?()
click to toggle source
# File lib/graphql/directive.rb, line 79 def on_operation? locations.include?(QUERY) && locations.include?(MUTATION) && locations.include?(SUBSCRIPTION) end
to_s()
click to toggle source
# File lib/graphql/directive.rb, line 67 def to_s "<GraphQL::Directive #{name}>" end