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.1.11 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-2.0.28 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-2.2.5 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-2.2.4 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-2.2.3 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-2.1.10 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-2.2.2 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-2.1.9 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-2.2.1 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-2.2.0 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-2.1.8 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-2.1.7 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-2.1.6 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-2.1.5 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-2.1.4 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-2.1.3 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-2.1.2 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-2.1.1 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-2.1.0 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-2.0.27 lib/graphql/static_validation/rules/directives_are_defined.rb