Skip to content

Commit 6dac159

Browse files
committed
Include more directive locations
1 parent ceb95e3 commit 6dac159

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

spec/Section 2 -- Language.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,6 +1211,27 @@ Since the validation of a GraphQL document includes ensuring that any directives
12111211
used are defined and used correctly, defining a directive allows for a validator
12121212
to be aware of all possible validation rules.
12131213

1214+
As part of validation, directives are only allowed to be used in locations
1215+
that are explicitly declared. Directive locations must be one of:
1216+
1217+
* `QUERY`
1218+
* `MUTATION`
1219+
* `FIELD`
1220+
* `FRAGMENT_DEFINITION`
1221+
* `FRAGMENT_SPREAD`
1222+
* `INLINE_FRAGMENT`
1223+
* `SCHEMA`
1224+
* `SCALAR`
1225+
* `OBJECT`
1226+
* `FIELD_DEFINITION`
1227+
* `ARGUMENT_DEFINITION`
1228+
* `INTERFACE`
1229+
* `UNION`
1230+
* `ENUM`
1231+
* `ENUM_VALUE`
1232+
* `INPUT_OBJECT`
1233+
* `INPUT_FIELD_DEFINITION`
1234+
12141235
In this example, a directive is defined which can be used to annotate a
12151236
fragment definition:
12161237

@@ -1221,3 +1242,15 @@ fragment SomeFragment on SomeType @someAnnotation(arg: "abc") {
12211242
someField
12221243
}
12231244
```
1245+
1246+
Directives can also be used to annotate the schema language itself:
1247+
1248+
```
1249+
directive @some(thing: Int) on FIELD_DEFINITION | ARGUMENT_DEFINITION
1250+
1251+
type SomeType {
1252+
field(
1253+
arg: Int @some(thing: 1)
1254+
): String @some(thing: 2)
1255+
}
1256+
```

spec/Section 4 -- Introspection.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,17 @@ enum __DirectiveLocation {
201201
FRAGMENT_DEFINITION
202202
FRAGMENT_SPREAD
203203
INLINE_FRAGMENT
204+
SCHEMA
205+
SCALAR
206+
OBJECT
207+
FIELD_DEFINITION
208+
ARGUMENT_DEFINITION
209+
INTERFACE
210+
UNION
211+
ENUM
212+
ENUM_VALUE
213+
INPUT_OBJECT
214+
INPUT_FIELD_DEFINITION
204215
}
205216
```
206217

0 commit comments

Comments
 (0)