Gatsby: Json file change does not update GraphQL schema without restarting dev server

Created on 17 May 2018  路  4Comments  路  Source: gatsbyjs/gatsby

Description

I have my Gatsby site data in json files. Unfortunately when I work on it incrementally (add a component, attach data to it, add data to corresponding json file, save everything at once) I need to restart my dev server (yarn develop) everytime I add something.

Steps to reproduce

  1. Configure Gatsby for use with gatsby-transformer-json
  2. Add some .json file in your attached data folder
  3. Query the data (it works now)
  4. Add a property to the .json file
  5. Try to query the new property (it doesn't work)

Expected result

I expected Gatsby to refresh the schema on-the-fly as the file changes.

Actual result

I need to restart the dev server to see the new properties from my .json files.

Environment

  • Gatsby version: 1.9.251
  • gatsby-cli version: 1.1.48
  • Node.js version: 9.4.0
  • Operating System: Mac OSX High Sierra

File contents (if changed)

gatsby-config.js:

module.exports = {
  siteMetadata: {
    title: '***'
  },
  plugins: [
    {
      resolve: 'gatsby-plugin-google-analytics',
      options: {
        trackingId: '***'
      }
    },
    'gatsby-plugin-react-helmet',
    {
      resolve: 'gatsby-source-filesystem',
      options: {
        name: 'data',
        path: `${__dirname}/src/data`
      }
    },
    'gatsby-transformer-json',
    'gatsby-transformer-sharp',
    'gatsby-plugin-sharp',
    'gatsby-plugin-netlify'
  ]
};

package.json:

{
  "name": "***",
  "description": "***",
  "version": "0.1.0",
  "author": "***",
  "private": true,
  "scripts": {
    "build:css": "postcss src/assets/input.css -o src/assets/output.css",
    "watch:css": "postcss src/assets/input.css -o src/assets/output.css -w",
    "build": "yarn build:css && gatsby build",
    "develop": "yarn watch:css & gatsby develop",
    "serve": "gatsby serve",
    "lint": "npm-run-all lint:eslint lint:flow",
    "lint:eslint": "eslint src",
    "lint:flow": "flow src"
  },
  "dependencies": {
    "classnames": "^2.2.5",
    "date-fns": "^1.29.0",
    "gatsby": "^1.9.241",
    "gatsby-image": "^1.0.46",
    "gatsby-link": "^1.6.39",
    "gatsby-plugin-google-analytics": "^1.0.30",
    "gatsby-plugin-netlify": "^1.0.19",
    "gatsby-plugin-react-helmet": "^2.0.8",
    "gatsby-plugin-sharp": "^1.6.42",
    "gatsby-source-filesystem": "^1.5.33",
    "gatsby-transformer-json": "^1.0.16",
    "gatsby-transformer-sharp": "^1.6.22",
    "humanize-duration": "^3.14.0",
    "jsonp": "^0.2.1",
    "postcss-cli": "^5.0.0",
    "react": "^16.3.2",
    "react-dom": "^16.3.2",
    "react-helmet": "^5.2.0",
    "react-player": "^1.4.0",
    "tailwindcss": "^0.5.1"
  },
  "devDependencies": {
    "babel-eslint": "^8.2.2",
    "eslint": "^4.19.1",
    "eslint-plugin-flowtype": "^2.46.1",
    "eslint-plugin-react": "^7.7.0",
    "flow-bin": "^0.68.0",
    "npm-run-all": "^4.1.2",
    "prettier": "^1.11.1",
    "tailwindcss-aspect-ratio": "^1.0.0"
  }
}
question or discussion

All 4 comments

This is unfortunately known limitation - Gatsby creates schema just once during bootstrap and it isn't later updated. We do plan on adding support for updating schema if/when shape of data changes.

@pieh My bad then 馃槃 Thought that if the data from the sources is being successfully updated then the schemas rebuild is also happening. Feel free to close this issue, thanks for clarifying things up 馃憤

Thanks for reporting @sarneeh!

This is unfortunately known limitation - Gatsby creates schema just once during bootstrap and it isn't later updated. We do plan on adding support for updating schema if/when shape of data changes.

Any updates on this ?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jimfilippou picture jimfilippou  路  3Comments

ghost picture ghost  路  3Comments

3CordGuy picture 3CordGuy  路  3Comments

mikestopcontinues picture mikestopcontinues  路  3Comments

dustinhorton picture dustinhorton  路  3Comments