-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add types for QueryFilters which flow down to Query<> and QueryKey/DataTag types #8332
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks lovely. Can you maybe add a type test please (in a .test-d.ts
file) so that we are future proof and can see per example what this achieves? Thank you 🙏
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 03ab3e3. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 1 targetSent with 💌 from NxCloud. |
Done Good I'm doing this. I think getQueryState could be next on my agenda, DataTag has no way to communicate an error type but getQueryState can get you back the error. I've left a test with a comment for now to document the current behaviour |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #8332 +/- ##
===========================================
+ Coverage 45.97% 62.90% +16.93%
===========================================
Files 200 136 -64
Lines 7509 4799 -2710
Branches 1718 1345 -373
===========================================
- Hits 3452 3019 -433
+ Misses 3680 1540 -2140
+ Partials 377 240 -137 |
At tRPC we're working on a new react query client which only provides factories to React Query interfaces. Many of these factories already support full type-safety, for instance a QueryKey can have a DataTag which hints at the query data type.
QueryKey (with DataTag) and Query<> both support typesafety, but QueryFilters hides this and only exposes the defaults. This means our queryFilter factory method cannot be type-safe without replicating the tanstack query types into the tRPC codebase.
I propose upstreaming this type-safety so that everyone can benefit and tRPC can utilise it natively
Here is the work I'm doing on the tRPC side: trpc/trpc#6265