-
Notifications
You must be signed in to change notification settings - Fork 177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue with multiple queries/mutations in single .graphql file using loader #168
Comments
@ryanjsmyth I'm having the same issue .. after some line in the |
Hey @jnwng I think there is a problem with the webpack loader when the |
This issue also causes this apollographql/react-apollo#1928 |
I've encountered the same issue. When running any of the mutations below a certain point in my .graphql file, my browser tab completely freezes up and the "out of memory" error can be seen if my console doesn't die first. |
The following code is causing some issues with exporting multiple queries/mutations from a single .graphql file.
When exporting multiple queries/mutations there are a number of unnecessary properties hanging off of each document.
This is because the root doc is assigned to module.exports
module.exports = doc;
and then is incrementally added to through calls to oneQuery
module.exports["${opName}"] = oneQuery(doc, "${opName}");
which essentially does:
doc["${opName}"] = oneQuery(doc, "${opName}");
The call to oneQuery copies the doc and only overwrites the definitions property. This means that all preceding queries/mutations exist on the new doc created by oneQuery.
Here is an example of what the exported queries may look like:
The problem is this structure becomes deeply nested and if you deepclone it can cause out of memory exceptions. I didn't encounter this problem until one .graphql file grew in size and we began using Apollo Link State, which does a deep clone on your mutation, removing the @client directive, before executing it.
I don't know if this side-effect exists with purpose but if not I think there should be a shallow clone of doc before assigning it to module.exports.
/label bug
The text was updated successfully, but these errors were encountered: