question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

feat: prefix infinite queries differently to "normal" queries?

See original GitHub issue

Describe the feature you’d like to request

Currently, the cache gets a bit messed up if you use an endpoint the with .useInfiniteQuery() in one part of the app and .useQuery() in another.

Describe the solution you’d like to see

Currently, we store cache keys as [pathArray, input]-tuple

Maybe, we should store it as ['query' | 'infinite', pathArray, input]-tuple?

Or a [pathArray, 'query' | 'infinite', input]-tuple?

Desribe alternate solutions

Not doing it

Additional information

No response

👨‍👧‍👦 Contributing

  • 🙋‍♂️ Yes, I’d be down to file a PR implementing this feature!

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:15 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
TkDodocommented, Nov 13, 2022

Given key: [ [‘post’, ‘byId’], { type: “query”, input: 1 } ]

invalidateQueries([ [‘post’, ‘byId’], { input: 1 } ]) would invalidate that key even if we don’t define the type?

That’s exactly right. Objects have no order so the partial matching will work as you want to here. I’m going into details why the object is pretty good for query keys: https://tkdodo.eu/blog/leveraging-the-query-function-context

1reaction
TkDodocommented, Nov 12, 2022
// Query key to invalidate all queries and infinite Queries with an input of `userId:10`
[ ["post"], { input: { userId:10 } } ]  // ✅❓// I think would work!

// Query key to invalidate only queries with an input of userId:10
[ ["post"], { type: "query", input: { userId:10 } } ] // ✅❓

yes, those two would work.

I also thought about having one object, but I thought that we then wouldn’t be able to allow having type provided from the params. Having the input be a separate entry in the object would solve that nicely I think 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Infinite Queries | TanStack Query Docs
When an infinite query becomes stale and needs to be refetched, each group is fetched sequentially , starting from the first one. This...
Read more >
How to optimistically update an infinite or paginated query?
It seems for now on mutation success I always have to call queryCache.invalidateQueries() which is very wasteful. Some code example would be great....
Read more >
React Query Tutorial - 20 - Infinite Queries - YouTube
Courses - https://learn.codevolution.dev/ Support UPI - https://support.codevolution.dev/ Support PayPal ...
Read more >
NetSuite Applications Suite - Using Qualified Queries
Cloud · Cloud Applications · NetSuite. NetSuite Applications Suite. Table of Contents; Search. Contents. Expand AllCollapse All.
Read more >
PRACTICAL GREMLIN: An Apache TinkerPop Tutorial
This book introduces the Apache TinkerPop 3 Gremlin graph query and traversal language via real examples featuring real-world graph data. That ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found