Skip to content

Commit

Permalink
Update schema-customization.md (#25109)
Browse files Browse the repository at this point in the history
* Update schema-customization.md

Adds paragraph at the end of section **Foreign-key fields** explaining that the `by` argument doesn't work with arrays.

Closes #25089

* Update docs/docs/schema-customization.md

Co-authored-by: Aisha Blake <[email protected]>
Co-authored-by: gatsbybot <[email protected]>
  • Loading branch information
3 people authored Jun 20, 2020
1 parent 400d01f commit d708fa2
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/docs/schema-customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,8 @@ otherwise the foreign-key has to be provided with the `by` argument. The
optional `from` argument allows getting the field on the current type which acts as the foreign-key to the field specified in `by`.
In other words, you `link` **on** `from` **to** `by`. This makes `from` especially helpful when adding a field for back-linking.

Keep in mind that in the example above, the link of `posts` in `AuthorJson` works because `frontmatter` and `author` are both objects. If, for example, the `Frontmatter` type had a list of `authors` instead (`frontmatter.authors.email`), it wouldn't work since the `by` argument doesn't support arrays. In that case, you'd have to provide a custom resolver with [Gatsby Type Builders](/docs/schema-customization/#gatsby-type-builders) or [createResolvers API](/docs/schema-customization/#createresolvers-api).

> Note that when using `createTypes` to fix type inference for a foreign-key field
> created by a plugin, the underlying data will probably live on a field with
> a `___NODE` suffix. Use the `from` argument to point the `link` extension to
Expand Down

0 comments on commit d708fa2

Please sign in to comment.