feat(react-query): allow optional cursor in useInfiniteQuery#4374
Merged
feat(react-query): allow optional cursor in useInfiniteQuery#4374
react-query): allow optional cursor in useInfiniteQuery#4374Conversation
|
The latest updates on your projects. Learn more about Vercel for Git βοΈ
|
|
@lithdew is attempting to deploy a commit to the trpc Team on Vercel. A member of the Team first needs to authorize it. |
useInfiniteQuery
useInfiniteQueryreact-query): relax input type conditions for exposing useInfiniteQuery
react-query): relax input type conditions for exposing useInfiniteQueryreact-query): relax input type conditions for exposing useInfiniteQuery
f973b05 to
81ed5ae
Compare
Contributor
Author
Wrote some type-checking tests to ensure that |
ec2d42f to
bc07ca2
Compare
β¦teQuery
Suppose we define a router procedure's input with Zod as `z.object({
cursor: z.string().optional() }).default({})`. The inferred input type,
which may be checked using `inferRouterInputs<Router>["procedure"]`,
erroneously is the type union `void | {cursor?: string} | undefined`.
The error is caused by `inferProcedureInput` union-ing the input
type with void should the input potentially be undefined.
useInfiniteQuery at the moment is only exposed for procedures whose
inputs solely extend `{cursor?: any}`. Procedures whose inputs are
potentially undefined, that guarantee** after parsing to set defaults to
the `cursor` field however should also expose useInfiniteQuery.
This PR relaxes the input types of useInfiniteQuery to allow inputs that
are potentially undefined by exposing useInfiniteQuery for procedures
whose inputs extends the type `{cursor?: any} | void`.
KATT
reviewed
May 25, 2023
react-query): relax input type conditions for exposing useInfiniteQueryreact-query): allow optional cursor in useInfiniteQuery
KATT
previously approved these changes
May 25, 2023
KATT
approved these changes
May 25, 2023
mastondzn
referenced
this pull request
in mastondzn/synopsisbot
May 28, 2023
[](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [@trpc/client](https://trpc.io) ([source](https://togithub.com/trpc/trpc)) | [`10.27.1` -> `10.28.0`](https://renovatebot.com/diffs/npm/@trpc%2fclient/10.27.1/10.28.0) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | | [@trpc/react-query](https://trpc.io) ([source](https://togithub.com/trpc/trpc)) | [`10.27.1` -> `10.28.0`](https://renovatebot.com/diffs/npm/@trpc%2freact-query/10.27.1/10.28.0) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | | [@trpc/server](https://trpc.io) ([source](https://togithub.com/trpc/trpc)) | [`10.27.1` -> `10.28.0`](https://renovatebot.com/diffs/npm/@trpc%2fserver/10.27.1/10.28.0) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>trpc/trpc</summary> ### [`v10.28.0`](https://togithub.com/trpc/trpc/releases/tag/v10.28.0) [Compare Source](https://togithub.com/trpc/trpc/compare/v10.27.3...v10.28.0) #### What's Changed - feat(`client`): allow closing active subscriptions by [@​Dealerpriest](https://togithub.com/Dealerpriest) in [https://github.com/trpc/trpc/pull/4136](https://togithub.com/trpc/trpc/pull/4136) - feat(`client`): add ability to call `TRPCProxyClient`-methods with `.apply()` by [@​atoy40](https://togithub.com/atoy40) in [https://github.com/trpc/trpc/pull/3973](https://togithub.com/trpc/trpc/pull/3973) - feat(`react-query`): allow optional cursor in `useInfiniteQuery` by [@​lithdew](https://togithub.com/lithdew) in [https://github.com/trpc/trpc/pull/4374](https://togithub.com/trpc/trpc/pull/4374) - fix(`*`): exclude `*.test.*`-files in build outputs by [@​KATT](https://togithub.com/KATT) in [https://github.com/trpc/trpc/pull/4417](https://togithub.com/trpc/trpc/pull/4417) #### New Contributors - [@​atoy40](https://togithub.com/atoy40) made their first contribution in [https://github.com/trpc/trpc/pull/3973](https://togithub.com/trpc/trpc/pull/3973) - [@​miguelvelasquezdev](https://togithub.com/miguelvelasquezdev) made their first contribution in [https://github.com/trpc/trpc/pull/4341](https://togithub.com/trpc/trpc/pull/4341) - [@​lithdew](https://togithub.com/lithdew) made their first contribution in [https://github.com/trpc/trpc/pull/4374](https://togithub.com/trpc/trpc/pull/4374) **Full Changelog**: trpc/trpc@v10.27.3...v10.28.0 ### [`v10.27.3`](https://togithub.com/trpc/trpc/releases/tag/v10.27.3) [Compare Source](https://togithub.com/trpc/trpc/compare/v10.27.2...v10.27.3) #### What's Changed - fix(`react-query`): fix `useInfiniteQuery` `placeholderData` types by [@​SSHari](https://togithub.com/SSHari) in [https://github.com/trpc/trpc/pull/4402](https://togithub.com/trpc/trpc/pull/4402) #### New Contributors - [@​SSHari](https://togithub.com/SSHari) made their first contribution in [https://github.com/trpc/trpc/pull/4402](https://togithub.com/trpc/trpc/pull/4402) **Full Changelog**: trpc/trpc@v10.27.2...v10.27.3 ### [`v10.27.2`](https://togithub.com/trpc/trpc/releases/tag/v10.27.2) [Compare Source](https://togithub.com/trpc/trpc/compare/v10.27.1...v10.27.2) #### What's Changed - fix(`next)`: remove conditional hook in `withTRPC()` by [@​KATT](https://togithub.com/KATT) in [https://github.com/trpc/trpc/pull/4410](https://togithub.com/trpc/trpc/pull/4410) **Full Changelog**: trpc/trpc@v10.27.1...v10.27.2 </details> --- ### Configuration π **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). π¦ **Automerge**: Disabled by config. Please merge this manually once you are satisfied. β» **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. π **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/synopsisgg/bot). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS4xMDIuNCIsInVwZGF0ZWRJblZlciI6IjM1LjEwMi40IiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
π― Changes
Suppose we define a router procedure's input with Zod as
z.object({ cursor: z.string().optional() }).default({}). The inferred input type, which may be checked usinginferRouterInputs<Router>["procedure"], erroneously is the type unionvoid | {cursor?: string} | undefined.The error is caused by
inferProcedureInputunion-ing the input type with void should the input potentially be undefined.useInfiniteQuery at the moment is only exposed for procedures whose inputs solely extend
{cursor?: any}. Procedures whose inputs are potentially undefined, that guarantee** after parsing to set defaults to thecursorfield however should also expose useInfiniteQuery.This PR relaxes the input types of useInfiniteQuery to allow inputs that are potentially undefined by exposing useInfiniteQuery for procedures whose inputs extends the type
{cursor?: any} | void.β Checklist