You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Something to consider as a best practice -- since Relay is designed to have data co-located with the views that use them, I think we could extract sub-fragments from this graphql fragment and put them on the views that use them. Like reviewsView_comment and commentDecorationsController_comment.
[..]
We'd rather not fetch data we don't need, that's the beauty of GraphQL 😊
This also applies to the other two accumulators: ReviewSummariesAccumulator and ReviewThreadsAccumulator
The text was updated successfully, but these errors were encountered:
I started to try to address this and I hit a bit of a hitch with it. The aggregated data structure that we assemble in AggregatedReviewsContainer to hold the collated review threads and review comments is different from the way that the data is shaped in GraphQL, so we can't easily map it to props in a Relay fragmentContainer around ReviewsView.
Specifically, the GraphQL structure looks roughly like this:
... onPullRequest {
reviewThreads {
nodes {
# fields we need from review threads...reviewsView_reviewThreadscomments {
nodes {
# fields we need from comments...reviewsView_comments
}
}
}
}
}
We process comments grouped with their owning threads in ReviewsView like so:
So we'd lose the ability to tell which comment belongs to which review thread, which we use pretty heavily within the view.
I think one path forward to accomplish this is to split a subcomponent out of ReviewsView which can be a fragmentContainer for a single comment:
... onPullRequest {
reviewThreads {
nodes {
# fields we need from review threads...reviewsView_reviewThreadcomments {
nodes {
# fields we need from comments...reviewCommentView_comment
}
}
}
}
}
classReviewsViewextendsReact.Component{renderReviewThread(thread){// Relay will do its magic and allow each child to access each comment's data, but ReviewsView still gets to tell// it about its owning threadreturnthread.comments.map(comment=>(<ReviewCommentViewcomment={comment}thread={thread}/>))}}
In any case, this was a bit more invasive than I was hoping it would be, so I'm going to punt on it for the moment, and tackle this after we have a chance to get some of the easier ones out of the way, and maybe advocate merging as-is if we continue to run short on time. It's also possible that I'm misunderstanding some Relay-fu that would make this easier. I welcome education if so 😁
Extracted from #1995 (comment):
The text was updated successfully, but these errors were encountered: