Closed
Description
The problem is that i still want to wait for a specific request made by the lazy query.
// at my store:
const { load, loading, error, result } = useLazyQuery()
// inside the component:
const data = await load()
Because load
doesn't return the current request promise, many reactive variables needed to be watched unwillingly.
The suggested solution
load()
should return the promise to the current request.
also every other fetching function like rerun
etc.
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
- [Snyk] Upgrade @vue/apollo-composable from 4.0.0-beta.5 to 4.0.2Shoutzor/frontend
- [Snyk] Upgrade @vue/apollo-composable from 4.0.0-beta.5 to 4.0.2Shoutzor/frontend
- [Snyk] Upgrade @vue/apollo-composable from 4.0.0-beta.5 to 4.0.2Shoutzor/frontend
- [Snyk] Upgrade @vue/apollo-composable from 4.0.0-beta.5 to 4.0.2Shoutzor/frontend
- [Snyk] Upgrade @vue/apollo-composable from 4.0.0-beta.5 to 4.0.2Shoutzor/frontend
- [Snyk] Upgrade @vue/apollo-components from 4.0.0-beta.5 to 4.0.0Shoutzor/frontend
Activity
Csszabi98 commentedon Jul 6, 2023
For now you can do:
sschneider-ihre-pvs commentedon Aug 25, 2023
{loading: true, networkStatus: 1, partial: true}
doesn't seem to worktcitworld commentedon Aug 31, 2023
You can make sure the promise is only resolved when the query is no longer loading.
Csszabi98 commentedon Sep 4, 2023
@sschneider-ihre-pvs That is a different issue,
useLazyQuery
does not invokeonServerPrefetch
in this case. See: #1495. You can use the mentioned workaround to fix that.Also, this is the final implementation of waitForApolloQuery that ended up working for me:
Usage of
setTimeout
is required if you have multiple async functions waiting for the same Apollo query. (onResult and onError are invoked inside of a for cycle and synchronous removal of the event handlers will affect their invocation order, leading to not all handlers being called)feat(useLazyQuery): load returns Promise, fix vuejs#1486