-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[docs] Add mapping
documentation
#4007
Comments
Hey! I'd love to work on this! |
That's great, thanks! |
@KyleAMathews mentioned as an example the mapping done directly between nodes in gatsbyjs.org, an author field in markdown is mapped to an authors.yaml file. What exactly can you do once it's mapped, can you give me a bit clearer explanation of what happens in the back? Also any suggestions on what to include in the documentation? @m-allanson @fk |
Query data with GraphQL. 🎉
… given that the Lines 9 to 12 in 4edf11f
Note that we currently only map to |
@fk Thank you so much for such a detailed and clear explanation. This makes everything so much understandable now. |
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:
And you have a list of authors and their details stored in
This enables you to query data from both sources together:
|
@KyleAMathews @fk @m-allanson I've written up a rough idea of what should be added to the documentation. Any suggestions? I'll go on to making a PR once you review it! |
@ajayns Maybe it's worth mentioning that mapping doesn't have to be 1-1 relationship (single blog post has single author) and can be 1-N (single blog post can have multiple authors - then authors field in frontmatter in your example should be array of author ids)? Probably not in introduction to this feature (to not overwhelm with too much information). This can be added at later date, just keep this in mind as this:
is only "half" of what mapping can do. |
I was looking a for a simple way to explain what mapping does. Any suggestions on how I should rephrase it then? @pieh |
Not sure really - I already learned that writing docs is hard :) Maybe don't include details about linking 2 nodes by id in introduction and just say that it links nodes. And then add more details for specific scenarios (1-1 and 1-N) in seperate sub sections? |
Sure! I'm on it right now! @fk |
https://www.gatsbyjs.org/docs/gatsby-config/#mapping
Ref. #3129
The text was updated successfully, but these errors were encountered: