-
-
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
Include optional TError on DataTag so that getQueryState can infer the error type correctly #8361
Conversation
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 10420a4. 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 2 targetsSent with 💌 from NxCloud. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #8361 +/- ##
===========================================
+ Coverage 46.12% 62.90% +16.78%
===========================================
Files 200 136 -64
Lines 7504 4799 -2705
Branches 1712 1345 -367
===========================================
- Hits 3461 3019 -442
+ Misses 3668 1540 -2128
+ Partials 375 240 -135 |
The tRPC PR now has this implemented and looks good, though you'd need to locally link to this PR to make it work: trpc/trpc#6265
|
Current
getQueryState
can infer the data type correctly via the DataTag type.DataTag does not include any type information for the Error type however.
At tRPC we are working on a package to generate query keys, query filters, and query options automatically based on your tRPC type. This will provide the ability to call
getQueryState
but currently no ability to create inference for the error because of the current limitations of DataTag. trpc/trpc#6265 - similar to #8332 it seems right to improve this upstream so everybody can benefit, though this time it also can't be easily improved downstreamThis PR updates DataTag with a 3rd optional type parameter for TError, defaulting to
unknown
to avoid breaking changes for RQ users. getQueryState now infers the error type from this information or automatically falls back on its own TError value if the DataTag is unsetAlternative implementation could be to do an
ErrorTag
alongsideDataTag
but this one seems more in-line with how type params are set up elsewhere in RQ