Sha256: 9317b0a164c94539263f6b92112aa88e5b5c35c9f0405e3861301a2bfef85b4b

Contents?: true

Size: 941 Bytes

Versions: 13

Compression:

Stored size: 941 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

      # This covers `@include(if:)` & `@skip(if:)`
      # @return [Boolean] Should this node be skipped altogether?
      def skip?(irep_node, query)
        irep_node.directives.each do |directive_node|
          if directive_node.name == SKIP || directive_node.name == INCLUDE
            directive_defn = directive_node.definitions.first
            args = query.arguments_for(directive_node, directive_defn)
            if !directive_defn.include?(args)
              return true
            end
          end
        end
        false
      end

      # @return [Boolean] Should this node be included in the query?
      def include?(irep_node, query)
        !skip?(irep_node, query)
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
graphql-0.18.14 lib/graphql/execution/directive_checks.rb
graphql-0.18.13 lib/graphql/execution/directive_checks.rb
graphql-0.18.12 lib/graphql/execution/directive_checks.rb
graphql-0.18.11 lib/graphql/execution/directive_checks.rb
graphql-0.18.10 lib/graphql/execution/directive_checks.rb
graphql-0.18.9 lib/graphql/execution/directive_checks.rb
graphql-0.18.8 lib/graphql/execution/directive_checks.rb
graphql-0.18.7 lib/graphql/execution/directive_checks.rb
graphql-0.18.6 lib/graphql/execution/directive_checks.rb
graphql-0.18.5 lib/graphql/execution/directive_checks.rb
graphql-0.18.4 lib/graphql/execution/directive_checks.rb
graphql-0.18.3 lib/graphql/execution/directive_checks.rb
graphql-0.18.2 lib/graphql/execution/directive_checks.rb