-
Notifications
You must be signed in to change notification settings - Fork 178
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
Stop Bundling GraphQL in the module #46
Conversation
…om graphql. fix maximum callstack issue in stripLoc
index.js
Outdated
@@ -156,5 +164,7 @@ function gql(/* arguments */) { | |||
gql.default = gql; | |||
gql.resetCaches = resetCaches; | |||
gql.disableFragmentWarnings = disableFragmentWarnings; | |||
gql.print = require('graphql/language/printer'); | |||
gql.parser = parser |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't look like these two names are consistent - should it be "parse" rather than "parser"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stubailo I did a search:
https://github.com/apollographql/apollo-client/search?utf8=%E2%9C%93&q=parser
and saw some typings expecting parser
What do you suggest? parse
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The module is called parser
, but the function exported is called parse
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay i will export the parse function instead of the whole parser
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was exporting the whole lib var parser = require('graphql/language/parser');
Also it looks like this is adding a yarn lock file, I don't think we want that in the repository. |
@stubailo I added the lock file because I manage dependencies with yarn. Are we opposed to managing the dependencies and their versions with |
@abhiaiyer91 no, but you can install dependencies with yarn without adding a lock file. Lock files are perfect for applications, but not the right solution for packages, where we need to be constantly testing with new versions. |
Sounds good, will remove the yarn.lock |
Alright updates made! |
index.js
Outdated
@@ -90,6 +93,11 @@ function stripLoc (doc, removeLocAtThisLevel) { | |||
delete doc.loc; | |||
} | |||
|
|||
if (doc.loc) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this could use a comment - im not fully certain why we'd want to delete these properties. linking to the issue should be sufficient
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will add a comment, the parser's loc fields include references to the query string and as your AST is deeper it becomes more overhead to ship/store the query
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this lgtm, but @stubailo should probably sign off.
Yeah I think this is a great change although it is majorly breaking for anyone that was using Also, are we worried about importing |
(Consider that a sign-off, we can always fix it later if we think this increases the bundle size unnecessarily) |
@stubailo I think people should import printer/parser themselves. They are already going to have graphql due to the peer dependency. So i would say next steps: Remove the re-export of both libraries and ship a major version. |
This reverts commit 7413172. # Conflicts: # index.js # parser.js # printer.js # webpack.config.js
Slightly off-topic but Would you accept a PR for that ? |
thanks for sharing that article, i was fairly certain we shouldn't be adding |
No description provided.