You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Inside reftechQueries, I need the response of the original mutation to use the result as a variable for the refetch query.
I saw, even if not really documented, that a RefetchQueriesFunction is accepted as refetchQueries.
Trying to retro-engineer how this function would work, I print the arguments received to the console an see that the response is sent as first argument!
Typescript tells me that the function should return a Array<string | PureQueryOptions>.
Great, this is exactly what I need.
Actual outcome:
The actual outcome is, at runtime the first argument that as the exact same shape as data in
const{ data }=useQuery(...)// ^
is undefined. (the prop inside data is actually undefined).
So for a mutation called addPost, data.addPost will be undefined at runtime.
The fact that the console shows the data on console.log is probably due to a pointer value being updated and the console shows the updated value.
So, I see two options here:
1/ My retro-engineering is wrong and the RefetchQueriesFunction should be documented.
2/ My retro-engineering is right and something is wrong in the implementation of RefetchQueriesFunction. Maybe response is not awaited properly or something ?
How to reproduce the issue:
I guess this is pretty straightforward, if you need any additional info just tell me :)
I'm open to creating a PR if needed.
Thanks for your wonderful work 👏
The text was updated successfully, but these errors were encountered:
toniopelo
changed the title
RefetchQueriesFunction does not send mutation result as first parameter and is not documented
RefetchQueriesFunction does not receive mutation result as first parameter and is not documented
Dec 15, 2020
In my case, the refetchQueries function actually receive the mutation result and it's working as intended. It's just that the argument is not properly typed yet, and it's marked as any, instead of the type of the mutation result.
I saw on the roadmap that there would be a rework for refetchQueries, so I guess this could be fixed on version 3.4.0
Intended outcome:
Inside reftechQueries, I need the response of the original mutation to use the result as a variable for the refetch query.
I saw, even if not really documented, that a
RefetchQueriesFunction
is accepted asrefetchQueries
.Trying to retro-engineer how this function would work, I print the arguments received to the console an see that the response is sent as first argument!
Typescript tells me that the function should return a
Array<string | PureQueryOptions>
.Great, this is exactly what I need.
Actual outcome:
The actual outcome is, at runtime the first argument that as the exact same shape as
data
inis undefined. (the prop inside data is actually undefined).
So for a mutation called
addPost
,data.addPost
will be undefined at runtime.The fact that the console shows the data on console.log is probably due to a pointer value being updated and the console shows the updated value.
So, I see two options here:
1/ My retro-engineering is wrong and the
RefetchQueriesFunction
should be documented.2/ My retro-engineering is right and something is wrong in the implementation of
RefetchQueriesFunction
. Maybe response is not awaited properly or something ?How to reproduce the issue:
I guess this is pretty straightforward, if you need any additional info just tell me :)
Versions
I'm open to creating a PR if needed.
Thanks for your wonderful work 👏
The text was updated successfully, but these errors were encountered: