jeddeloh / rescript-apollo-client

ReScript bindings for the Apollo Client ecosystem
MIT License
126 stars 18 forks source link

fetchMore executing request multiple times #88

Closed Laegel closed 3 years ago

Laegel commented 3 years ago

Hey there, first I'd like to thank everybody working on this wonderful library! Combined to GraphQL PPX, it's delightful.

I ran into the following issue: fetchMore executes a request multiple times (twice on my project even on simple requests not implying variables or specific stuff and four times on your own example: https://github.com/reasonml-community/rescript-apollo-client/blob/master/EXAMPLES/src/hooksUsage/Query_Typical.res#L35). Have you ever seen that?

Thanks for reading!

jeddeloh commented 3 years ago

I feel like someone might have posted this issue a long time ago on discord at a time when I didn't have time to look into it. I assumed they worked it out, but I guess not. We should look into what's going on.

jeddeloh commented 3 years ago

I only took a quick look, but my intuition is that the issue stems from using a NetworkOnly fetch policy. This will trigger two fetches even in the case of no render after the call (no data changed). Seems like an Apollo issue to me. Maybe someone could confirm the behavior exists in a vanilla Apollo situation?

I think the client in examples is configured with NetworkOnly across the board. Maybe I'll just set that up with defaults for now.

Laegel commented 3 years ago

Thanks for your quick answer. I do have the fetch policy as NetworkOnly too... I'll try something else to verify your theory!

jeddeloh commented 3 years ago

Gonna close this for now. Please reopen if you can confirm this isn't the JS behavior. Thanks!