-
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
Remove bad fragment recommendations in best practices docs #11390
Conversation
|
size-limit report 📦
|
@@ -160,87 +160,6 @@ query GetGlobalStatus { | |||
* If you have collections of components that _are_ always rendered together, you can use fragments to distribute the structure of a single query between them. See [Colocating fragments](./fragments/#colocating-fragments). | |||
* If you're querying a list field that returns more items than your component needs to render, you should [paginate that field](../pagination/overview/). | |||
|
|||
|
|||
|
|||
## Use fragments to encapsulate related sets of fields |
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.
Going forward, we want fragments to be used by components so that components can declare their data needs. It is rare that you should need/want to use fragments as a means to DRY up a query, or share data between multiple operations. This tends to result in overfetching over time.
} | ||
``` | ||
|
||
### Avoid excessive or illogical fragments |
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.
When using fragments to declare data needs for a component, queries start to look more like the "less readable" example here. We much prefer for devs to use fragments as the unit of composition in components rather than queries, so this recommendation makes no sense anymore.
✅ Deploy Preview for apollo-client-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
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.
💯
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.
Thank you for clean-up and commenting on what we'll want to recommend in the future!
Our best practices doc includes some recommendations on fragments that I do not deem as good advice. This PR removes them from the documentation.
There are additional recommendations that I would like to add in the future regarding fragments, including deemphasizing splitting queries at the component boundary, but for now this is the quick and dirty change I would like to see removed to avoid future Apollo Client users from following these patterns.