module GraphQL::StaticValidation::UniqueDirectivesPerLocation
Constants
- DIRECTIVE_NODE_HOOKS
Private Instance Methods
validate_directive_location(node)
click to toggle source
# File lib/graphql/static_validation/rules/unique_directives_per_location.rb, line 33 def validate_directive_location(node) used_directives = {} node.directives.each do |ast_directive| directive_name = ast_directive.name if used_directives[directive_name] add_error(GraphQL::StaticValidation::UniqueDirectivesPerLocationError.new( "The directive \"#{directive_name}\" can only be used once at this location.", nodes: [used_directives[directive_name], ast_directive], directive: directive_name, )) elsif !((dir_defn = context.schema_directives[directive_name]) && dir_defn.repeatable?) used_directives[directive_name] = ast_directive end end end