Skip to content

Commit 15769c3

Browse files
committed
Make root query operation type optional
This makes the root query operation type optional like the other types. Schema introspection is unaffected. The `__schema` and `__type` fields were already described as "implicit" and not part of the defined root query operation type. A schema without a root query type therefore only supports these queries. Fixes graphql#490
1 parent ae65178 commit 15769c3

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

spec/Section 3 -- Type System.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,11 @@ A schema defines the initial root operation type for each kind of operation it
6969
supports: query, mutation, and subscription; this determines the place in the
7070
type system where those operations begin.
7171

72-
The `query` root operation type must be provided and must be an Object type.
72+
A schema must define at least one root operation type.
73+
74+
The `query` root operation type is optional; if it is not provided, the service
75+
does not support queries except schema introspection. If it is provided, it
76+
must be an Object type.
7377

7478
The `mutation` root operation type is optional; if it is not provided, the
7579
service does not support mutations. If it is provided, it must be an

spec/Section 4 -- Introspection.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,15 @@ __type(name: String!): __Type
111111
```
112112

113113
These fields are implicit and do not appear in the fields list in the root type
114-
of the query operation.
114+
of the query operation. They are available even if the schema does not provide
115+
a query operation of its own.
115116

116117
The schema of the GraphQL schema introspection system:
117118

118119
```graphql
119120
type __Schema {
120121
types: [__Type!]!
121-
queryType: __Type!
122+
queryType: __Type
122123
mutationType: __Type
123124
subscriptionType: __Type
124125
directives: [__Directive!]!

0 commit comments

Comments
 (0)