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
Allow fields (which normally read out data) to be transformed into a common primitive that can power refetchable, loadOnce, paginated, fake deferred, etc fields
Plan
Add some sort of way to make fields imperatively loadable
Later, add the ability to make fields imperatively loaded at normalization time (including later normalization time of unrelated queries, as long as that query is mounted.) (Or, perhaps, for arbitrary code to run at normalization time iff the query is retained.) (See [RFC] Normalization-time loaded fields #79 )
Details
The imperatively loadable field will not have type T anymore, but instead have type { load: (variables) => Disposable<FragmentReference<_, T>> }
The initial way this will be used might be as follows:
iso(` field Query.HomePage { ViewerComponent @imperative blogs @imperative { BlogComponent } }`)((data)=>{// loadOnce has type { kind: 'Loaded', data: T } | { kind: 'NotLoaded', load: (variables) => void }constloadOnce=useLoadOnce(data.ViewerComponent);// paginate has type { data: Array<T>, loadMore: (count) => void, hasNext: boolean, isLoadingMore: boolean }constpaginate=usePagination(data.blogs);})
In the long term, you should be able to embed the transforms (e.g. useLoadOnce, usePagination, etc.) in the iso literal, as in:
iso(` field Query.HomePage { ViewerComponent @imperative | useLoadOnce }`)((data)=>{})
The text was updated successfully, but these errors were encountered:
rbalicki2
changed the title
[RFC] refetchable, paginated, loadable, etc. fields
[RFC] imperatively loadable fields to unlock refetchable, paginated, loadable, etc. fields
Apr 28, 2024
rbalicki2
changed the title
[RFC] imperatively loadable fields to unlock refetchable, paginated, loadable, etc. fields
[RFC] imperatively loadable fields to unlock refetchable, paginated, load once, etc. fields
Apr 28, 2024
Goal
Plan
Details
T
anymore, but instead have type{ load: (variables) => Disposable<FragmentReference<_, T>> }
The text was updated successfully, but these errors were encountered: