-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
refetch doesn't update store at certain circumstances #3573
Comments
refetchQueries has caused me so many headaches since moving to apollo... |
Is this related to (or perhaps the cause of) apollographql/react-apollo#1929? I tried a simple React |
@dendrochronology Are you able to share the quick sample app you put together, that shows this happening? Any form of repro would greatly help here (you can use https://codesandbox.io/s/7361K9q6w as a starting point if that helps). Thanks! |
In setting up an example, I realized that |
Refetch don't work for me, i pass variables and doesn't update store |
refetch is returning new data in the console for me, but is not updating the props of the components grabbing it or using the query we're refetching |
Same issuehere |
If anyone here can supply a reproduction that demonstrates this issue, I'll be happy to take a look. Closing for now though since we haven't received a repro. Thanks! |
Reproduced as #2285 |
Updates ? |
I use recompose pattern to organize my react components.
The
withGetQAPairsPageing
HOC is declared as below:The above code's feature is simple and easy to reason about. It provides a table component with paging functionality.
I've dived into the source code of
apollo-client
a little bit.I found that this statement in my code,
dispatch(setTableLoadingState(true));
, caused the whole component to re-render which thencaused the
Query.componentWillReceiveProps
to callupdateQuery
method.Since the query variables had changed(pageNum was changed),
ObservableQuery.setVariables
then triggeredthis.queryManager.fetchQuery
and maderequestId
increased by 1 which resulted in the conditional expressionrequestId >= (lastRequestId || 1)
infetchQuery
failed when the actual request had finished.The consequence of failing the above condition is the
_this.setQuery
infetchRequest
function would never be called and result of this request was accidentally discarded. That's why the table stayed unchanged.Intended outcome:
The table content changes to the next page after clicking the next button.
Actual outcome:
The table content stays unchanged after clicking the next button.
How to reproduce the issue:
Versions
System:
OS: macOS High Sierra 10.13.4
Binaries:
Node: 8.9.4 - ~/.nvm/versions/node/v8.9.4/bin/node
npm: 6.0.0 - ~/.nvm/versions/node/v8.9.4/bin/npm
Browsers:
Chrome: 66.0.3359.181
Safari: 11.1
npmPackages:
apollo-cache-inmemory: ^1.1.12 => 1.2.2
apollo-client: ^2.2.8 => 2.3.2
apollo-link: ^1.2.2 => 1.2.2
apollo-link-batch-http: ^1.2.2 => 1.2.2
apollo-link-error: ^1.0.9 => 1.1.0
apollo-link-schema: ^1.1.0 => 1.1.0
apollo-server-koa: ^1.3.4 => 1.3.6
react-apollo: ^2.1.4 => 2.1.4
The text was updated successfully, but these errors were encountered: