-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support code-splitting mutation operations with useMutation #4827
Comments
Yes! This is a much needed ability, I'm fully in favor of finding a way for us to support this. In fact, it may be that this should be the recommended default way to use mutations. Given that, we should think carefully about what would be the best API here to make it easy to get right and low-friction. One significant challenge is that today the babel transform blindly converts the I could also see a few options around when we load the artifact:
There are a lot of options here, so probably the next step would be to brainstorm. What timezone are you in? Would you be interested in attending one of our design discussion meetings to discuss what options we have here and decide what the next concrete steps would be? I think this is really important work and would love to help support you get this feature added to Relay! |
Ah yeah I hadn't factored this in. Needing to define that in a separate file is definitely tedious (on top of likely defining a hook per mutation in its own file to capture common response handling logic)
I am in PT, I'd be happy to join a design discussion meeting on this! |
Almost all mutations are not needed for the initial render of a page, often being triggered by some delayed user interaction like a button click. However, it is currently hard to avoid bloating bundles with the mutation nodes when using the built-in
useMutation
hook. The mutation nodes contain JS proportional to the mutation document size (and thus potentially proportional to the page size if the page's data is included as a fragment) in the query text and operation/fragment fields.There's two main problems I've run into trying to solve this:
PreloadableConcreteRequest
), as well as a promise/JSResource for the actual mutation node (similar touseQueryLoader
, or perhapsuseEntryPointLoader
)While it would be possible to roll my own version of useMutation which allows this (the logic doesn't seem too complicated), I think it would be beneficial to provide first-class support to encourage this pattern. I'd be happy to help contribute something for this, but would like some confirmation that these are the right paths to go down
The text was updated successfully, but these errors were encountered: