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

does 'refetch' suppose to update data props? #1391

Closed
kdong007 opened this issue Dec 8, 2017 · 10 comments
Closed

does 'refetch' suppose to update data props? #1391

kdong007 opened this issue Dec 8, 2017 · 10 comments

Comments

@kdong007
Copy link

kdong007 commented Dec 8, 2017

seems calling props.data.refetch only returns a promise but not update the component. Is this as designed or a bug?

@alewiahmed
Copy link

I'm having this issue too. When you call a refetch it returns a promise. When the promise is resolved you get the data, errors, networkStatus, etc. But those fields should have updated the component props, IMO.

@alewiahmed
Copy link

@kdong007 if you're still having trouble with data.refetch, you should checkout apollographql/apollo-client#2513 .The solution of @adambom helped.

@kdong007
Copy link
Author

@alewiahmed that works. refetch -> retry :D

@adambom
Copy link

adambom commented Dec 26, 2017

@kdong007 if you keep scrolling down I came up with a better workaround that allows you to continue using refetch instead of retry. I published it under the package react-apollo-temp-adambom if you want to try that

@alewiahmed
Copy link

alewiahmed commented Dec 27, 2017

@kdong007 , @adambom is right, I used his package, react-apollo-temp-adambom. You don't need the retry stuff, just use refetch as you always.

@kdong007
Copy link
Author

@adambom just found an issue with the fix. First you get an error state for the component, and then update some props of the component, data.loading become true and data.error is cleared.

I tracked the issue down to apollo-client, the issue is related to unsubribe/create query, so the old error result is removed by tearDownQuery()

@adambom
Copy link

adambom commented Dec 28, 2017

@kdong007 Can you provide repro steps and include line numbers of the code you're referencing?

I'll do my best to address the issue if possible if you're able to provide some more information, but it was really only meant to be a hack, so there may be a better way of addressing the problem.

@kdong007
Copy link
Author

kdong007 commented Jan 3, 2018

@adambom
I just realized it is not refetch related. I posted another one here. #1509

@Elijen
Copy link

Elijen commented May 11, 2018

@kdong007 @adambom So what is the answer to the original question? Is refetch supposed to update the component's props? I think the linked issue is only relevant if one of the refetch queries fails.

@rosskevin
Copy link
Contributor

Closing - housekeeping - ping me if it needs to be reopened.

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

5 participants