harshit-test-org / javascript-af

https://javascript.af
14 stars 2 forks source link

Graphql request visible in devtools? #88

Closed NickyMeuleman closed 5 years ago

NickyMeuleman commented 5 years ago

Can't seem to see any graphql queries in the devtools network tab. Tested on a couple different browsers. Chrome Firefox Edge

Do see them on other sites that use graphql, like https://iamsaravieira.com/ 2019-02-11_23-41-08

Please tell me I'm being stupid and forgot some supersimple thing ๐Ÿ™

pantharshit00 commented 5 years ago

~I don't think we make a query yet :)~ I was wrong , I was not aware of your changes

pantharshit00 commented 5 years ago

You called the refetch the wrong way

NickyMeuleman commented 5 years ago

Thanks! Glad I made a mistake and it's working as it should. Not at pc with dev-things installed, will check tomorrow.

https://www.apollographql.com/docs/react/essentials/queries.html#refetching

refetch takes variables, but if we donโ€™t pass in new variables, it will use the same ones from our previous query.

Just to confirm my understanding: Because I passed onClick={payload.refetch} it treated that call as a refetch with the same variables. Because there are none (so it's the same), Apollo grabbed the result from the cache and I never saw that graphql request in the console.

In the new code refetch is being called with an empty object (which is different) and apollo does fire the graphql request.