Tuesday, 14 March 2017

Clearing Node.js' cache when loading non-js files e.g. graphql language defenitions

I want to clear Node's cache from my graphql defintions but nothing happens until I make a change to the file where the require('my.graphql') statement is. I think this question relates to this one and I've tried to do:

Object.keys(require.cache).forEach(function(key) {
  delete require.cache[key];
});

But it doesn't reload the code. There must be some other caching that is going on that I miss.

Since the example would be a little long, I've forked this repo and created a graphql-branch that you can install and test adapting the src/schema.graphql file:

git clone git@github.com:gforge/graphql-relay-mongodb-pagination.git
cd graphql-relay-mongodb-pagination
git checkout git checkout mongoose-w-gql-lang 
npm install



via Max Gordon

No comments:

Post a Comment