Skip to content
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

Can't access result.value after successful query on first load #606

Open
mathieuCatapulpe opened this issue Mar 26, 2024 · 2 comments
Open
Labels

Comments

@mathieuCatapulpe
Copy link

Environment

Describe the bug

After a successful query using either useAsyncQuery or useQuery I can console.log my result, but when trying to access result.value it returns null as shown in the example bellow

import fetchProgramme from "~/config/graphql/preview/programme.graphql"
    const { result } = useQuery(
        fetchProgramme ,
        {id: previewId},
    );

    console.log('result : ' , result)
    console.log('result.value : ' , result.value)

image

Expected behaviour

Being able to access result.value

Reproduction

No response

Additional context

Also tried :

  • trigger the graphql query onMounted()
  • use useQuery and useAsyncQuery
  • running code on prod and local server using nuxt dev
  • adding prefetch : false parameter to the query

Logs

No response

@atenazr
Copy link

atenazr commented May 10, 2024

i have this issue too!

@toknT
Copy link

toknT commented Aug 20, 2024

😭 same issue any update? Because useQuery fire onResult twice after refreshed page. You can edit like this

const pageSize = 11;
const page = ref(1)
const tableData = ref<PaginatedSystemSetting>(emptyPaginatedSystemSetting)
const { data, status } = await useLazyAsyncData(async () => {
  await handleCurrentPageChange(1);
})
const handleCurrentPageChange = async (val: number) => {
  page.value = val;
  useQuery<{ data: PaginatedSystemSetting }>(findAllQuery, {
    input: { page: page.value, perPage: pageSize },
  }, {
    fetchPolicy: 'network-only',
    prefetch: false,
  }).onResult((value) => {
    if (value.loading == false) {
      tableData.value = value.data.data;
    }
  });
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants