diff --git a/spec/Section 5 -- Validation.md b/spec/Section 5 -- Validation.md index 75af96ffd..c71a40931 100644 --- a/spec/Section 5 -- Validation.md +++ b/spec/Section 5 -- Validation.md @@ -332,6 +332,41 @@ contain any number of operations, each of which may contain different root fields. When executed, a document containing multiple subscription operations must provide the operation name as described in {GetOperation()}. +### Operation Type Exists + +#### Formal Specification + +For each operation definition in the document: + +- Let {operationType} be the type of the operation (`query`, `mutation`, or + `subscription`). +- The corresponding _root operation type_ for {operationType} must be defined in + the schema. + +#### Explanatory Text + +A schema defines the root operation types that it supports. Any document that +contains an operation of a type unsupported by the schema is invalid, since such +an operation cannot be executed. + +While query operations are required for all schemas, mutation and subscription +operations are optional. If the schema does not include the necessary type for a +mutation or subscription operation defined in the document, it will be +considered invalid. + +For example, the following document is valid if the schema includes a Mutation +type, but invalid if it does not: + +```graphql example +mutation { + likeStory(storyID: 12345) { + story { + likeCount + } + } +} +``` + ## Fields ### Field Selections