Sha256: bce745b2f763754deaefe1ffc7854b278383f4674d50e63ffbcc41187453d283

Contents?: true

Size: 1.03 KB

Versions: 93

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

93 entries across 93 versions & 1 rubygems

Version Path
graphql-1.8.18 lib/graphql/execution/directive_checks.rb
graphql-1.9.21 lib/graphql/execution/directive_checks.rb
graphql-1.9.20 lib/graphql/execution/directive_checks.rb
graphql-1.9.19 lib/graphql/execution/directive_checks.rb
graphql-1.9.18 lib/graphql/execution/directive_checks.rb
graphql-1.9.17 lib/graphql/execution/directive_checks.rb
graphql-1.9.16 lib/graphql/execution/directive_checks.rb
graphql-1.9.15 lib/graphql/execution/directive_checks.rb
graphql-1.9.14 lib/graphql/execution/directive_checks.rb
graphql-1.9.13 lib/graphql/execution/directive_checks.rb
graphql-1.9.12 lib/graphql/execution/directive_checks.rb
graphql-1.9.11 lib/graphql/execution/directive_checks.rb
graphql-1.9.10 lib/graphql/execution/directive_checks.rb
graphql-1.9.9 lib/graphql/execution/directive_checks.rb
graphql-1.9.8 lib/graphql/execution/directive_checks.rb
graphql-1.9.7 lib/graphql/execution/directive_checks.rb
graphql-1.9.6 lib/graphql/execution/directive_checks.rb
graphql-1.9.5 lib/graphql/execution/directive_checks.rb
graphql-1.9.4 lib/graphql/execution/directive_checks.rb
graphql-1.9.3 lib/graphql/execution/directive_checks.rb