Sha256: 4447488bf6b67b5bfcfc5cf301305f59a0fde79bd835690dc3826ef65a278acf

Contents?: true

Size: 807 Bytes

Versions: 56

Compression:

Stored size: 807 Bytes

Contents

# frozen_string_literal: true
module GraphQL
  module StaticValidation
    module DirectivesAreDefined
      def initialize(*)
        super
        @directive_names = context.warden.directives.map(&:graphql_name)
      end

      def on_directive(node, parent)
        if !@directive_names.include?(node.name)
          @directives_are_defined_errors_by_name ||= {}
          error = @directives_are_defined_errors_by_name[node.name] ||= begin
            err = GraphQL::StaticValidation::DirectivesAreDefinedError.new(
              "Directive @#{node.name} is not defined",
              nodes: [],
              directive: node.name
            )
            add_error(err)
            err
          end
          error.nodes << node
        else
          super
        end
      end
    end
  end
end

Version data entries

56 entries across 56 versions & 1 rubygems

Version Path
graphql-2.2.16 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-2.1.13 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-2.3.7 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-2.3.6 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-2.3.5 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-2.0.31 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-2.3.2 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-2.3.1 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-2.3.0 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-2.2.14 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-2.2.13 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-2.2.12 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-2.0.29 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-2.1.12 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-2.2.11 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-2.2.10 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-2.2.9 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-2.2.8 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-2.2.7 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-2.2.6 lib/graphql/static_validation/rules/directives_are_defined.rb