You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/pages/learn/schema.mdx
+10-9Lines changed: 10 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -96,7 +96,7 @@ type Query {
96
96
97
97
Schemasmayalsosupport `mutation` and `subscription` operationsbyaddingadditional `Mutation` and `Subscription` typesandthendefiningfieldsonthecorrespondingrootoperationtypes.
98
98
99
-
It'simportanttorememberthatapartfromthespecialstatusofbeingentrypointsintotheschema, 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'simportanttorememberthatotherthanthespecialstatusofbeingentrypointsintotheschema, the `Query`, `Mutation`, and `Subscription` types are the same as any other GraphQL Object type, and their fields work exactly the same way.
100
100
101
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
102
@@ -132,7 +132,7 @@ GraphQL comes with a set of [default Scalar types](https://spec.graphql.org/draf
132
132
-`Float`: A signed double-precision floating-point value.
133
133
-`String`: A UTF‐8 character sequence.
134
134
-`Boolean`: `true` or `false`.
135
-
-`ID`: This type represents a unique identifier, often used to refetch an object or as the key for a cache. The `ID` type is serialized in the same way as a `String`; however, defining it as an `ID` signifies that it is not intended to be human‐readable.
135
+
-`ID`: A unique identifier, often used to refetch an object or as the key for a cache. The `ID` type is serialized in the same way as a `String`; however, defining it as an `ID` signifies that it is not intended to be human‐readable.
136
136
137
137
In most GraphQL service implementations, there is also a way to specify custom Scalar types. For example, we could define a `Date` type:
138
138
@@ -192,7 +192,7 @@ As we saw in an example above, the Non-Null type modifier can also be used when
192
192
}
193
193
```
194
194
195
-
### Lists
195
+
### List
196
196
197
197
Lists work in a similar way. We can use a type modifier to mark a type as a List type, which indicates that this field will return an array of that type. In SDL, this is denoted by wrapping the type in square brackets, `[` and `]`. It works the same for arguments, where the validation step will expect an array for that value. Here's an example:
198
198
@@ -341,7 +341,7 @@ Note that Interface types may not implement themselves or contain any cyclic ref
341
341
342
342
## Union types
343
343
344
-
GraphQLsupportsasecondabstracttypecalleda [Uniontype](https://spec.graphql.org/draft/#sec-Unions). They share similarities with Interface types, but they cannot define any shared fields among the constituent types.
344
+
GraphQLsupportsasecondabstracttypecalleda [Uniontype](https://spec.graphql.org/draft/#sec-Unions). Union types share similarities with Interface types, but they cannot define any shared fields among the constituent types.
@@ -374,7 +374,7 @@ In this case, if you query a field that returns the `SearchResult` Union type, y
374
374
}
375
375
```
376
376
377
-
The `__typename` field is a special _meta-field_ that resolves to a `String` and lets you differentiate between data types on the client.
377
+
The `__typename` field is a special _meta-field_ that automatically exists on every Object type and resolves to the name of that type, providing a way to differentiate between data types on the client.
378
378
379
379
Also, in this case, since `Human` and `Droid` share a common interface (`Character`), you can query their common fields in one place and still get the same result:
380
380
@@ -406,9 +406,9 @@ Note that `name` is still specified on `Starship` because otherwise it wouldn't
406
406
407
407
Most of the examples we've covered on this page demonstrate how Object, Scalar, Enum, Interface, and Union types may be used as _output types_ for the fields in a schema. But we have also seen that field arguments must specify their _input types_.
408
408
409
-
So far, we've only talked about using scalar values (like Enums or String types) as an input type for a field argument. However, you can also easily pass complex objects as arguments using an [Input Object type](https://spec.graphql.org/draft/#sec-Input-Objects), which is the last of named types in GraphQL that we'll explore.
409
+
So far, we've only talked about using scalar values (like Enums or String types) as an input type for a field argument. However, you can also pass complex objects as arguments using an [Input Object type](https://spec.graphql.org/draft/#sec-Input-Objects), which is the last kind of named types in GraphQL that we'll explore.
410
410
411
-
This is particularly valuable in the case of [mutations](/learn/queries/#mutations), where you might want to pass in a whole object to be created. In SDL, Input Object types look the same as regular Object types, but with the keyword `input` instead of `type`:
411
+
This is particularly valuable in the case of [mutations](/learn/queries/#mutations), where you might want to pass in a whole object to be created. In SDL, Input Object types look similar to regular Object types, but with the keyword `input` instead of `type`:
412
412
413
413
```graphql
414
414
inputReviewInput {
@@ -516,6 +516,7 @@ type Query {
516
516
```
517
517
518
518
InadditiontomakingaGraphQLAPIschema more expressive, descriptions are helpful to client developers because they are available in [introspection queries](/learn/introspection/) and visible in developer tools such as [GraphiQL](https://github.com/graphql/graphiql).
519
+
519
520
### Comments
520
521
521
522
Occasionally, you may need to add comments in a schema that do not describe types, fields, or arguments, and are not meant to be seen by clients. In those cases, you can add a single-line comment to SDL by preceding the text with a `#` character:
@@ -550,9 +551,9 @@ To recap what we've learned about schemas and types:
550
551
- There are six kinds of named type definitions in GraphQL: Object, Scalar, Enum, Interface, Union, and Input Object types
551
552
- Object types contain fields that specify output types, and those fields may have arguments that specify input types
552
553
- The `Int`, `Float`, `String`, `Boolean`, and `ID` Scalar types are built into GraphQL, and you can also define your own custom scalars
553
-
- Like Scalar types, Enum types represent leaf values in a GraphQL schema but they are limited to a finite list of values
554
+
- Like Scalar types, Enum types represent leaf values in a GraphQL schema but they are limited to a finite set of values
554
555
- Interface and Union types are abstract types that allow different concrete Object types to be output from a single field
555
-
- Input Object types allow you to pass more complex values into a field argument than Scalar and Enum types allow
556
+
- Input Object types allow you to pass more complex values into a field argument or directive argument than Scalar and Enum types allow
556
557
- Type system directives can be applied to the types, fields, and arguments in a schema to alter how they are validated and executed during a query
557
558
- GraphQL supports schema documentation using type, field, and argument descriptions, and it also supports comments that are ignored by the parser
0 commit comments