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
- DeprecatedDirective
- IncludeDirective
- LOCATIONS
- LOCATION_DESCRIPTIONS
- SkipDirective
Attributes
arguments[RW]
arguments_class[RW]
ast_node[RW]
default_directive[W]
@api private
description[RW]
graphql_name[RW]
locations[RW]
name[RW]
Public Class Methods
new()
click to toggle source
# File lib/graphql/directive.rb, line 69 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 91 def default_directive? @default_directive end
get_argument(argument_name)
click to toggle source
# File lib/graphql/directive.rb, line 103 def get_argument(argument_name) arguments[argument_name] end
inspect()
click to toggle source
# File lib/graphql/directive.rb, line 95 def inspect "#<GraphQL::Directive #{name}>" end
on_field?()
click to toggle source
# File lib/graphql/directive.rb, line 78 def on_field? locations.include?(FIELD) end
on_fragment?()
click to toggle source
# File lib/graphql/directive.rb, line 82 def on_fragment? locations.include?(FRAGMENT_SPREAD) && locations.include?(INLINE_FRAGMENT) end
on_operation?()
click to toggle source
# File lib/graphql/directive.rb, line 86 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 74 def to_s "<GraphQL::Directive #{name}>" end
type_class()
click to toggle source
# File lib/graphql/directive.rb, line 99 def type_class metadata[:type_class] end