File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -1169,6 +1169,27 @@ Since the validation of a GraphQL document includes ensuring that any directives
1169
1169
used are defined and used correctly , defining a directive allows for a validator
1170
1170
to be aware of all possible validation rules .
1171
1171
1172
+ As part of validation , directives are only allowed to be used in locations
1173
+ that are explicitly declared . Directive locations must be one of :
1174
+
1175
+ * `QUERY `
1176
+ * `MUTATION `
1177
+ * `FIELD `
1178
+ * `FRAGMENT_DEFINITION `
1179
+ * `FRAGMENT_SPREAD `
1180
+ * `INLINE_FRAGMENT `
1181
+ * `SCHEMA `
1182
+ * `SCALAR `
1183
+ * `OBJECT `
1184
+ * `FIELD_DEFINITION `
1185
+ * `ARGUMENT_DEFINITION `
1186
+ * `INTERFACE `
1187
+ * `UNION `
1188
+ * `ENUM `
1189
+ * `ENUM_VALUE `
1190
+ * `INPUT_OBJECT `
1191
+ * `INPUT_FIELD_DEFINITION `
1192
+
1172
1193
In this example , a directive is defined which can be used to annotate a
1173
1194
fragment definition :
1174
1195
@@ -1179,3 +1200,15 @@ fragment SomeFragment on SomeType @someAnnotation(arg: "abc") {
1179
1200
someField
1180
1201
}
1181
1202
```
1203
+
1204
+ Directives can also be used to annotate the schema language itself:
1205
+
1206
+ ```
1207
+ directive @some(thing: Int) on FIELD_DEFINITION | ARGUMENT_DEFINITION
1208
+
1209
+ type SomeType {
1210
+ field(
1211
+ arg: Int @some(thing: 1)
1212
+ ): String @some(thing: 2)
1213
+ }
1214
+ ```
Original file line number Diff line number Diff line change @@ -198,6 +198,17 @@ enum __DirectiveLocation {
198
198
FRAGMENT_DEFINITION
199
199
FRAGMENT_SPREAD
200
200
INLINE_FRAGMENT
201
+ SCHEMA
202
+ SCALAR
203
+ OBJECT
204
+ FIELD_DEFINITION
205
+ ARGUMENT_DEFINITION
206
+ INTERFACE
207
+ UNION
208
+ ENUM
209
+ ENUM_VALUE
210
+ INPUT_OBJECT
211
+ INPUT_FIELD_DEFINITION
201
212
}
202
213
```
203
214
You can’t perform that action at this time.
0 commit comments