File tree 1 file changed +20
-8
lines changed
1 file changed +20
-8
lines changed Original file line number Diff line number Diff line change @@ -201,19 +201,31 @@ fragment definedOnImplementorsButNotInterface on Pet {
201
201
}
202
202
```
203
203
204
- Because fields are not declared on unions, direct field selection on
205
- union-typed selection set. This is true even if concrete
206
- implementors of the union define the fieldName.
204
+ Because unions do not define fields, fields may not be directly selected from a
205
+ union-typed selection set, with the exception of the meta-field {__ typename}.
206
+ Fields from a union-typed selection set must only be queried indirectly via
207
+ a fragment.
207
208
208
- For example the following is invalid
209
+ For example the following is valid:
209
210
210
- ``` !graphql
211
- fragment directFieldSelectionOnUnion on CatOrDog {
212
- directField
211
+ ``` graphql
212
+ fragment inDirectFieldSelectionOnUnion on CatOrDog {
213
+ __typename
214
+ ... on Pet {
215
+ name
216
+ }
217
+ ... on Dog {
218
+ barkVolume
219
+ }
213
220
}
221
+ ```
222
+
223
+ But the following is invalid:
214
224
215
- fragment definedOnImplementorsQueriedOnUnion on CatOrDog {
225
+ ``` !graphql
226
+ fragment directFieldSelectionOnUnion on CatOrDog {
216
227
name
228
+ barkVolume
217
229
}
218
230
```
219
231
You can’t perform that action at this time.
0 commit comments