Comments (5)
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.
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.
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.
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.
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)
- BatchHTTPLink is not monitoring friendly HOT 6
- Support extensions in useSubscription HOT 1
- React functionality 'useContext' is not available in this environment [Nextjs app] HOT 4
- Subscription doesn't deduplicate HOT 3
- Types `cache.modify` and `writeFragment` lead to TypeScript errors for documented Apollo examples when specifying generic parameter HOT 1
- SOLVED : TypeError: Cannot return null for non-nullable field Subscription: Next.js frontend + FastApi backend HOT 2
- NextJS with "useSuspenseQuery" not passing headers to request HOT 3
- Using @defer in a query on a field which was previously queried creates a cache hit, when it should be a miss HOT 1
- Custom ApolloLink using `next.subscribe` is making duplicated requests HOT 8
- Adding graphql-tag-swc-plugin to performance docs for apollo client HOT 4
- (Batch)HttpLink Uncaught (in promise)DOMException: signal is aborted without reason HOT 6
- Typeguard for useQuery fails when the queryOptions passed using spread operator HOT 4
- Can you use `useFragment` with a type that doesn't have an id? HOT 3
- PossibleTypes not working as intended HOT 4
- Infinite network requests with non-normalized objects HOT 3
- fetchMore not hitting onError and causing an infinite loop of queries HOT 3
- [Docs] refetchQueries can fetch non active queries HOT 2
- Typescript compilation error in Node context HOT 1
- I try to integrate GraphQL PHP in backend with Apollo client and React in front end) but I get an undefined post response HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apollo-client.