-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refresh not updating data in useAsyncQuery #483
Comments
I'm facing the same problem with this config setup |
@chrispreisler can you try if this works for you? <script setup>
const query = gql`
query ($id: ID!) {
collection(id: $id) {
title
}
}
`;
const variables = ref({
id: ref('gid://shopify/Collection/274542428327');
});
const { data, refresh } = await useAsyncQuery(query, variables.value);
const handleClick = () => {
variables.value.id = 'gid://shopify/Collection/274541707431';
refresh();
};
</script> |
@rutgerbakker95 ah damn you are so right. It was a reactive problem, because the variables object was no ref and so the variables of the query didn't get the updated id and so it doesn't update the data. id itselft doesn't have to be a another ref. I have updated the stackblitz: https://stackblitz.com/edit/nuxt-3-zzzb71?file=pages%2Findex.vue Thanks so much for the help |
@chrispreisler Yep I also had the same problem but in the end it makes sense. You're welcome :) |
Environment
Linux
v16.14.2
3.2.2
2.2.3
[email protected]
vite
modules
,apollo
@nuxtjs/[email protected]
-
Describe the bug
Hey guys,
first of all, thank you very much for this great library.
When I call the refresh function I see a network call in the dev tools, but the data variable ist not being updated. I also tried to use the watch property from asyncData from nuxt3, but this is not working at all and doesn't call any network requests.
Expected behaviour
I would expect, that when I call the refresh function and provide a new ID, that the data ist updated.
Reproduction
You can find a repproduction link here:
https://stackblitz.com/edit/nuxt-3-zzzb71?file=pages/index.vue
There is also a second page, which shows, that it is working with asyncData and a normal fetch function.
Additional context
Thank you very much for looking into the bug.
Best regards
Chris
Logs
No response
The text was updated successfully, but these errors were encountered: