Fragments On Composite Types
Formal Specification
- For each fragment defined in the document.
- The target type of fragment must have kind UNION , INTERFACE , or OBJECT .
Explanatory Text
Fragments can only be declared on unions, interfaces, and objects. They are invalid on scalars. They can only be applied on non‐leaf fields. This rule applies to both inline and named fragments.
The following fragment declarations are valid:
fragment fragOnObject on Dog {
name
}
fragment fragOnInterface on Pet {
name
}
fragment fragOnUnion on CatOrDog {
... on Dog {
name
}
}
and the following are invalid:
fragment fragOnScalar on Int {
something
}
fragment inlineFragOnScalar on Dog {
... on Boolean {
somethingElse
}
}