Sha256: 5f3d163a0c6c12f9bb9c42960de69a8eff6be4556615985617ac5f60ce44f387

Contents?: true

Size: 583 Bytes

Versions: 53

Compression:

Stored size: 583 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)
          add_error(GraphQL::StaticValidation::DirectivesAreDefinedError.new(
            "Directive @#{node.name} is not defined",
            nodes: node,
            directive: node.name
          ))
        else
          super
        end
      end
    end
  end
end

Version data entries

53 entries across 53 versions & 2 rubygems

Version Path
graphql-1.13.23 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-1.13.22 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-1.13.21 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-1.13.20 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-1.13.19 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-1.13.18 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-1.13.17 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-1.13.16 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-2.0.12 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-1.13.15 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-2.0.11 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-1.13.14 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-1.13.13 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-2.0.9 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-2.0.8 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-2.0.7 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql_cody-1.13.0 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-1.13.12 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-2.0.6 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-2.0.5 lib/graphql/static_validation/rules/directives_are_defined.rb