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

Refactor QueryManager to make better use of observables and enforce fetchPolicy more reliably #6221

Merged
merged 86 commits into from
May 7, 2020

Commits on May 7, 2020

  1. Configuration menu
    Copy the full SHA
    e1a416a View commit details
    Browse the repository at this point in the history
  2. Fix broken useQuery tests.

    These tests were swallowing "No more mocked responses..." errors because
    of the missing call to setOnError. After I fixed that, the tests began
    consistently failing because they made too many requests of the mock link
    chain, so I reduced the expected number of requests, while mostly
    preserving the original spirit of the tests.
    benjamn committed May 7, 2020
    Configuration menu
    Copy the full SHA
    e8f4674 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    1f0e5ba View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    c392e95 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    8b84ed6 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    3c38470 View commit details
    Browse the repository at this point in the history
  7. Improve QueryManager tests.

    benjamn committed May 7, 2020
    Configuration menu
    Copy the full SHA
    94fe1ff View commit details
    Browse the repository at this point in the history
  8. Rename multiplex to multicast.

    Though this API is not perfectly aligned with the RxJS multicast operator
    (no explicit Subject, for example), the spirit is definitely the same, and
    "multiplex" was mistaken terminology: https://rxjs.dev/api/operators/multicast
    benjamn committed May 7, 2020
    Configuration menu
    Copy the full SHA
    8fa1457 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    a0b6525 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    816d4f5 View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    5773ba1 View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    edd5ba3 View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    40e3921 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    d84ee83 View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    35502f4 View commit details
    Browse the repository at this point in the history
  16. Improve Concast comments.

    benjamn committed May 7, 2020
    Configuration menu
    Copy the full SHA
    570cb66 View commit details
    Browse the repository at this point in the history
  17. Configuration menu
    Copy the full SHA
    4b24a39 View commit details
    Browse the repository at this point in the history
  18. Configuration menu
    Copy the full SHA
    be8c20a View commit details
    Browse the repository at this point in the history
  19. Configuration menu
    Copy the full SHA
    6c0ef9f View commit details
    Browse the repository at this point in the history
  20. Configuration menu
    Copy the full SHA
    9d77948 View commit details
    Browse the repository at this point in the history
  21. Configuration menu
    Copy the full SHA
    e58b2d6 View commit details
    Browse the repository at this point in the history
  22. Configuration menu
    Copy the full SHA
    85a07d4 View commit details
    Browse the repository at this point in the history
  23. Configuration menu
    Copy the full SHA
    180fb00 View commit details
    Browse the repository at this point in the history
  24. Configuration menu
    Copy the full SHA
    34e19e8 View commit details
    Browse the repository at this point in the history
  25. Configuration menu
    Copy the full SHA
    58a88ca View commit details
    Browse the repository at this point in the history
  26. Configuration menu
    Copy the full SHA
    428655a View commit details
    Browse the repository at this point in the history
  27. Configuration menu
    Copy the full SHA
    cba7240 View commit details
    Browse the repository at this point in the history
  28. Configuration menu
    Copy the full SHA
    ae3f6d5 View commit details
    Browse the repository at this point in the history
  29. Configuration menu
    Copy the full SHA
    99014ed View commit details
    Browse the repository at this point in the history
  30. Configuration menu
    Copy the full SHA
    3c17286 View commit details
    Browse the repository at this point in the history
  31. Configuration menu
    Copy the full SHA
    0d6646c View commit details
    Browse the repository at this point in the history
  32. Use ObservableQuery.reobserve when polling, when possible.

    If we move polling logic from QueryManager into ObservableQuery, then we
    will always have an ObservableQuery available to consume results when we
    are polling, which should eliminate the non-ObservableQuery branch of this
    condition.
    benjamn committed May 7, 2020
    Configuration menu
    Copy the full SHA
    f141aa7 View commit details
    Browse the repository at this point in the history
  33. Configuration menu
    Copy the full SHA
    3a414a5 View commit details
    Browse the repository at this point in the history
  34. Configuration menu
    Copy the full SHA
    8aeeba4 View commit details
    Browse the repository at this point in the history
  35. Configuration menu
    Copy the full SHA
    3c7d00e View commit details
    Browse the repository at this point in the history
  36. Configuration menu
    Copy the full SHA
    71733c7 View commit details
    Browse the repository at this point in the history
  37. Configuration menu
    Copy the full SHA
    23b9d07 View commit details
    Browse the repository at this point in the history
  38. Configuration menu
    Copy the full SHA
    6a40aef View commit details
    Browse the repository at this point in the history
  39. Configuration menu
    Copy the full SHA
    6acaa37 View commit details
    Browse the repository at this point in the history
  40. Configuration menu
    Copy the full SHA
    9793b7d View commit details
    Browse the repository at this point in the history
  41. Configuration menu
    Copy the full SHA
    6e6c8d1 View commit details
    Browse the repository at this point in the history
  42. Configuration menu
    Copy the full SHA
    c1293d8 View commit details
    Browse the repository at this point in the history
  43. Fall back to queryInfo.getDiff() if diff.result empty.

    I'm not completely happy with this, but it seems to keep some existing
    tests passing.
    benjamn committed May 7, 2020
    Configuration menu
    Copy the full SHA
    397a8aa View commit details
    Browse the repository at this point in the history
  44. Configuration menu
    Copy the full SHA
    c4ca3d4 View commit details
    Browse the repository at this point in the history
  45. Configuration menu
    Copy the full SHA
    b88da6d View commit details
    Browse the repository at this point in the history
  46. Configuration menu
    Copy the full SHA
    ecfa334 View commit details
    Browse the repository at this point in the history
  47. Configuration menu
    Copy the full SHA
    9f40894 View commit details
    Browse the repository at this point in the history
  48. Configuration menu
    Copy the full SHA
    c9dc1b0 View commit details
    Browse the repository at this point in the history
  49. Configuration menu
    Copy the full SHA
    2f560ed View commit details
    Browse the repository at this point in the history
  50. Configuration menu
    Copy the full SHA
    f7253c4 View commit details
    Browse the repository at this point in the history
  51. Configuration menu
    Copy the full SHA
    6151bbe View commit details
    Browse the repository at this point in the history
  52. Configuration menu
    Copy the full SHA
    0c1cdf6 View commit details
    Browse the repository at this point in the history
  53. Rename fqoHelper to fetchQueryHelper.

    Since it now returns an array of observables, rather than a combined
    observable, the 'o' in fqoHelper is no longer strictly warranted.
    benjamn committed May 7, 2020
    Configuration menu
    Copy the full SHA
    2186aeb View commit details
    Browse the repository at this point in the history
  54. Configuration menu
    Copy the full SHA
    59ca80a View commit details
    Browse the repository at this point in the history
  55. Configuration menu
    Copy the full SHA
    b411ee5 View commit details
    Browse the repository at this point in the history
  56. Configuration menu
    Copy the full SHA
    ff04d02 View commit details
    Browse the repository at this point in the history
  57. Configuration menu
    Copy the full SHA
    45a07a3 View commit details
    Browse the repository at this point in the history
  58. Simplify QueryInfo#shouldNotify.

    QueryManager#fetchQueryObservable now manages this logic (see
    mightUseNetwork and related code), so we don't need to do as much work in
    shouldNotify.
    benjamn committed May 7, 2020
    Configuration menu
    Copy the full SHA
    9dd15b8 View commit details
    Browse the repository at this point in the history
  59. Configuration menu
    Copy the full SHA
    665c4cb View commit details
    Browse the repository at this point in the history
  60. Fix old QueryRecycler tests.

    ObservableQuery#isTornDown is not a public property, so testing its value
    by abusing the type system was always a bit of an overreach.
    benjamn committed May 7, 2020
    Configuration menu
    Copy the full SHA
    098c060 View commit details
    Browse the repository at this point in the history
  61. Configuration menu
    Copy the full SHA
    b239124 View commit details
    Browse the repository at this point in the history
  62. Fix QueryManager tests.

    benjamn committed May 7, 2020
    Configuration menu
    Copy the full SHA
    8c37713 View commit details
    Browse the repository at this point in the history
  63. Fix fetchMore tests.

    TODO These changes might not be necessary if we were properly
    updating/delivering loading states for the original query for which we're
    fetching more results.
    
    The tests that I removed entirely were duplicates of other tests that I
    fixed/adjusted.
    benjamn committed May 7, 2020
    Configuration menu
    Copy the full SHA
    2ce4051 View commit details
    Browse the repository at this point in the history
  64. Fix mutationResults tests.

    benjamn committed May 7, 2020
    Configuration menu
    Copy the full SHA
    691384e View commit details
    Browse the repository at this point in the history
  65. Fix useQuery tests.

    benjamn committed May 7, 2020
    Configuration menu
    Copy the full SHA
    f952698 View commit details
    Browse the repository at this point in the history
  66. Configuration menu
    Copy the full SHA
    8f9f63d View commit details
    Browse the repository at this point in the history
  67. Fix ObservableQuery tests.

    benjamn committed May 7, 2020
    Configuration menu
    Copy the full SHA
    76e22d7 View commit details
    Browse the repository at this point in the history
  68. Improve racy subscribeToMore tests.

    The use of setTimeout in tests is often an invitation to race conditions
    and timing-sensitive outcomes.
    
    This raciness became particularly problematic thanks to changes (between
    Node 10 and Node 12) in the timing of Promise callbacks with respect to
    setTimeout callbacks.
    
    These changes also leave all tests passing when cherry-picked onto master,
    so I'm confident I am *not* changing the tests just to fix my PR #6221, at
    the expense of backwards compatibility.
    benjamn committed May 7, 2020
    Configuration menu
    Copy the full SHA
    a23c194 View commit details
    Browse the repository at this point in the history
  69. Configuration menu
    Copy the full SHA
    e7f29aa View commit details
    Browse the repository at this point in the history
  70. Configuration menu
    Copy the full SHA
    bcd1014 View commit details
    Browse the repository at this point in the history
  71. Configuration menu
    Copy the full SHA
    e24e446 View commit details
    Browse the repository at this point in the history
  72. Remove redundant addExportedVariables logic from observer.next.

    Now that the ObservableQuery consumes results exclusively through
    QueryManager#fetchQueryObservable, we can rely on the addExportedVariables
    call that happens there, and avoid potentially re-triggering a network
    request while consuming network results.
    
    @hwillson I was a bit surprised this change didn't cause any tests to
    fail, but several tests did fail when I cherry-picked it onto master, so
    I'm optimistic this addExportedVariables logic is genuinely redundant
    after my refactoring PR #6221.
    benjamn committed May 7, 2020
    Configuration menu
    Copy the full SHA
    28fc24e View commit details
    Browse the repository at this point in the history
  73. Configuration menu
    Copy the full SHA
    12d6729 View commit details
    Browse the repository at this point in the history
  74. Update comment in src/core/Reobserver.ts.

    Thanks to @danReynolds for catching this.
    
    Co-authored-by: Dan Reynolds <me@danreynolds.ca>
    benjamn and danReynolds committed May 7, 2020
    Configuration menu
    Copy the full SHA
    fb6801f View commit details
    Browse the repository at this point in the history
  75. Configuration menu
    Copy the full SHA
    c3dae7b View commit details
    Browse the repository at this point in the history
  76. Configuration menu
    Copy the full SHA
    892ee4e View commit details
    Browse the repository at this point in the history
  77. Configuration menu
    Copy the full SHA
    aecd453 View commit details
    Browse the repository at this point in the history
  78. Configuration menu
    Copy the full SHA
    b1562e5 View commit details
    Browse the repository at this point in the history
  79. Configuration menu
    Copy the full SHA
    4dff16f View commit details
    Browse the repository at this point in the history
  80. Configuration menu
    Copy the full SHA
    190ce59 View commit details
    Browse the repository at this point in the history
  81. Avoid unconditionally cancelling cache.watch in updateWatch.

    Besides addressing an important TODO, the privatization of the cancel
    method also resolves #6221 (comment)
    benjamn committed May 7, 2020
    Configuration menu
    Copy the full SHA
    6122cac View commit details
    Browse the repository at this point in the history
  82. Configuration menu
    Copy the full SHA
    cfa385d View commit details
    Browse the repository at this point in the history
  83. Configuration menu
    Copy the full SHA
    6ff3a59 View commit details
    Browse the repository at this point in the history
  84. Configuration menu
    Copy the full SHA
    4e48779 View commit details
    Browse the repository at this point in the history
  85. Reinstate warnings about missing cache fields.

    This functionality was introduced in PR #6058 (beta.43), and was
    temporarily removed by my refactoring PR #6221.
    
    I believe these warnings can be improved, especially since they are pretty
    noisy right now, but I wanted to preserve existing functionality before
    trying to figure out a better way to report missing fields.
    
    Any/all ideas and feedback welcome.
    benjamn committed May 7, 2020
    Configuration menu
    Copy the full SHA
    9e56386 View commit details
    Browse the repository at this point in the history
  86. Mention PR #6221 in CHANGELOG.md.

    benjamn committed May 7, 2020
    Configuration menu
    Copy the full SHA
    2de0e23 View commit details
    Browse the repository at this point in the history