File tree 2 files changed +44
-0
lines changed
2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -1211,6 +1211,27 @@ Since the validation of a GraphQL document includes ensuring that any directives
1211
1211
used are defined and used correctly , defining a directive allows for a validator
1212
1212
to be aware of all possible validation rules .
1213
1213
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
+
1214
1235
In this example , a directive is defined which can be used to annotate a
1215
1236
fragment definition :
1216
1237
@@ -1221,3 +1242,15 @@ fragment SomeFragment on SomeType @someAnnotation(arg: "abc") {
1221
1242
someField
1222
1243
}
1223
1244
```
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
+ ```
Original file line number Diff line number Diff line change @@ -201,6 +201,17 @@ enum __DirectiveLocation {
201
201
FRAGMENT_DEFINITION
202
202
FRAGMENT_SPREAD
203
203
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
204
215
}
205
216
```
206
217
You can’t perform that action at this time.
0 commit comments