Sha256: 19de6e56a88846b8f6b0a7b75c2e74970f1ef76772e0b10fbf7160ca761b9028

Contents?: true

Size: 670 Bytes

Versions: 13

Compression:

Stored size: 670 Bytes

Contents

module GraphQL
  module StaticValidation
    class DirectivesAreDefined
      include GraphQL::StaticValidation::Message::MessageHelper

      def validate(context)
        directive_names = context.schema.directives.keys
        context.visitor[GraphQL::Language::Nodes::Directive] << -> (node, parent) {
          validate_directive(node, directive_names, context.errors)
        }
      end

      private

      def validate_directive(ast_directive, directive_names, errors)
        if !directive_names.include?(ast_directive.name)
          errors << message("Directive @#{ast_directive.name} is not defined", ast_directive)
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
graphql-0.17.2 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-0.17.1 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-0.17.0 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-0.16.1 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-0.16.0 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-0.15.3 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-0.15.2 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-0.14.2 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-0.15.1 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-0.15.0 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-0.14.1 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-0.14.0 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-0.13.0 lib/graphql/static_validation/rules/directives_are_defined.rb