-
Notifications
You must be signed in to change notification settings - Fork 786
Refetch does not work with variables #1929
Comments
+1 |
I'm having the same issue as @kimochg; calling Is there some missing step, or is this a bug? |
Same for me, the only two ways it's working for me it's with
|
Same here, except im doing something like this
where searchResourcesPaged takes a page int, I want to re use the one that was previously used. in my case it does not refetch |
Any updates on this issue? I am trying to build pagination, I can see the refetch with updated variable |
I think I know when its happens: Main advice will be to not use initial vars and I don't know which is proper fix will be in |
Same here, I am using other config options I hope it doesn't matter:
|
Fixed adding the flag to skip the cache in the specific fragments with field id that I don't wanna cache:
Reference: https://kamranicus.com/posts/2018-03-06-graphql-apollo-object-caching |
Looks a lot like apollographql/apollo-client#2285 |
This was my solution before using apollo client and writing to cache:
No longer an issue to use
|
Anyone has a solution for this issue. I still get stuck with refetch function. It doest not return the updated data when passing new variables |
@khaphannm I don't remember it correctly but my issue got resolved by changing Please check if it works in your case. Or it should work with |
React Apollo has been refactored to use React Hooks behind the scenes for everything, which means a lot has changed since this issue was opened (and a lot of outstanding issues have been resolved). We'll close this issue off, but please let us know if you're still encountering this problem using React Apollo >= 3.1.0. Thanks! |
This error is still present in graphql(getLocations, {
props: ({ data: { users, refetch, updateQuery, loading, error } }) => {
// ERROR HUNT: The problem is that the previously used query variables
// are not removed when passing new variables
// this can be observed in the apollo console
return {
title: 'Locations',
locations,
refetch,
updateQuery,
loading,
error
}
} and in component: handleSubmit = () => {
const {
form: { getFieldsValue },
updateQuery,
refetch
} = this.props
let fields = getFieldsValue()
fields = omit(fields, value => value == null || value === '')
// this is not working, variables used in previous query are not updated/removed
//refetch({ ...fields, dummy: Math.random() })
refetch({ ...fields })
} Example: Run query with Apollo "watch query" console output:
Then run query with Apollo "watch query" console output:
|
I'm also experiencing the same issue. Has there been any update on this? |
this error still apear with me |
I am trying to implement a straightforward search on react-native. I was previously using react-apollo 1.x, and the following snippet worked fine ie when i change the search state in Wrapper, the List component reruns with the new value of search.
I just cannot figure out how to do the same with the new Query component. I have tried replacing ListWIthQuery with the new Query component like below. But the list does not refetch when search changes.
I also tried using the refetch function in the renderProps of query to manually trigger a refetch with new variables whenever the search state is changed(see below snippet). This refetches the query but i cannot seem to pass in the new search variable.
In my opinion, this is a real basic use case and it worked fine with the old pattern of wrapping components with graphql(), but I just cannot get it to work with the new Query Component. I cannot find anything in the docs which leads to a solution. Am i going about this the wrong way? Can someone please help with this.
The text was updated successfully, but these errors were encountered: