Sha256: 420c30dc3e2d50c818e54d3f7376dbb72c3508ee9e2238adbef9a3f386b31d1d

Contents?: true

Size: 578 Bytes

Versions: 4

Compression:

Stored size: 578 Bytes

Contents

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

  def validate(context)
    directive_names = context.schema.directives.keys
    context.visitor[GraphQL::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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
graphql-0.5.0 lib/graph_ql/static_validation/rules/directives_are_defined.rb
graphql-0.4.0 lib/graph_ql/static_validation/rules/directives_are_defined.rb
graphql-0.3.0 lib/graph_ql/static_validation/rules/directives_are_defined.rb
graphql-0.2.0 lib/graph_ql/static_validation/directives_are_defined.rb