Update description of Fragments to emphasize evolving data needs #1193
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why these changes?
Fragments are not for reuse.
The current language in section 2.8 on Fragments, namely the sentence...
...encourages using fragments to deduplicate common selections, even if those selections represent independent data needs.
For example, let's consider these two functions
Given these two functions currently both use
authorName
andcontentText
, the current language in the spec encourages one to write a fragmentIf
formatPostForFeed
now needstimestamp
, we will add naturally addtimestamp
toPostDisplayFragment
If we have the following queries
notice how
NotificationQuery
is now over-fetching timestamp!The key observation is that
formatPostForFeed
andformatPostForNotification
are two independent functions, so by having them both rely on a single fragment to express their data needs, we are creating a dependency where one should not exist (because that dependency does not exist in the product logic itself).What are the proposed changes?
Updated:
The goal is to emphasize that fragments support evolving data needs (as opposed to recommending people identify common selections that are currently in an executable document).
Open to any and all feedback on the motivation for the change and how it's communicated via changes in the spec language!