Sha256: c34319ce5b45b9ee353fb2aeb967e7405d5a4d69b0903e41eb937e504759ee0b

Contents?: true

Size: 1011 Bytes

Versions: 8

Compression:

Stored size: 1011 Bytes

Contents

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

8 entries across 8 versions & 1 rubygems

Version Path
graphql-1.2.6 lib/graphql/execution/directive_checks.rb
graphql-1.2.5 lib/graphql/execution/directive_checks.rb
graphql-1.2.4 lib/graphql/execution/directive_checks.rb
graphql-1.2.3 lib/graphql/execution/directive_checks.rb
graphql-1.2.2 lib/graphql/execution/directive_checks.rb
graphql-1.2.1 lib/graphql/execution/directive_checks.rb
graphql-1.2.0 lib/graphql/execution/directive_checks.rb
graphql-1.1.0 lib/graphql/execution/directive_checks.rb