New: Use typePolicies and makeVar to store client-side state
New Pattern Proposal: "Use typePolicies and makeVar to store client-side state"
Apollo Client 3 allows us to manage application state with type policies with reactive variables, this pattern may replace client-side resolvers (in some cases?).
Advantages of new pattern
- Reactive variables (
makeVar
) manage updates in components automatically. - Current local resolvers are deprecated by Apollo Client: https://www.apollographql.com/docs/react/local-state/local-resolvers/, and will have to be reimplemented as part of the link chain.
Disadvantages of new pattern
- We don't use mutations as with backend changes, and require one more inject to modify state.
- We have yet one more way to state state on the client.
- We don't have a good way to track local state of the reactive variable using Apollo devtools.
What is the impact on our existing codebase?
I expect that we will use the best tool on a case-by-case basis, and each product area will choose an approach that suits them, no sweeping changes.
Reference implementation
Introduce admin_runners_bulk_delete feature flag (gitlab-org/gitlab!81894 - merged)
New
Edited by Miguel Rincon