feat: add skipToken support and queryOptions override to TanStack Query useQuery hooks#3528
feat: add skipToken support and queryOptions override to TanStack Query useQuery hooks#3528nmokkenstorm wants to merge 1 commit intohey-api:mainfrom
Conversation
|
|
|
@nmokkenstorm is attempting to deploy a commit to the Hey API Team on Vercel. A member of the Team first needs to authorize it. |
🦋 Changeset detectedLatest commit: 2ffe100 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
6d07fd5 to
cf8e859
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3528 +/- ##
==========================================
- Coverage 39.37% 39.20% -0.18%
==========================================
Files 506 513 +7
Lines 18572 18804 +232
Branches 5511 5573 +62
==========================================
+ Hits 7313 7372 +59
- Misses 9088 9239 +151
- Partials 2171 2193 +22
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
@hey-api/codegen-core
@hey-api/json-schema-ref-parser
@hey-api/nuxt
@hey-api/openapi-ts
@hey-api/shared
@hey-api/types
@hey-api/vite-plugin
commit: |
|
@nmokkenstorm Why is it an optional configuration flag? Why not add it for everyone? |
|
@nandorojo will like this |
|
@nmokkenstorm I updated your description with linked issue |
habit to make it opt-in tbh. I think the skipToken is a breaking change too on type level and it also slightly increases the generated bundle size but I will check. |
|
@nmokkenstorm I didn't look at the code yet, stopped after seeing the configuration haha. If it's going to be breaking either way, I'd much rather deprecate the old approach because we wouldn't want new users to start with the flag disabled, realize one day they need to enable it, and face a lot of breaking changes. We can talk through it when you feel the pull request is more ready. I'm pretty sure there was another thread where we talked about skip tokens but can't find it, I'd like to ideally avoid another breaking change when that thread gets addressed |
I'll double check, I think it's definately doable to have it be backwards compatible without a breaking change. The useQuery/Mutation stuff was opt in so I stuck to the pattern but I think this can be done without losing ergonomics. I'll update the pr description and ping you if it's reviewable, I needed a remote public ref to do some internal testing with first anyways. Thanks for the feedback! |
7df42fb to
3007b3c
Compare
|
@nmokkenstorm Can you clarify what do you mean by "add useQuery hooks" in the title? React/Preact Query already support generating useQuery hooks so I'm confused what it's referencing |
its about having the generated useQuery hooks exist per entity, with queryoptions and skiptoken enabled. the reason it's named like that is because the original code/branch orginates from a fork that pre-dates the support we had in our project. still tinkering on this, nothing to see/review here yet! |
|
Just making sure we're aligned on the scope! I shall retreat once more |
d6ebc7c to
b1fc4b9
Compare
…gins - Generate useQuery hooks by default for all TanStack query plugins - Add skipToken support via inline narrowing instead of helper functions - Fix 4028 type errors in generated code by replacing resolveQueryFn/resolveOptions helpers with inline ternary narrowing and proper type assertions - Use `useQuery: false` to opt out of generating useQuery hooks
b1fc4b9 to
2ffe100
Compare
Summary
Adds
skipTokensupport andqueryOptionsoverride to generateduseQueryhooks for TanStack Query plugins (React, Preact).useQueryhooks are now generated by default (no config flag needed)skipTokenis always supported — pass it instead of options to conditionally disable a queryqueryOptionsoverride parameter allows customizing the underlying query optionsuseQuery: falseto opt out of generatinguseQueryhooksCloses #2766
Breaking changes
None. This is additive and backwards-compatible:
queryOptionsandqueryKeyscontinue to work as beforeuseQueryhooks are new generated output (enabled by default, opt-out withuseQuery: false)skipTokensupport is wired intoqueryOptionsautomatically