Sha256: 132c8f84b84381f23eb4cf09e8b6d971439b961cb38c5d60e52cbfc9cced2402

Contents?: true

Size: 1.03 KB

Versions: 171

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true
module GraphQL
  module Execution
    # Boolean checks for how an AST node's directives should
    # influence its execution
    # @api private
    module DirectiveChecks
      SKIP = "skip"
      INCLUDE = "include"

      module_function

      # @return [Boolean] Should this node be included in the query?
      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
    end
  end
end

Version data entries

171 entries across 171 versions & 2 rubygems

Version Path
graphql-2.4.9 lib/graphql/execution/directive_checks.rb
graphql-2.4.8 lib/graphql/execution/directive_checks.rb
graphql-2.4.7 lib/graphql/execution/directive_checks.rb
graphql-2.4.6 lib/graphql/execution/directive_checks.rb
graphql-2.4.5 lib/graphql/execution/directive_checks.rb
graphql-2.4.4 lib/graphql/execution/directive_checks.rb
graphql-2.4.3 lib/graphql/execution/directive_checks.rb
graphql-2.4.2 lib/graphql/execution/directive_checks.rb
graphql-2.4.1 lib/graphql/execution/directive_checks.rb
graphql-2.4.0 lib/graphql/execution/directive_checks.rb
graphql-2.3.20 lib/graphql/execution/directive_checks.rb
graphql-2.3.19 lib/graphql/execution/directive_checks.rb
graphql-2.3.18 lib/graphql/execution/directive_checks.rb
graphql-2.3.17 lib/graphql/execution/directive_checks.rb
graphql-2.3.16 lib/graphql/execution/directive_checks.rb
graphql-2.3.15 lib/graphql/execution/directive_checks.rb
graphql-2.3.14 lib/graphql/execution/directive_checks.rb
graphql-2.3.13 lib/graphql/execution/directive_checks.rb
graphql-2.3.12 lib/graphql/execution/directive_checks.rb
graphql-2.3.11 lib/graphql/execution/directive_checks.rb