Intended outcome:
I want to use refetch to re-send the same query with new variables. I expect the returned promise to deliver the results in data.
Actual outcome:
When refetch is used with new variables, the following object is returned by the promise:
{
data: undefined
errors: undefined,
loading: false,
networkStatus: 7,
stale: false,
}
Version
The network status seems to indicate that there were to obvious errors with the query execution.
Could you implement a test case that elicits this behavior? That'll allow us to identify what is wrong and whether or not it constitutes intended behavior.
We haven't heard back regarding the reproduction requested in https://github.com/apollographql/apollo-client/issues/2914#issuecomment-360741571, so closing for now. If this issue is still happening, and you're able to supply a reproduction, we'll be happy to re-visit it. Thanks!
I'm getting the exact same issue, the API hits successfully and returns data in network tab (chrom dev tools) but the promise returned by refetch has {data: undefined, errors: undefined, loading: false, networkStatus: 7, stale: false}. This happens when I pass variable (dynamic) in refetch as
refetch({ first: 10, filter: { search } })
I'm getting the exact same issue, the API hits successfully and returns data in network tab (chrom dev tools) but the promise returned by refetch has {data: undefined, errors: undefined, loading: false, networkStatus: 7, stale: false}. This happens when I pass variable (dynamic) in refetch as
refetch({ first: 10, filter: { search } })
I found the issue, I had implemented cache in my apollo client, so whenever I was using refetch it used to get response from the cache. If variables were different it would return undefined. Setting up fetch policy to 'no-cache' in query options (I'm using hooks) resolved the issue
{
variables: { first: 10, filter: { search: '' } },
fetchPolicy: 'no-cache',
}
Most helpful comment
I found the issue, I had implemented cache in my apollo client, so whenever I was using refetch it used to get response from the cache. If variables were different it would return undefined. Setting up fetch policy to 'no-cache' in query options (I'm using hooks) resolved the issue
{ variables: { first: 10, filter: { search: '' } }, fetchPolicy: 'no-cache', }