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

Reset store returns a promise #1674

Merged
merged 7 commits into from
May 27, 2017

Conversation

abergenw
Copy link
Contributor

@abergenw abergenw commented May 7, 2017

TODO:

  • If this PR is a new feature, 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
  • Rebase your changes on master so that they can be merged easily
  • Make sure all tests and linter rules pass
  • Update CHANGELOG.md with your change
  • Add your name and email to the AUTHORS file (optional)
  • If this was a change that affects the external API, update the docs and post a link to the PR in the discussion

@apollo-cla
Copy link

@abergenw: 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/

Copy link
Contributor

@helfer helfer left a comment

Choose a reason for hiding this comment

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

Hey @abergenw, thanks a lot! If you make the test a bit more complete I think it will be ready to merge.

@@ -2343,6 +2343,11 @@ describe('QueryManager', () => {
});

describe('store resets', () => {
it('returns a promise', done => {
const queryManager = createQueryManager({});
queryManager.resetStore().then(() => done());
Copy link
Contributor

Choose a reason for hiding this comment

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

This should check that all queries have completed refetching before the then is called.

Copy link
Contributor

@helfer helfer left a comment

Choose a reason for hiding this comment

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

I think the basic setup of the test is great, I would just change how it actually determines that the refetch happened. Using readQuery should be a lot more stable.

Also, make sure to associate your e-mail address with github so the commits will be assigned to you 😉

),
});

let count = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a bit concerned that using count across these two queries makes this test really likely to fail on unrelated changes because it bakes in the order in which these events are fired, which might not always stay the same. How about just running two watchQueries, then refetching when they're both ready, and then in the then callback of reset check that client.readQuery for the two queries returns the second response for each? readQuery is synchronous, so that should be fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@helfer
Copy link
Contributor

helfer commented May 26, 2017

Looks great, thanks a lot @abergenw !

@helfer helfer merged commit f74da28 into apollographql:master May 27, 2017
@helfer
Copy link
Contributor

helfer commented May 27, 2017

Merged 🎉 Can you update the docs @abergenw ?

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants