Module: GraphQL::Execution::DirectiveChecks Private

Defined in:
lib/graphql/execution/directive_checks.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Boolean checks for how an AST node’s directives should influence its execution

Constant Summary collapse

SKIP =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

"skip"
INCLUDE =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

"include"

Class Method Summary collapse

Class Method Details

.include?(directive_ast_nodes, query) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns Should this node be included in the query?.

Returns:

  • (Boolean)

    Should this node be included in the query?



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/graphql/execution/directive_checks.rb', line 14

def include?(directive_ast_nodes, query)
  directive_ast_nodes.each do |directive_ast_node|
    name = directive_ast_node.name
    directive_defn = query.schema.directives[name]
    case name
    when SKIP
      args = query.arguments_for(directive_ast_node, directive_defn)
      if args[:if] == true
        return false
      end
    when INCLUDE
      args = query.arguments_for(directive_ast_node, directive_defn)
      if args[:if] == false
        return false
      end
    else
      # Undefined directive, or one we don't care about
    end
  end
  true
end