Exposes JSON values as a scalar field in GraphQL schema.
npm install --save gatsby-transformer-rawjson
In your gatsby-config.js
:
module.exports = {
plugins: [
`gatsby-transformer-json`,
{
resolve: `gatsby-source-filesystem`,
options: {
path: `./src/data/`,
},
},
`gatsby-transformer-rawjson`,
],
}
Assuming a letters.json
file was loaded
{
allLettersJson {
edges {
node {
objectValue {
es
en
}
childRawLettersJson {
objectValue
}
}
}
}
}
Which would return:
{
allLettersJson: {
edges: [
{
node: {
objectValue: {
"es": "...",
"en": "..."
}
childRawLettersJson {
objectValue: {
"es": "...",
"en": "..."
}
}
},
}
]
}
}