Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

error object on Query's children function is not reset #2072

Closed
htulipe opened this issue Jun 5, 2018 · 2 comments
Closed

error object on Query's children function is not reset #2072

htulipe opened this issue Jun 5, 2018 · 2 comments

Comments

@htulipe
Copy link

htulipe commented Jun 5, 2018

I'm trying to handle error cases when a query variables mutates. My problem is with the error object on query's children function which is not reset when cache is read.

I have a Query component executing a query with a sort order variable. Something like:

query MyQuery(
  $order: ReviewSortOrder
) {
  reviews(
    order: $order
  ) {
    ...
  }
}

The ReviewSortOrder type is either ASC or DESC but right now only ASC is implemented and running the query with DESC returns an error from server.

Here is how my code executes:

  • Default order is ASC: the query fires and gets a positive response. Query's children function is called with the data and no error object.
  • User changes order via UI to DESC: the query fires again and gets an error response. Query's children function is called with an error object.
  • User changes back to ASC: the query does not fire because the cache is used. Query's children function is called with the previous error object.

Intended outcome:

I'd expect the last call to children to not include the error object.

Actual outcome:

The last call to children contains the error object from the previous execution

How to reproduce the issue:

I don't have a reproduction repo or sandbox, sorry. My Query is configured with fetchPolicy at cache-first and notifyOnNetworkStatusChange at true, other props use their default values.

Version

Many thanks for your help

@hughfm
Copy link

hughfm commented Aug 20, 2018

Interested if anyone has a reasonable way to handle this behavior? Is it considered a bug or expected?

@hwillson
Copy link
Member

This was addressed in #2718, which was included in react-apollo 2.5.3. Thanks!

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

No branches or pull requests

3 participants