apollographql / apollo-client

:rocket:  A fully-featured, production ready caching GraphQL client for every UI framework and GraphQL server.
https://apollographql.com/client
MIT License
19.38k stars 2.66k forks source link

Invalid error propagation In Query Component between queries differed by variables #3772

Closed gandhiamarnadh closed 5 years ago

gandhiamarnadh commented 6 years ago

query + variables A return dataA and no errors query + variables B return no data and errorB

Intended outcome:

  1. Running a query Using Query Component initially with set of variables A that returns dataA and no errors.
  2. Query is now updated with another set of variables B that returns errorB and no data.
  3. Updating Query again with A variables should return dataA and no errors in render props.

Actual outcome: a. In step 2 render props returns twice

b. In step 3 render props returns once

Problem: why in 'a' data is present although that query didn't return data ? 'b' returning error from previous call although this call cached data has no errors? also the data returned in 'b is not based on it's cached data but the last successfully received data (tested with another variable set)

Initially thought this is related to error issues with refetch, which may not be the case. This is most common behaviour expected from the package so this is a major bug.

for issue at 'b' at this line correct result is picked, but further querySet and querState init are called and finally errors from previous query are thrown here

Work Around: I was able to fix the issue in step 'b' by not passing previous errors into updation of querystore setting [] here however I don't know the side effects of this. (If at all only network errors should be passed on)

How to reproduce the issue:

Versions

System: OS: macOS High Sierra 10.13.6 Binaries: Node: 8.11.2 - /usr/local/bin/node Browsers: Chrome: 67.0.3396.99 Firefox: 61.0.1 Safari: 11.1.2 npmPackages: apollo-boost: 0.1.4 => 0.1.4 apollo-cache-inmemory: 1.2.5 => 1.2.5 apollo-client: 2.3.7 => 2.3.7 apollo-link: 1.2.2 => 1.2.2 apollo-link-batch-http: 1.2.2 => 1.2.2 apollo-link-error: 1.1.0 => 1.1.0 apollo-link-state: 0.4.1 => 0.4.1 react-apollo: 2.1.9 => 2.1.9

gandhiamarnadh commented 6 years ago

3103 related

2200 #2214 change is introduced in these PR's

hwillson commented 5 years ago

This should no longer be an issue using modern versions of apollo-client and react-apollo. Thanks!