Skip to content

Commit

Permalink
fix(docs): schema -> code fences, code fix (#26462)
Browse files Browse the repository at this point in the history
  • Loading branch information
muescha committed Aug 31, 2020
1 parent 6b96972 commit 652af04
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
8 changes: 4 additions & 4 deletions docs/docs/schema-generation.md
Expand Up @@ -48,9 +48,9 @@ See [Schema Root Fields and Utility Types](/docs/schema-root-fields) for a more

For each type, utility types are created. Those are input object types, used for searching, sorting and filtering, and types for paginated data (Connections and Edges).

For searching and sorting, Gatsby goes through every field in the type and converts them to corresponding Input GraphQL types. Scalars are converted to objects with filter operator fields like "eq" or "ni". Object types are converted to Input Object types. For sorting, enums are created out of all fields so that one can use that to specify the sort.
For searching and sorting, Gatsby goes through every field in the type and converts them to corresponding Input GraphQL types. Scalars are converted to objects with filter operator fields like `eq` or `ni`. Object types are converted to Input Object types. For sorting, enums are created out of all fields so that one can use that to specify the sort.

Those types are used to create _root fields_ of the schema in `Query` type. For each node type a root field for querying one item and paginated items are created (for example, for type BlogPost it would be `blogPost` and `allBlogPost`).
Those types are used to create _root fields_ of the schema in `Query` type. For each node type a root field for querying one item and paginated items are created (for example, for type `BlogPost` it would be `blogPost` and `allBlogPost`).

## 6. Merging in third-party schemas

Expand All @@ -60,8 +60,8 @@ If a plugin like `gatsby-source-graphql` is used, all third-party schemas that i

[`createResolvers`](/docs/schema-customization/#createresolvers-api) API is called, allowing users to add additional customization on top of created schema. This is an "escape hatch" API, as it allows to modify any fields or types in the Schema, including Query type.

## 8. Second schema build for SitePage
## 8. Second schema build for `SitePage`

Because SitePage nodes are created after a schema is first created (at `createPages`) API call, the type of the `SitePage.context` field can change based on which context was passed to pages. Therefore, an additional schema inference pass happens and then the schema is updated.
Because `SitePage` nodes are created after a schema is first created (at `createPages`) API call, the type of the `SitePage.context` field can change based on which context was passed to pages. Therefore, an additional schema inference pass happens and then the schema is updated.

Note that this behavior will be removed in Gatsby v3 and context will become a list of key/value pairs in GraphQL.
7 changes: 5 additions & 2 deletions docs/docs/schema-root-fields.md
Expand Up @@ -16,7 +16,10 @@ Plural fields accept four arguments - `filter`, `sort`, `skip` and `limit`. `fil

```graphql
{
allBlogPost(filter: { date: { lt: "2020-01-01" }}, sort: {fields: [date], order: ASC) {
allBlogPost(
filter: { date: { lt: "2020-01-01" } }
sort: { fields: [date], order: ASC }
) {
nodes {
id
}
Expand Down Expand Up @@ -48,7 +51,7 @@ Gatsby uses a common pattern in GraphQL called [Connections](https://relay.dev/g
- `pageInfo.totalCount` - (also available as `totalCount` number of all nodes that match the filter, before pagination
- `pageInfo.currentPage` - index of the current page (based on 1)
- `pageInfo.hasNextPage`, `pageInfo.hasPreviousPage` - whether there is a next or previous page based on current pagination
- `pageInfoitemCount` - number of items on current page
- `pageInfo.itemCount` - number of items on current page
- `perPage` - requested number of items on each page
- `pageCount` - total number of pages
- `distinct(field)` - print distinct values for given field
Expand Down

0 comments on commit 652af04

Please sign in to comment.