Skip to content
Expose values as JSON type in GraphQL schema
CSS JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
example
src
.babelrc
.gitignore
.npmignore
README.md
index.js
package.json
yarn.lock

README.md

npm

gatsby-transformer-json

Exposes JSON values as a scalar field in GraphQL schema.

Install

npm install --save gatsby-transformer-rawjson

How to use

In your gatsby-config.js:

module.exports = {
  plugins: [
    `gatsby-transformer-json`,
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        path: `./src/data/`,
      },
    },
    `gatsby-transformer-rawjson`,
  ],
}

How to query

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": "a",
              "en": "a"
            }
          }
        },
      }
    ]
  }
}
You can’t perform that action at this time.