9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/graphql/static_validation/rules/directives_are_defined.rb', line 9
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
|