Reputation: 305
Is there a good solution to reuse same GraphQL fragments in multiple .graphql files?
I am trying to have all the fragments in one file, and to use them in multiple queries.
Upvotes: 3
Views: 2511
Reputation: 3334
You mean, how to export/import fragment accross files ? I would do it like this
fragment MyReusableFragment_MyConnection on MyConnection {
edges {
node {
_id
name
}
}
}
And import it :
#import "./MyReusableFragment.graphql"
query myQuery on MyConnection {
...MyReusableFragment_MyConnection
}
and reuse it around other file
#import "./MyReusableFragment.graphql"
query myOtherQuery on MyConnection {
...MyReusableFragment_MyConnection
}
Upvotes: 9