Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion docs/docs/gatsby-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,44 @@ See more about [Browser Support](/docs/browser-support/#polyfills) in Gatsby.

## mapping

TODO
To query between nodes, Gatsby has a mapping feature which allows you to link two different nodes by id and then you can query with GraphQL. For instance, if you have a couple of blog posts which have author id in the frontmatter:

```
title: A blog post
author: Kyle Mathews
```

And you have a list of authors and their details stored in `authors.yaml`, you can map between `author` in `frontmatter` to id in `authors.yaml` file by:

```
module.exports = {
mapping: {
"MarkdownRemark.frontmatter.author": `AuthorYaml`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be AuthorsYaml (plural) if the file is named authors.yaml

},
}
```

This enables you to query data from both sources together:

```
query BlogPost($slug: String!) {
markdownRemark(fields: {slug: {eq: $slug}}) {
html
fields {
slug
}
frontmatter {
title
author {
id
fields {
slug
}
}
}
}
}
```

## proxy

Expand Down