Skip to content

Add validation rule that operation types exist #955

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions spec/Section 3 -- Type System.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,14 @@ type system where those operations begin.
The {`query`} root operation type must be provided and must be an Object type.

The {`mutation`} root operation type is optional; if it is not provided, the
service does not support mutations. If it is provided, it must be an Object
type.
service does not support mutations (see
[Operation Type Existence](#sec-Operation-Type-Existence)). If it is provided,
it must be an Object type.

Similarly, the {`subscription`} root operation type is also optional; if it is
not provided, the service does not support subscriptions. If it is provided, it
must be an Object type.
not provided, the service does not support subscriptions (see
[Operation Type Existence](#sec-Operation-Type-Existence))s. If it is provided,
it must be an Object type.

The {`query`}, {`mutation`}, and {`subscription`} root types must all be
different types if provided.
Expand Down
40 changes: 40 additions & 0 deletions spec/Section 5 -- Validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,46 @@ extend type Dog {

## Operations

### All Operation Definitions

#### Operation Type Existence

**Formal Specification**

- For each operation definition {operation} in the document.
- Let {operationRootType} be the root type in {schema} corresponding to the type
of {operation}.
- {operationRootType} must exist.

**Explanatory Text**

Each operation must reference an operation type which has a valid root type in
the schema.

For example given the following schema:

```graphql example
type Query {
hello: String
}
```

The following operation is valid:

```graphql example
query helloQuery {
hello
}
```

While the following operation is invalid:

```graphql example
mutation goodbyeMutation {
goodbye
}
```

### Named Operation Definitions

#### Operation Name Uniqueness
Expand Down