Skip to content

Commit f6a508e

Browse files
committed
Merge remote-tracking branch 'jonathanberger/patch-1' into update-schema-docs
2 parents 01beff7 + d06f813 commit f6a508e

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/pages/learn/schema.mdx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,7 @@ Arguments can be either required or optional. When an argument is optional, we c
7575

7676
### The Query, Mutation, and Subscription types
7777

78-
Most types in your schema will just be normal Object types, but there are three special types within a schema:
79-
80-
```graphql
81-
schema {
82-
query: Query
83-
mutation: Mutation
84-
subscription: Subscription
85-
}
86-
```
87-
88-
Every GraphQL service has a `query` [root operation type](https://spec.graphql.org/October2021/#sec-Root-Operation-Types) and may or may not have `mutation` and `subscription` root operation types. These types are the same as a regular Object type, but they are special because they define the _entry point_ of every GraphQL operation. So if you see a query that looks like this:
78+
Every GraphQL schema must support `query` operations. The _entry point_ for this [root operation type](https://spec.graphql.org/October2021/#sec-Root-Operation-Types) is a regular Object type called `Query` by default. So if you see a query that looks like this:
8979

9080
```graphql
9181
# { "graphiql": true }
@@ -104,9 +94,19 @@ type Query {
10494
}
10595
```
10696

107-
Mutations and subscriptions work similarlyyou define fields on the `Mutation` and `Subscription` types, and those are available as the root `mutation` and `subscription` fields you can call in your request.
97+
Schemas may also support `mutation` and `subscription` operations by adding additional `Mutation` and `Subscription` types and then defining fields on the corresponding root operation types.
10898

109-
It's important to remember that apart from the special status of being an entry point into the schema, the `Query`, `Mutation`, and `Subscription` types are the same as any other GraphQL Object type, and their fields work exactly the same way.
99+
It's important to remember that apart from the special status of being entry points into the schema, the `Query`, `Mutation`, and `Subscription` types are the same as any other GraphQL Object type, and their fields work exactly the same way.
100+
101+
You can name your root operation types differently too; if you choose to do so then you will need to inform GraphQL of the new names using the `schema` keyword:
102+
103+
```graphql
104+
schema {
105+
query: MyQueryType
106+
mutation: MyMutationType
107+
subscription: MySubscriptionType
108+
}
109+
```
110110

111111
## Scalar types
112112

0 commit comments

Comments
 (0)