Skip to content
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

feat(react-query): added initialData overloads for useQuery #3500

Merged

Conversation

JoshuaKGoldberg
Copy link
Collaborator

Closes #2996

🎯 Changes

adds function overloads to two forms of useQuery:

  • trpc.useQuery: with an inline function overload
  • ctx.proxy.post.byId.useQuery & the like: with an interface containing multiple call signatures

Both overloads indicate that if opts.initialData is defined, the result should have a defined data.

βœ… Checklist

  • I have followed the steps listed in the Contributing guide.
  • If necessary, I have added documentation related to the changes made.
  • I have added or updated the tests related to the changes made.

@vercel
Copy link

vercel bot commented Dec 27, 2022

@JoshuaKGoldberg is attempting to deploy a commit to the trpc Team on Vercel.

A member of the Team first needs to authorize it.

@vercel
Copy link

vercel bot commented Dec 27, 2022

The latest updates on your projects. Learn more about Vercel for Git β†—οΈŽ

Name Status Preview Comments Updated
todomvc πŸ”„ Building (Inspect) Dec 27, 2022 at 8:44PM (UTC)
www βœ… Ready (Inspect) Visit Preview πŸ’¬ Add your feedback Dec 27, 2022 at 8:44PM (UTC)

Copy link
Member

@KATT KATT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it, but let's not add this in the v9 (any /interop/* or /deprecated/* - see #3496, we've already deleted a bunch of these files in #3494)

KATT
KATT previously approved these changes Dec 27, 2022
Copy link
Member

@KATT KATT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd love @juliusmarminge to look at this cause he raised the original issue πŸ‘€

Co-authored-by: Alex / KATT <alexander@n1s.se>
KATT
KATT previously approved these changes Dec 27, 2022
@KATT
Copy link
Member

KATT commented Dec 27, 2022

cc @juliusmarminge smash the merge button if you like it

@juliusmarminge
Copy link
Member

cc @juliusmarminge smash the merge button if you like it

Will look in a bit

Copy link
Member

@juliusmarminge juliusmarminge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job!

I added back the original regression tests that verifies that "all ways" return the same as tanstack (destructuring, initialData, fallbackData).

