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

TRPC 11 #41

Open
wants to merge 34 commits into
base: main
Choose a base branch
from
Open

TRPC 11 #41

wants to merge 34 commits into from

Conversation

vafanassieff
Copy link

@vafanassieff vafanassieff commented May 7, 2024

Hey there, thanks for this package.
We took few liberties to improve the DX / testing

Closes #37

Best

🎯 Changes

  • changed repo structure to a monorepo with pnpm
  • use trpc@next since it's a release candidate
  • new handler generation (from @louneskmt)
  • use links like a normal TRPC client (from @louneskmt)
  • use vitest as test runner
  • add tests for node and react

✅ Checklist

  • If necessary, I have added documentation related to the changes made.
  • I have added or updated the tests related to the changes made.

@vafanassieff vafanassieff mentioned this pull request May 7, 2024
2 tasks
@vafanassieff vafanassieff marked this pull request as ready for review May 27, 2024 09:49
"@trpc/server": "11.0.0-rc.403",
"@types/react": "18.3.3",
"@types/react-dom": "18.3.0",
"jsdom": "24.1.0",

Choose a reason for hiding this comment

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

happy-dom is faster than jsdom, albeit it is lacking some of the web APIs, one should consider trying to see if it's adequate for this package

https://github.com/capricorn86/happy-dom

Copy link
Author

@vafanassieff vafanassieff Jun 17, 2024

Choose a reason for hiding this comment

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

I chose jsdom because they support Websocket in the browser without needing a polyfill. Tests packages are only here for example, you can use happy-dom too.

Copy link

@l0gicgate l0gicgate left a comment

Choose a reason for hiding this comment

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

@vafanassieff I've reviewed the entire PR, it looks great. I am not a core contributor though but I am looking forward to seeing this merged as we are using tRPC v11 and would like to use this package for testing.

Co-authored-by: Pierre B. <pierre@lgse.com>
@vafanassieff
Copy link
Author

@vafanassieff I've reviewed the entire PR, it looks great. I am not a core contributor though but I am looking forward to seeing this merged as we are using tRPC v11 and would like to use this package for testing.

Thanks !
The PR is just missing an updated documentation, we changed the API and added the Websocket API.
And msw websocket is still in beta.

@vafanassieff vafanassieff mentioned this pull request Jun 17, 2024
@maloguertin
Copy link
Owner

@vafanassieff could you add the documentation and then we could go forward with this PR? Thanks!

@randseay
Copy link

randseay commented Sep 5, 2024

Our team is excited to see support for tRPC v11, thank you! Is there a chance this might merge soon?

@rinarakaki
Copy link

rinarakaki commented Oct 29, 2024

@vafanassieff could you please resolve the conflicts?


I think we need to pnpm install before pnpm prettier in the workflow. And there seems still some code to be fixed.

Run pnpm prettier --check .
Checking formatting...
[warn] packages/msw-trpc/src/handler.ts
[warn] packages/msw-trpc/src/links.ts
[warn] pnpm-lock.yaml
[warn] Code style issues found in 3 files. Run Prettier with --write to fix.
Error: Process completed with exit code 1.

I made a PR to fix this vafanassieff#2. Please squash merge it.

@rinarakaki
Copy link

@maloguertin could you please take a look at the doc update?

## Config

`createTRPCMsw` accepts a 2nd argument:
You need to pass a `httpLink` to the `createTRPCMsw` function like you would do with the tRPC client.

Choose a reason for hiding this comment

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

This description must come before the **2. build your trpcMsw with createTRPCMsw.** in the ## Usage section above since the config argument of createTRPCMsw is now non-optional.

* Update npm-publish.yml

* Update npm-publish.yml

* Update npm-publish.yml

* Update test.yml

* update

* update

* update
@danilofuchs
Copy link
Contributor

@maloguertin msw has released WebSocket support in version 2.6.0

https://github.com/mswjs/msw/releases/tag/v2.6.0

I love this package and have been using it extensively with @vafanassieff fork

Is there anything else the community is able to provide in this PR to unblock it and start implementing WebSocket, FormData and other goodies?

@vafanassieff
Copy link
Author

@maloguertin msw has released WebSocket support in version 2.6.0

https://github.com/mswjs/msw/releases/tag/v2.6.0

I love this package and have been using it extensively with @vafanassieff fork

Is there anything else the community is able to provide in this PR to unblock it and start implementing WebSocket, FormData and other goodies?

If you look in the previous commit, we added a way to use websocket, but it was kinda cluncky and out of the scope of this PR.

(BTW we moved to SSE instead of websocket for subscriptions, it's much easier)

@Mathieu-R
Copy link

Hi !
I'm currently using it in a project and this fork works just fine (at least for now) with TRPC v11 and MSW v2.

Any plan to merge ? @vafanassieff Did you publish your fork on npm under a prefix ?

@vafanassieff
Copy link
Author

Hi ! I'm currently using it in a project and this fork works just fine (at least for now) with TRPC v11 and MSW v2.

Any plan to merge ? @vafanassieff Did you publish your fork on npm under a prefix ?

I'm using "@vafanassieff/msw-trpc": "0.0.1" meanwhile.

@Alletkla
Copy link

Hello 👋🏽
@vafanassieff
Do you know what is blocking this PR from being merged? - I would really appreciate it as it blocks update to trpc11 for me and my team.
Since websocket support has been removed from this PR,
the only outstanding issue I see is in the documentation, where the explanation for createTRPCMsw/config should be moved up.

The only conflict with main is also in the documentation. I can solve this.
Although unfortunately I probably can't help with in depth programming due to lack of experience.

@vafanassieff
Copy link
Author

@Alletkla

I have yet to find the time to write the doc, if you are willing to do it lfg !

@balloman
Copy link

Just as a heads up, this doesn't seem to support post overrides (it always assumes a get request for a query)

@louneskmt
Copy link

louneskmt commented Mar 12, 2025

@balloman This should do the trick 69115cf.

@danilofuchs
Copy link
Contributor

Hello @maloguertin!

tRPC 11 is stable! https://trpc.io/blog/announcing-trpc-v11

As of now, msw-trpc is not compatible with the stable version of tRPC and users will see issues installing this library.

Is there any chance this PR will be reviewed soon?

@vafanassieff
Copy link
Author

I updated the PR to use tRPC 11.

@Alletkla if you still want to update the config lmk :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for V11