Skip to content

Commit d80608c

Browse files
committed
Include more directive locations
1 parent de42f08 commit d80608c

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
@@ -1169,6 +1169,27 @@ Since the validation of a GraphQL document includes ensuring that any directives
11691169
used are defined and used correctly, defining a directive allows for a validator
11701170
to be aware of all possible validation rules.
11711171

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+
11721193
In this example, a directive is defined which can be used to annotate a
11731194
fragment definition:
11741195

@@ -1179,3 +1200,15 @@ fragment SomeFragment on SomeType @someAnnotation(arg: "abc") {
11791200
someField
11801201
}
11811202
```
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+
```

spec/Section 4 -- Introspection.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,17 @@ enum __DirectiveLocation {
198198
FRAGMENT_DEFINITION
199199
FRAGMENT_SPREAD
200200
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
201212
}
202213
```
203214

0 commit comments

Comments
 (0)