Giter Club home page Giter Club logo

Comments (5)

phryneas avatar phryneas commented on June 24, 2024 2

I'm sorry, but it is literally in the word: "re(execute)fetch".
The whole purpose of this function is to get new data from the server and to bypass fetchPolicy.

There is no need for a function to get new data from the cache, because the cache will always update your component automatically - you always will have the newest data from the cache in your hook.

Again, the purpose of this function is not to change variables. You can choose to refetch with new variables, but that's a bonus on top of that base functionality.

You can explain your use case a bit more and we can try to find a solution for that, but right now this looks like an XY problem: you are choosing tool Y to solve problem X and ask questions about how to change the behaviour of tool Y, while it was never intended to solve problem X in the first place.

Let's take a step back and look at your problem X instead, okay? :)

from apollo-client.

phryneas avatar phryneas commented on June 24, 2024

That's intentional. refetch here means "get new data from the server". It's an intentional command.

Using the useQuery hook itself doesn't cause a cache unless it needs to (or you set an according fetchPolicy) - if you were to mount the hooks in three components, you wouldn't want to see three network requests.

If you just want to change variables, there is no need to call refetch - just rerender the useQuery hook with the new variables.

from apollo-client.

ps173 avatar ps173 commented on June 24, 2024

If you just want to change variables, there is no need to call refetch - just rerender the useQuery hook with the new variables.

Yes that is understood. But in cases such as debounce a refetch needs to be triggered. Obviously this is a very specific case.

I also feel like that the idea of refetch to "get new data from the server" should also be based on fetchPolicy just like useQuery. I mean if I select a certain caching / fetchPolicy that should be valid for my refetch requests as well.

from apollo-client.

ps173 avatar ps173 commented on June 24, 2024

Fair enough. It does seem like an XY problem and I agree on that. Just wanted to make sure that whether it was intended for refetch to bypass fetchPolicy. As for my problem it can be handled with useLazyQuery. Thanks for the time!

from apollo-client.

github-actions avatar github-actions commented on June 24, 2024

Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo Client usage and allow us to serve you better.

from apollo-client.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.