Sha256: adc094f8f3a0929e57d19056654cdb5eddc4e1715fd3d42dfaa138d90b19ced5

Contents?: true

Size: 867 Bytes

Versions: 5

Compression:

Stored size: 867 Bytes

Contents

# frozen_string_literal: true
module GraphQL
  module StaticValidation
    module DirectivesAreDefined
      def initialize(*)
        super
      end

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
graphql-2.4.4 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-2.4.3 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-2.4.2 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-2.4.1 lib/graphql/static_validation/rules/directives_are_defined.rb
graphql-2.4.0 lib/graphql/static_validation/rules/directives_are_defined.rb