Closed sparklesam closed 6 years ago
@sparklesam can you once check the data that you are trying to access? By reading the error, I assume that the data that you are trying to access is not available there.
post.node.data.primary_tag.document.data.text
@kakadiadarpan actually I can view it in log but just failed to map it. Uploaded screenshot for reference
@sparklesam As per the screenshot, document
is an array:
You need to access it the following way:
<h1>{post.node.data.primary_tag.document[0].data.text}</h1>
It works! Thanks a lot for your help!
My laptop is windows 10,how to add this project
@psnaik if you are talking about how to start with Gatsby, please head over to Get started
section.
Summary
Is it possible to map inline fragments?
Relevant information
I have read the part 4 of the new tutorial on GraphQL. It would be great if there are tutorial on mapping inline fragments. I have a working GraphQL query already but I failed to map it in my page. I use Prismic.io as backend, resulting in this query using
gatsby-source-prismic
.My Gatsby code goes like this:
The line with h1 are supposed to show text but I received an error. Trying to figure our all day, what is missing?
Here's the error message
Environment (if relevant)
System: OS: macOS High Sierra 10.13.6 CPU: x64 Intel(R) Core(TM) i5-7267U CPU @ 3.10GHz Shell: 3.2.57 - /bin/bash Binaries: Node: 10.8.0 - /usr/local/bin/node npm: 6.2.0 - /usr/local/bin/npm Browsers: Chrome: 69.0.3497.100 Firefox: 63.0 Safari: 12.0 npmPackages: gatsby: ^2.0.0-beta.55 => 2.0.0-rc.25 gatsby-image: ^1.0.55 => 1.0.55 gatsby-link: ^1.6.46 => 1.6.46 gatsby-plugin-catch-links: ^2.0.2-beta.4 => 2.0.2-rc.1 gatsby-plugin-lodash: ^3.0.1-beta.3 => 3.0.1-rc.1 gatsby-plugin-manifest: ^2.0.2-beta.3 => 2.0.2-rc.1 gatsby-plugin-netlify: ^2.0.0-beta.5 => 2.0.0-rc.6 gatsby-plugin-offline: ^2.0.0-beta.4 => 2.0.0-rc.8 gatsby-plugin-react-helmet: ^3.0.0-beta.4 => 3.0.0-rc.1 gatsby-plugin-sharp: ^1.6.48 => 1.6.48 gatsby-plugin-sitemap: ^2.0.0-beta.3 => 2.0.0-rc.2 gatsby-plugin-styled-components: ^3.0.0-beta.3 => 3.0.0-rc.5 gatsby-plugin-typography: ^2.2.0-beta.3 => 2.2.0-rc.3 gatsby-remark-autolink-headers: ^2.0.0-beta.4 => 2.0.0-rc.2 gatsby-remark-external-links: 0.0.4 => 0.0.4 gatsby-remark-images: ^1.5.67 => 1.5.67 gatsby-remark-prismjs: ^3.0.0-beta.4 => 3.0.0-rc.2 gatsby-source-airtable: 0.0.6 => 0.0.6 gatsby-source-filesystem: ^2.0.1-beta.9 => 2.0.1-rc.6 gatsby-source-prismic: ^1.2.0 => 1.2.0 gatsby-transformer-remark: ^2.1.1-beta.4 => 2.1.1-rc.5 gatsby-transformer-sharp: ^1.6.27 => 1.6.27 npmGlobalPackages: gatsby-cli: 1.1.58
File contents (if changed)
gatsby-config.js
: N/Apackage.json
: N/Agatsby-node.js
: N/Agatsby-browser.js
: N/Agatsby-ssr.js
: N/A