@juliusmarminge juliusmarminge merged commit 6b84db5 into trpc:main Dec 27, 2022
@KATT KATT changed the title feat: added initialData overloads for useQuery feat(react-query): added initialData overloads for useQuery Dec 27, 2022
@JoshuaKGoldberg JoshuaKGoldberg deleted the use-query-initialData-overload branch December 27, 2022 20:53
kodiakhq bot added a commit to weareinreach/InReach that referenced this pull request Jan 6, 2023
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](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.7.0` -> `10.8.1`](https://renovatebot.com/diffs/npm/@trpc%2fclient/10.7.0/10.8.1) | [![age](https://badges.renovateapi.com/packages/npm/@trpc%2fclient/10.8.1/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/npm/@trpc%2fclient/10.8.1/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/npm/@trpc%2fclient/10.8.1/compatibility-slim/10.7.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/npm/@trpc%2fclient/10.8.1/confidence-slim/10.7.0)](https://docs.renovatebot.com/merge-confidence/) |
| [@trpc/next](https://trpc.io) ([source](https://togithub.com/trpc/trpc)) | [`10.7.0` -> `10.8.1`](https://renovatebot.com/diffs/npm/@trpc%2fnext/10.7.0/10.8.1) | [![age](https://badges.renovateapi.com/packages/npm/@trpc%2fnext/10.8.1/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/npm/@trpc%2fnext/10.8.1/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/npm/@trpc%2fnext/10.8.1/compatibility-slim/10.7.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/npm/@trpc%2fnext/10.8.1/confidence-slim/10.7.0)](https://docs.renovatebot.com/merge-confidence/) |
| [@trpc/react-query](https://trpc.io) ([source](https://togithub.com/trpc/trpc)) | [`10.7.0` -> `10.8.1`](https://renovatebot.com/diffs/npm/@trpc%2freact-query/10.7.0/10.8.1) | [![age](https://badges.renovateapi.com/packages/npm/@trpc%2freact-query/10.8.1/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/npm/@trpc%2freact-query/10.8.1/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/npm/@trpc%2freact-query/10.8.1/compatibility-slim/10.7.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/npm/@trpc%2freact-query/10.8.1/confidence-slim/10.7.0)](https://docs.renovatebot.com/merge-confidence/) |
| [@trpc/server](https://trpc.io) ([source](https://togithub.com/trpc/trpc)) | [`10.7.0` -> `10.8.1`](https://renovatebot.com/diffs/npm/@trpc%2fserver/10.7.0/10.8.1) | [![age](https://badges.renovateapi.com/packages/npm/@trpc%2fserver/10.8.1/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/npm/@trpc%2fserver/10.8.1/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/npm/@trpc%2fserver/10.8.1/compatibility-slim/10.7.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/npm/@trpc%2fserver/10.8.1/confidence-slim/10.7.0)](https://docs.renovatebot.com/merge-confidence/) |
| [libphonenumber-js](https://gitlab.com/catamphetamine/libphonenumber-js) | [`1.10.15` -> `1.10.16`](https://renovatebot.com/diffs/npm/libphonenumber-js/1.10.15/1.10.16) | [![age](https://badges.renovateapi.com/packages/npm/libphonenumber-js/1.10.16/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/npm/libphonenumber-js/1.10.16/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/npm/libphonenumber-js/1.10.16/compatibility-slim/1.10.15)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/npm/libphonenumber-js/1.10.16/confidence-slim/1.10.15)](https://docs.renovatebot.com/merge-confidence/) |
| [quicktype-core](https://togithub.com/quicktype/quicktype) | [`7.0.2` -> `7.0.3`](https://renovatebot.com/diffs/npm/quicktype-core/7.0.2/7.0.3) | [![age](https://badges.renovateapi.com/packages/npm/quicktype-core/7.0.3/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/npm/quicktype-core/7.0.3/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/npm/quicktype-core/7.0.3/compatibility-slim/7.0.2)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/npm/quicktype-core/7.0.3/confidence-slim/7.0.2)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>trpc/trpc</summary>

### [`v10.8.1`](https://togithub.com/trpc/trpc/releases/tag/v10.8.1)

[Compare Source](https://togithub.com/trpc/trpc/compare/v10.8.0...v10.8.1)

##### What's Changed

-   chore: bump `peerDependencies` between `@trpc/*`-packages by [@&#8203;KATT](https://togithub.com/KATT)

**Full Changelog**: trpc/trpc@v10.8.0...v10.8.1

### [`v10.8.0`](https://togithub.com/trpc/trpc/releases/tag/v10.8.0)

[Compare Source](https://togithub.com/trpc/trpc/compare/v10.7.0...v10.8.0)

##### What's Changed

-   feat(client): add base client for integrations by [@&#8203;bautistaaa](https://togithub.com/bautistaaa) & [@&#8203;KATT](https://togithub.com/KATT) in [trpc/trpc#3389, [trpc/trpc#3479
-   chore: deprecate usage of `createHooksInternal` by [@&#8203;KATT](https://togithub.com/KATT) in [trpc/trpc#3480
-   chore: pruned some never-used code by [@&#8203;JoshuaKGoldberg](https://togithub.com/JoshuaKGoldberg) in [trpc/trpc#3487
-   fix(react-query): fix import from dist folder by [@&#8203;gspetrou](https://togithub.com/gspetrou) in [trpc/trpc#3499
-   feat: accept function param in `initTRPC.context` by [@&#8203;juliusmarminge](https://togithub.com/juliusmarminge) in [trpc/trpc#3495
-   feat: handle reserved properties key collisions by [@&#8203;sachinraja](https://togithub.com/sachinraja) in [trpc/trpc#3466
-   feat(react-query): added `initialData` overloads for `useQuery` by [@&#8203;JoshuaKGoldberg](https://togithub.com/JoshuaKGoldberg) in [trpc/trpc#3500
-   feat: add `resHeaders` to fetch-adapter's `createContext` by [@&#8203;sachinraja](https://togithub.com/sachinraja) in [trpc/trpc#3532
-   Add cloudflare-page-plugin-trpc into the Awesome tRPC collection list by [@&#8203;toyamarinyon](https://togithub.com/toyamarinyon) in [trpc/trpc#3531
-   fix(client): use constant of websocket impl by [@&#8203;nohum](https://togithub.com/nohum) in [trpc/trpc#3542
-   chore(client): rm redundant `getLinks()` from client factory by [@&#8203;KATT](https://togithub.com/KATT) in [trpc/trpc#3541

##### New Contributors

-   [@&#8203;JoshuaKGoldberg](https://togithub.com/JoshuaKGoldberg) made their first contribution in [trpc/trpc#3482
-   [@&#8203;mishankov](https://togithub.com/mishankov) made their first contribution in [trpc/trpc#3492
-   [@&#8203;guushamann](https://togithub.com/guushamann) made their first contribution in [trpc/trpc#3493
-   [@&#8203;gspetrou](https://togithub.com/gspetrou) made their first contribution in [trpc/trpc#3499
-   [@&#8203;zihan-ch](https://togithub.com/zihan-ch) made their first contribution in [trpc/trpc#3511
-   [@&#8203;roj1512](https://togithub.com/roj1512) made their first contribution in [trpc/trpc#3515
-   [@&#8203;nfabredev](https://togithub.com/nfabredev) made their first contribution in [trpc/trpc#3457
-   [@&#8203;hrstmr](https://togithub.com/hrstmr) made their first contribution in [trpc/trpc#3519

**Full Changelog**: trpc/trpc@v10.7.0...v10.8.0

</details>

<details>
<summary>catamphetamine/libphonenumber-js</summary>

### [`v1.10.16`](https://gitlab.com/catamphetamine/libphonenumber-js/compare/v1.10.15...v1.10.16)

[Compare Source](https://gitlab.com/catamphetamine/libphonenumber-js/compare/v1.10.15...v1.10.16)

</details>

<details>
<summary>quicktype/quicktype</summary>

### [`v7.0.3`](https://togithub.com/quicktype/quicktype/compare/5dbf11c85037e3f6a1ae842cf124c14546827a43...90a6bc16e854c337955ea453fe36a6d7fcd17c99)

[Compare Source](https://togithub.com/quicktype/quicktype/compare/5dbf11c85037e3f6a1ae842cf124c14546827a43...90a6bc16e854c337955ea453fe36a6d7fcd17c99)

</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 is behind base branch, or you tick the rebase/retry checkbox.

πŸ‘» **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://togithub.com/renovatebot/renovate/discussions) if that's undesired.

---

 - [ ] 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/weareinreach/InReach).



PR-URL: #141
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: add overloads to useQuery
3 participants