-
-
Notifications
You must be signed in to change notification settings - Fork 809
Description
Im attempting to use express-graphql with express-graphqlexpress-graphql and serverless ofline and am running into issues with graphql schemas already being defined since the require cache for my local files and therefor graphql schemas are invalidated, because the node_modules are not invaldated graphql still knows about my schema, this therefore gives me the error
'Error: Schema must contain unique named types but contains multiple types named "User".
running with the --skipCacheInvalidation resolves this issue for me.
I would also be concerned that this could cause memory leaks ( in situations similar to mine where you are adding references to types you create outside of node_modules to libaries that are persisting and not invalidated inside of node_modules.
Code in question in functionHelper.js
createHandler(funOptions, options) {
if (!options.skipCacheInvalidation) {
debugLog('Invalidating cache...');
for (const key in require.cache) {
// Require cache invalidation, brutal and fragile.
// Might cause errors, if so please submit an issue.
if (!key.match('node_modules')) delete require.cache[key];
}
}
See example of creating a memory leak due to the invaldiation of require cache here: