quasarframework / app-extension-apollo

The official Quasar App-Extension for Apollo and GraphQL - Currently Beta!
https://quasar.dev
109 stars 19 forks source link

First call affter Page reload anytime gives me an undefined #132

Closed Subsonic00 closed 8 months ago

Subsonic00 commented 1 year ago

Hello, after I solved the Problem to run GraphQL with Quasar, now the next problem jumping in my face. Anytime if I reload the page the first result of the graphql request is undefined and with 2nd request i get the result. This is weird and I dont find any solution for this. I hope u can help me with this.

How I send the request(initToken isn't empty) image

apollo.js image

I hope u can help me with this weird problem

Greetings Subsonic

smolinari commented 1 year ago

I'm assuming this is to see if a user is logged in or not via a token. This logic shouldn't be in a component. It should be in your boot system, where you set up your http link. See this for reference:

https://www.apollographql.com/docs/react/networking/authentication/

juferdinand commented 1 year ago

Hello I'm one of the two developers which found the problem. This is not the Problem which we have, I know that Headers or something else should be set in the boot file. But if I send any GraphQL Request via useQuery I get first time undefined. If u read result.value, but the result is there if I print the completly result into the console. Value is undefined, but _rawvalue is as example is not undefined and loading is anytime true in first call to Api. U know this Issue or should I share some more information?

smolinari commented 1 year ago

@juferdinand - I don't know about any such issue. And especially because I personally use the composition API. You might try using a hook to call the first time to prime the data. Also, @vue/apollo-composable was meant to be used with the composition API and using setup(). You seem to be using the options API. Are you using Vue 3 or Vue 2 (Quasar v2 or v1)? And if Vue 2/ Quasar v1), you should be using @vue/apollo-options as the docs say. https://v4.apollo.vuejs.org/guide-option/setup.html (assuming you are using vue-apollo 4).

Scott

juferdinand commented 1 year ago

We using Quasar V2 so Vue3, so it looks like we did something false. Have u maybe an example how we should do it? We found not much about this, we was happy that it was running 😂

smolinari commented 1 year ago

The vue-apollo docs show how it should be done. I gave you a link above.

Scott

juferdinand commented 1 year ago

there is apollo-options in use, u mean we have to use apollo-composable or should we switch completly to options?

smolinari commented 1 year ago

You should use @vue/apollo-options. @vue/apollo-composable is for the composition API. Or, change to the composition API.

Scott

smolinari commented 8 months ago

Closing. If you feel there is still an issue, please re-open.

Scott