Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 433
postalservice14 Avatar asked Sep 01 '16 12:09

postalservice14


2 Answers

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.

like image 104
postalservice14 Avatar answered Oct 29 '22 23:10

postalservice14


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.

like image 31
Chris Martin Avatar answered Oct 29 '22 22:10

Chris Martin