Sha256: 732ebed4b5f8062c9eff6ae17917fc8f38f30f34438b9fb30fd3d49c55092afa

Contents?: true

Size: 1.02 KB

Versions: 7

Compression:

Stored size: 1.02 KB

Contents

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

      module_function

      # @return [Boolean] Should this node be included in the query?
      def include?(directive_irep_nodes, query)
        directive_irep_nodes.each do |directive_irep_node|
          name = directive_irep_node.name
          directive_defn = query.schema.directives[name]
          case name
          when SKIP
            args = query.arguments_for(directive_irep_node, directive_defn)
            if args['if'] == true
              return false
            end
          when INCLUDE
            args = query.arguments_for(directive_irep_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

7 entries across 7 versions & 1 rubygems

Version Path
graphql-1.4.5 lib/graphql/execution/directive_checks.rb
graphql-1.4.4 lib/graphql/execution/directive_checks.rb
graphql-1.4.3 lib/graphql/execution/directive_checks.rb
graphql-1.4.2 lib/graphql/execution/directive_checks.rb
graphql-1.4.1 lib/graphql/execution/directive_checks.rb
graphql-1.4.0 lib/graphql/execution/directive_checks.rb
graphql-1.3.0 lib/graphql/execution/directive_checks.rb