Added support for nested fragments when importing from graphql/loader#227
Added support for nested fragments when importing from graphql/loader#227mzalewski wants to merge 1 commit into
Conversation
|
we want this :) |
|
Oh yes ! we really need this too ! 😍 |
abernix
left a comment
There was a problem hiding this comment.
Thanks for looking into this!
| @@ -1,6 +1,7 @@ | |||
| var parser = require('graphql/language/parser'); | |||
|
|
|||
| var printer = require('graphql/language/printer'); | |||
There was a problem hiding this comment.
While this probably solves the problem thanks the the providing of the much more complete and considerate printer module from graphql-js, introducing this would be adding the full weight of that printer to client bundles, no?
I'm not sure if that was the original reason for using the more simple implementation, but have you evaluated how this change affects bundle size?
There was a problem hiding this comment.
I haven't. Unfortunately haven't worked on any GraphQL projects in a while so haven't needed this.
I'll try to find some time over the next week to get back to this
There was a problem hiding this comment.
Our team could look at fixing this up so the printer doesn't get included in the client bundle. However, we've never worked on this code base, so have no idea where to start. Can someone provide guidance on an alternative approach that would be accepted? Is there another way we can help get this closer to being merged?
There was a problem hiding this comment.
@hwillson Looks like you're the most recent contributor to this code base. Is there any hope to get this merged, if we assist? How can we help? Just let us know, thanks :)
|
@mzalewski, any updates? |
|
I really need that feature too, hope reviewer merge this pull request |
|
It's been a while... |
|
Our app just suffered a nasty bug traced to a point where developer tried a nested fragment and commented it out because it doesn't work and the hard coded attributes pasted in its place got out of sync with the original fragment. Please get this merged! |
|
any updates on this? |
|
As a workaround while this isn't merged, for me the following worked. In the situation described by the OP, put the query in a separate # MyBookQuery.gql
#import "./BookDetailsFragment.gql"
# Above import includes nested AuthorDetailsFragment.
query MyBookQuery {
book {
...BooksAuthor
}
}// main.js
const result = require("./MyBookQuery")I'm using webpack as described here. As a (positive) side effect, the |
Used test from #105
Simplified import of nested fragments - uses the built-in graphql printer to get the full source including any nested fragments
Fixes the following situation:
AuthorDetailsFragment.gql
BookDetailsFragment.gql
main.js
Previously, result would only include 2 definitions: the Query and the BooksAuthor fragment - and ignore the AuthorDetails fragment.
Now result should include all 3