Skip to content

Commit 80b5a4a

Browse files
committed
Apply more changes from review.
1 parent cd6a9cc commit 80b5a4a

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/pages/learn/schema.mdx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,12 @@ That's where the schema comes in. Every GraphQL service defines a set of types t
3232

3333
## Type language
3434

35-
GraphQL services can be written in any language and there are different approaches you can take when defining the types in a schema. Some libraries require that you only write the _resolver functions_ that provide data for the different fields in the API, then compile the schema based on that code. Other libraries allow you to define types and fields using what's commonly called the _schema definition language_ (or SDL) and then write the resolver functions for the corresponding fields separately.
35+
GraphQL services can be written in any language and there are many different approaches you can take when defining the types in a schema:
36+
37+
- Some libraries have you construct the schema types, fields, and resolver functions together using the same programming language that was used to write the GraphQL implementation.
38+
- Some libraries allow you to define types and fields more ergonomically using what's commonly called the schema definition language (or SDL) and then write the resolver functions for the corresponding fields separately.
39+
- Some libraries allow you to write and annotate the resolver functions, and then infer the schema from that.
40+
- Some libraries may even infer both the types and resolver functions for you, based on some underlying data source(s).
3641

3742
Since we can't rely on a specific programming language to discuss GraphQL schemas in this guide, we'll use SDL because it's similar to the query language that we've seen so far and allows us to talk about GraphQL schemas in a language-agnostic way.
3843

@@ -49,11 +54,11 @@ type Character {
4954

5055
The language is readable, but let's go over it so that we can have a shared vocabulary:
5156

52-
- `Character` is a GraphQL Object type, meaning it's a type with some fields. Most of the types in your schema will be Object types.
53-
- `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.
54-
- `String` is one of the built-in Scalar types. These are types that resolve to a single scalar value and can't have sub-selections in the query. We'll go over Scalar types more later.
55-
- `String!` means that the field is a Non-Null type, meaning the GraphQL service promises to give you a value whenever you query this field. In SDL, we represent those with an exclamation mark.
56-
- `[Episode!]!` represents an List type of `Episode` objects. When a List is Non-Null, you can always expect an array (with zero or more items) when you query the `appearsIn` field. In this case, since `Episode!` is also Non-Null within the list, you can always expect every item in the array to be an `Episode` object.
57+
- `Character` is a [GraphQL Object type](#object-types-and-fields), meaning it's a type with some fields. Most of the types in your schema will be Object types.
58+
- `name` and `appearsIn` are [fields](#object-types-and-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.
59+
- `String` is one of the built-in [Scalar types](#scalar-types). These are types that resolve to a single scalar value and can't have sub-selections in the query. We'll go over Scalar types more later.
60+
- `String!` means that the field is a [Non-Null type](#non-null), meaning the GraphQL service promises to give you a value whenever you query this field. In SDL, we represent those with an exclamation mark.
61+
- `[Episode!]!` represents an [List type](#list) of `Episode` objects. When a List is Non-Null, you can always expect an array (with zero or more items) when you query the `appearsIn` field. In this case, since `Episode!` is also Non-Null within the list, you can always expect every item in the array to be an `Episode` object.
5762

5863
Now you know what a GraphQL Object type looks like and how to read the basics of SDL.
5964

0 commit comments

Comments
 (0)