-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Fragment Referencing/Query Composition #338
Comments
Another important benefit is that this is a simple way to avoid rewriting fragment names, so that server-side debugging tools can use the fragment names meaningfully. @Poincare one question this kinda skips.. how do I use |
To solve that issue, |
Nice! I love the detail of making sure that fragments in queries are unique as well. |
Closing due to #343. |
We want to be able to reference a fragment definitions within our queries. The point of including this feature is to do query composition across different UI components. Each UI component can be associated with a fragment to load and a root (or, parent) UI component can then construct a query that references these fragments.
Goals
After some discussion with @stubailo, we've come up with the following goals for the design:
graphql-tag
implementation remain unaffected by this implementation.Design
Given these goals, I'll implement the following design.
watchQuery
,query
,mutate
), etc. will take an array of GraphQL FragmentDefinitions calledfragments
....fragmentName
.client.fragment
which will warn the app. developer if there are conflicting fragment names. It will also take an additional argument of fragments that the the first argument fragment depends on and fllatten all of these into a single array ofFragmentDefinition
values.What this will look like
If you have a single fragment that you would like to reference within another query:
If you have a single fragment that depends on some other fragments:
If you have fragments within your query document,
Comments/feedback appreciated!
The text was updated successfully, but these errors were encountered: