postalservice14
postalservice14

Reputation: 2534

Relay/GraphQL Schema cache not updating when I update schema on server side

I have a React app using Relay and a remote GraphQL server. When I start the webpack server, I have it fetch the latest schema and feed it into the babel-relay-plugin.

It works great....except when I make a schema change. It appears React or Relay or webpack or something is caching the schema, because I'll get a Schema validation error in the browser console when I run the app. However, when I run the query manually against the GraphQL server using GraphIQL, the query is successful. So it would have to be some sort of cache on the react, relay, webpack side I'm thinking?

Things I've tried:

  1. List item
  2. Restarting webpack server
  3. Removing node_modules and npm install
  4. I've even tried restarting my computer (that actually seemed to work, but may be coincidence)

Thanks in advance for your help.

Upvotes: 8

Views: 2660

Answers (2)

postalservice14
postalservice14

Reputation: 2534

Turns out, of course, it was human error. I had cacheDirectory as true in my babel-loader query. You can read about it on the babel-loader readme (just do a find on page for 'cacheDirectory') https://github.com/babel/babel-loader

Once I changed that to false, which is the default. The problem went away. Hope that helps others.

Upvotes: 5

Chris Martin
Chris Martin

Reputation: 1889

This happened to me when I switched to Webpack 2.

The solution in my case was to move the babelRelayPlugin to be the first plugin to execute in .babelrc.

I'm not exactly sure on the why though.

Upvotes: 3

Related Questions