Skip to content

Commit c84dcbf

Browse files
committed
add documentation section
1 parent 691c74b commit c84dcbf

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/pages/learn/schema-design.mdx

+25
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,28 @@ A field error is typically the fault of a GraphQL service.
3535
Clients wanting to display partial data should opt out of error propagation using `@experimental_disableErrorPropagation` and parse the `errors` section of the response. This ensures the server returns as much data as is available.
3636

3737
Because they are typically not cached and harder to process that regular data, field errors in GraphQL work best are exceptional and transient.
38+
39+
## Documentation
40+
41+
GraphQL has built-in support for documentation. Every type and field in your schema can be described to provide context to your developers about how to use them.
42+
43+
```graphql
44+
"""
45+
A user of the service.
46+
"""
47+
type User {
48+
"""
49+
The full name of the user.
50+
"""
51+
name: String!
52+
"""
53+
The url of the user picture.
54+
`null` if the user did not configure a picture.
55+
"""
56+
pictureUrl: String
57+
}
58+
```
59+
60+
Schema authors are encouraged to add description to their type and field definitions. Those descriptions can be reused by tools like code generation to build a shared understanding of the data model.
61+
62+
Whenever a position is nullable descriptions should explicit in what cases `null` is returned so that users can make informed decisions.

0 commit comments

Comments
 (0)