Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions validator/imported/spec/UniqueDirectivesPerLocationRule.spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,31 @@
locations:
- {line: 3, column: 15}
- {line: 3, column: 26}
- name: custom repeatable directives in same location
rule: UniqueDirectivesPerLocation
schema: |
directive @customRepeatable repeatable on FIELD
type Query {
field: String
}
query: |
{
field @customRepeatable @customRepeatable
}
errors: []
- name: duplicate custom non-repeatable directives in one location
rule: UniqueDirectivesPerLocation
schema: |
directive @customNonRepeatable on FIELD
type Query {
field: String
}
query: |
{
field @customNonRepeatable @customNonRepeatable
}
errors:
- message: The directive "@customNonRepeatable" can only be used once at this location.
locations:
- {line: 2, column: 13}
- {line: 2, column: 35}
2 changes: 1 addition & 1 deletion validator/rules/unique_directives_per_location.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var UniqueDirectivesPerLocationRule = Rule{
seen := map[string]bool{}

for _, dir := range directives {
if dir.Name != "repeatable" && seen[dir.Name] {
if (dir.Definition == nil || !dir.Definition.IsRepeatable) && seen[dir.Name] {
addError(
Message(
`The directive "@%s" can only be used once at this location.`,
Expand Down