Skip to content

Commit 98130e8

Browse files
reconbotstubailo
authored andcommitted
Be clearer about nullable items in an array (graphql#604)
This bit of example code has allowed nulls in to many array types in many examples when that wasn't the intention.
1 parent c42d28b commit 98130e8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

site/learn/Learn-Schema.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ The most basic components of a GraphQL schema are object types, which just repre
4242
```graphql
4343
type Character {
4444
name: String!
45-
appearsIn: [Episode]!
45+
appearsIn: [Episode!]!
4646
}
4747
```
4848

@@ -52,7 +52,7 @@ The language is pretty readable, but let's go over it so that we can have a shar
5252
- `name` and `appearsIn` are _fields_ on the `Character` type. That means that `name` and `appearsIn` are the only fields that can appear in any part of a GraphQL query that operates on the `Character` type.
5353
- `String` is one of the built-in _scalar_ types - these are types that resolve to a single scalar object, and can't have sub-selections in the query. We'll go over scalar types more later.
5454
- `String!` means that the field is _non-nullable_, meaning that the GraphQL service promises to always give you a value when you query this field. In the type language, we'll represent those with an exclamation mark.
55-
- `[Episode]!` represents an _array_ of `Episode` objects. Since it is also _non-nullable_, you can always expect an array (with zero or more items) when you query the `appearsIn` field.
55+
- `[Episode!]!` represents an _array_ of `Episode` objects. Since it is also _non-nullable_, you can always expect an array (with zero or more items) when you query the `appearsIn` field. And since `Episode!` is also _non-nullable_, you can always expect every item of the array to be an `Episode` object.
5656

5757
Now you know what a GraphQL object type looks like, and how to read the basics of the GraphQL type language.
5858

0 commit comments

Comments
 (0)