Sha256: 132c8f84b84381f23eb4cf09e8b6d971439b961cb38c5d60e52cbfc9cced2402

Contents?: true

Size: 1.03 KB

Versions: 187

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

187 entries across 187 versions & 2 rubygems

Version Path
graphql-2.4.15 lib/graphql/execution/directive_checks.rb
graphql-1.11.12 lib/graphql/execution/directive_checks.rb
graphql-2.4.14 lib/graphql/execution/directive_checks.rb
graphql-2.3.22 lib/graphql/execution/directive_checks.rb
graphql-2.1.15 lib/graphql/execution/directive_checks.rb
graphql-1.11.11 lib/graphql/execution/directive_checks.rb
graphql-1.12.25 lib/graphql/execution/directive_checks.rb
graphql-1.13.24 lib/graphql/execution/directive_checks.rb
graphql-2.0.32 lib/graphql/execution/directive_checks.rb
graphql-2.1.14 lib/graphql/execution/directive_checks.rb
graphql-2.2.17 lib/graphql/execution/directive_checks.rb
graphql-2.3.21 lib/graphql/execution/directive_checks.rb
graphql-2.4.13 lib/graphql/execution/directive_checks.rb
graphql-2.4.12 lib/graphql/execution/directive_checks.rb
graphql-2.4.11 lib/graphql/execution/directive_checks.rb
graphql-2.4.10 lib/graphql/execution/directive_checks.rb
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