-
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
add updateLocal method to create transaction without comitting it #599
Conversation
This looks good, and thanks for the tests! Having two such similar methods is definitely redundant though. @yungsters @wincent - thoughts on making it the default for |
We should optimize for the most common use case, although figuring out what exactly that is is tricky. My intuition is that controlled inputs bound to mutations are actually the edge case, so the existing auto-commit behavior should be easy and the deferred-commit-managed-by-the-user behavior should be possible. So another possible option to consider:
If we go with two methods, I am not sure the meaning of the Finally, as for the idea of making |
Good points. So there are three options:
The last option feels the least awkward (especially with a rename s/update/enqueueUpdate/), and it also makes the option to enqueue a mutation but not commit it more discoverable. |
Totally agree with this, I really think the deferred commit way will be used in edge cases and probably should not be the default.
Which means this would make sense, but it does seem fairly awkward. I would personally probably go for this anyway I think. Let me know what you guys decide to go for and I'll update the PR |
@xuorig thanks for your patience. We chatted offline and came up with the following API:
Would you mind changing |
e7a14bf
to
f004a3c
Compare
Alright, I changed the method name to Squashed + reworded commit also. I will tackle 2 and 3 in another PR |
d7b7302
to
658fe5e
Compare
|
||
``` | ||
static applyUpdate(mutation: RelayMutation, callbacks: { | ||
onFailure?: (transaction: Transaction) => void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: transaction: RelayMutationTransaction
(also should update the above doc for update
for consistency)
@xuorig awesome, thanks! just two minor nits, otherwise this looks good to go. |
658fe5e
to
a43fa63
Compare
Addressed your nits! |
@facebook-github-bot import |
👍 |
Thanks for importing. If you are an FB employee go to https://our.intern.facebook.com/intern/opensource/github/pull_request/1727015024195186/int_phab to review. |
Summary: Follow up to #599, #550 Deprecate `RelayStore.update`, rename to `RelayStore.commitUpdate` `commitUpdate` now returns the `RelayMutationTransaction` just like `applyUpdate`. Changed to `commitUpdate` in the docs. I used `warning` to deprecate and also call the correct method, let me know if this is the way we should deprecate the function. Closes #607 Reviewed By: yungsters Differential Revision: D2668030 fb-gh-sync-id: 2a02b38009cf125089ddc341ce82173aee9fa294
For #550
Adds an
updateLocal
method toRelayStore
that creates a transaction in the Queue, but doesn't commit it.Returns a reference to the transaction so it can be committed or rollbacked afterwards.
There weren't any tests for update so I added a test for
update
andupdateLocal
, just making sure if the correct functions on the Queue and Transaction are called.