-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
Hello everyone!
I very recently started thinking about using deferred queries for making a progressive react app with Relay. My idea to use deferred queries for this is to be able to split data requirements the same way we can split react components. This is kind of possible by having query renderers.. but it quickly becomes very bloated and hard to work with.
From a conversation on Twitter I am creating this issue to track the progress and share thoughts on adding deferred queries into Relay Modern. I have myself started experimenting with it, so far I've only been working on a basic query transformer in the compiler.
I heard that you @leebyron actually are working on this internally right now. Is it possible for you to share your work and issues here on Github? I think it would be really good if this can be developed in the open behind some experimental/unstable flag (like React does).
It would also be very interesting to hear what thoughts the rest of the Relay team and others have on this! @josephsavona "confirmed" on Twitter that it is possible to solve. @wincent Maybe you have some ideas on this since you worked on it for Relay Classic.
I am imaging the relay compiler building these extra queries just like normal queries and have the runtime linking them together somehow. Or maybe it makes sense to introduce a list/tree on the concrete batch for deferred queries.
Main issues I see
I see some problems right now... I have not had time to dig into them yet though...
-
Variables
Figuring out what variables the deferred queries needs and does not need. Maybe we need some sort filtering of variables at runtime. -
store selectors
Do we need to switch the selectors when starting to execute deferred queries or can Relay handle the initial selector including all fields from the deferred responses? Since the initial query response will miss those fields I assume Relay will throw errors about fields being undefined in the normalize phase. -
Refetch containers / pagination containers
I don't know if this will be a problem.. but I have feeling these will require some extra logic around this.