Skip to content
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

await refetched queries before resolve mutation #3169

Merged
merged 12 commits into from
Jul 23, 2018

Conversation

jzimmek
Copy link
Contributor

@jzimmek jzimmek commented Mar 18, 2018

Fixes #1618.
Fixes #1821.
Fixes #3113.

Checklist:

  • If this PR is a new feature, please reference an issue where a consensus about the design was reached (not necessary for small changes)
  • Make sure all of the significant new logic is covered by tests
  • If this was a change that affects the external API used in GitHunt-React, update GitHunt-React and post a link to the PR in the discussion.

@apollo-cla
Copy link

@jzimmek: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Meteor Contributor Agreement here: https://contribute.meteor.com/

@jzimmek
Copy link
Contributor Author

jzimmek commented Mar 18, 2018

this pull request is adressing #1618

@jbaxleyiii jbaxleyiii changed the title await refetched queries before resolve mutation (not ready for merge yet) [WIP] await refetched queries before resolve mutation Mar 23, 2018
@hwillson hwillson self-assigned this May 18, 2018
}

this.query({
await this.query({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to let these queries run in parallel, rather than awaiting each one after the other?

optimisticResponse,
});
complete: async () => {
try {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One way to avoid this try-catch wrapping would be to use an async helper method:

complete: () => this._completeHelper().then(resolve, reject),
_completeHelper: async () => {
  if (error) {...}
  ...
  return storeResult;
}

@benjamn
Copy link
Member

benjamn commented Jun 8, 2018

You might want to rebase this PR and add a quick CHANGELOG, just to get those tests passing. Not sure why the bundle size would have changed at all…

@tkapiris
Copy link

Any progress on this PR? Tried it myself with some changes (a complete helper async function, an await Promise.all in refetchqueries along with an await in each refetch both with string or document input) and seems to work nicely. Of course it executes the refetches in serial mode.

Copy link
Member

@hwillson hwillson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your work on this @jzimmek!

@hwillson hwillson changed the title [WIP] await refetched queries before resolve mutation await refetched queries before resolve mutation Jul 23, 2018
@hwillson
Copy link
Member

We should be all set here, so it's LGTM time.

Quick note - react-apollo should be updated with similar awaitRefetchQueries changes (ideally before these changes get published). I'll try to get those changes in place for tomorrow, so we can release new apollo-client and react-apollo versions together.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
5 participants