-
Notifications
You must be signed in to change notification settings - Fork 21
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
fix: remove duplicate fragments (fix #90) #94
fix: remove duplicate fragments (fix #90) #94
Conversation
@@ -1,6 +1,15 @@ | |||
// @flow | |||
import gqlTag from 'graphql-tag'; | |||
import serialize from 'babel-literal-to-ast'; | |||
import template from '@babel/template'; | |||
|
|||
const uniqueFn = template.ast(` |
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.
Basically we append this function inside a .reduce
call after the .concat
we use to append the fragments.
Codecov Report
@@ Coverage Diff @@
## master #94 +/- ##
==========================================
+ Coverage 95.83% 95.91% +0.08%
==========================================
Files 5 5
Lines 48 49 +1
Branches 8 8
==========================================
+ Hits 46 47 +1
Misses 2 2
Continue to review full report at Codecov.
|
Accept the PR for now. I have not come up with a better solution to reduce runtime, either. |
With this PR, we deduplicate fragments at runtime.
I wanted to do this at build time inside Babel but I can't find a way to do it☹️
I copied the approach from
babel-plugin-graphql-tag