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 21 commits into
base: main
Choose a base branch
from
Open

TRPC 11 #41

wants to merge 21 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. <[email protected]>
@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?

@vafanassieff
Copy link
Author

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

Hey I currently don't have much time to write the docs, if someone want to chat with me and @louneskmt to have some guidance and help us!

@jasonsilvers-dispel
Copy link

jasonsilvers-dispel commented Sep 11, 2024

@vafanassieff @louneskmt I would be happy to help with the documentation. The github action to publish might also need to be updated as well. I ran into a few issues with it when creating a temporary fork.

@vafanassieff
Copy link
Author

Hey, I removed the websocket part since it added too much overhead for almost nothing.
We can add this later, I think HTTP link is enough for a first release.
The doc is updated, it's pretty straightforward, use msw-trpc like a regular tRPC client.

@blackmax1886

This comment was marked as resolved.

@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.

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