nuxt-modules / apollo

Nuxt.js module to use Vue-Apollo. The Apollo integration for GraphQL.
https://apollo.nuxtjs.org
MIT License
956 stars 198 forks source link

value is null #531

Open bovealexandre opened 1 year ago

bovealexandre commented 1 year ago

Environment


Describe the bug

I have this code

const result = await useAsyncQuery(usersQuery)

const Users = result.data.value?.users

and when i log result I have something in data value but when i log result data value it shows that it is null

Expected behaviour

just give me the result of my query

Reproduction

No response

Additional context

No response

Logs

No response

bovealexandre commented 1 year ago

does anyone else have this error?

ilhammeidi commented 1 year ago

does anyone else have this error?

Yes I am, but when I disabled ssr in nuxt.config, the data loaded when the browser reloaded. I think this library does not support ssr yet.

bovealexandre commented 1 year ago

but I need SSR

gkkirilov commented 11 months ago

It loads on the server but when it hydrates it retries the request and then becomes null @Diizzayy ?

Edit: Doesnt work on initial load but works on hot reload

gerbenvandijk commented 7 months ago

I ran into a similar issue where I had a <client-only> component that was calling useAsyncQuery in its script setup.

Oddly, adding an await nextTick() call fixed the issue.

jumptrnr commented 7 months ago

My queries work fine except for when I have logged in, closed tab and then and navigate directly to a page that has useAsyncQuery in setup. Seems Authentication isn't sent in this case and my backend returns a 401. Bearer token Is stored in Cookie in SSR, and is available when my function is called I can see.

iamandrewluca commented 6 months ago

@jumptrnr, do you have proxyCookies set to false in the configuration?

If it is true. probably this PR will fix the issue https://github.com/nuxt-modules/apollo/pull/618

PS: This library does support SSR; we are using it without any problems with SSR enabled.