gatsby-transformer-rawjson

5.0.0 • Public • Published

npm

gatsby-transformer-rawjson

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": "...",
              "en": "..."
            }
          }
        },
      }
    ]
  }
}

Readme

Keywords

Package Sidebar

Install

npm i gatsby-transformer-rawjson

Weekly Downloads

2

Version

5.0.0

License

MIT

Unpacked Size

4.88 kB

Total Files

6

Last publish

Collaborators

  • diegonc