Fragment Spread Type Existence
Formal Specification
- For each named spread namedSpread in the document
- Let fragment be the target of namedSpread
- The target type of fragment must be defined in the schema
Explanatory Text
Fragments must be specified on types that exist in the schema. This applies for both named and inline fragments. If they are not defined in the schema, the query does not validate.
For example the following fragments are valid:
fragment correctType on Dog {
name
}
fragment inlineFragment on Dog {
... on Dog {
name
}
}
fragment inlineFragment2 on Dog {
... @include(if: true) {
name
}
}
and the following do not validate:
fragment notOnExistingType on NotInSchema {
name
}
fragment inlineNotExistingType on Dog {
... on NotInSchema {
name
}
}