Do not overfetch data in design management
Summary
We're agressively overfetching data in current design app implementation. At the moment, for example, we're loading entire project with entire designs with entire discussions during page load and use that as main source of truth for entire design management
Problems
- Writing optimistic responses (see discussion https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/14648#note_199148726)
- Keeping data in-sync between cache and query responses (see #13231 (closed))
- Relations between entities are expressed in code and will be easily out-of-sync in case of further schema expansion
Suggested solution
We should split our huge queries and utilize GraphQL exactly in the way it was designed to - fetching relevant data only when needed. For example for design app (sorry, my view might be incomplete, since it mostly based on reviewing !14648 (merged)):
- at the very start we need only amount of designs for latest version
- when switched to discussions tab we need to prepopulate versions list and list of designs for specific version
- loading separate design right now does not have separate query, so we still need to fetch specific version (same like previous one)
It's really important to split this to small chunks as soon as possible since adding new functionality will most likely require more and more code to maintain current state of things
/cc @andr3 @ntepluhina