apollo
apollo copied to clipboard
[Question] Get loading state of query in another component
Hello,
I wanted to ask if it is possible to get the loading-state of a query that's executed in another component.
Example: Dashboard and Login are handled in different components. Now I would like to show a loading state on the dashboard when doing the login / fetching the current user.
This could done with Vue events (sending an event from the Login component when loading starts and another one when loading end), but I fear that's going to more difficult to maintain. Especially if it's used not just in the dashboard.
So my ideal solution would be:
Having access to a query from another component. If I could use this.$apollo.queries.CurrentUser.loading from the Dashboard this would allow to easily watch for changes in that query.
Is there a way to register queries on the $apollo property for all instances?
In Composition API you can just pass whole useQuery / useMutation object as component prop and use it in other's component template. I don't know how it works in Options API though.
I have the same case:
I have a dashboard, I'm loading many data. I would like to show loader for Dashboard, but at the same time, I'm loading data inside of Sections.
Yes, you load data on Dashboard and pass to sections but, then I have separate pages, where the same section components are used. I know, hard to visualize but basically, I need the same access to query