Skip to content

Conversation

Nick-Lucas
Copy link
Contributor

@Nick-Lucas Nick-Lucas commented Jan 8, 2025

This can't merge as is because it's a breaking change to splitLink, but I couldn't figure out how to keep the original behaviour while adding this because mapped types and records weren't playing nicely when intersected with the condition method. Also supporting booleans adds significant complexity (retained in this draft) which is probably not worth it

🎯 Changes

What changes are made in this PR? Is it a feature or a bug fix?

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

Copy link

railway-app bot commented Jan 8, 2025

This PR was not deployed automatically as @Nick-Lucas does not have access to the Railway project.

In order to get automatic PR deploys, please add @Nick-Lucas to the project inside the project settings page.

Copy link

vercel bot commented Jan 8, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
next-prisma-starter ✅ Ready (Inspect) Visit Preview Jan 23, 2025 7:21am
og-image ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 23, 2025 7:21am
www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 23, 2025 7:21am

Copy link

pkg-pr-new bot commented Jan 8, 2025

Open in Stackblitz

npm i https://pkg.pr.new/trpc/trpc/@trpc/client@6370
npm i https://pkg.pr.new/trpc/trpc/@trpc/next@6370
npm i https://pkg.pr.new/trpc/trpc/@trpc/server@6370
npm i https://pkg.pr.new/trpc/trpc/@trpc/react-query@6370

commit: 6325941

This was referenced Jan 13, 2025
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

This PR introduces significant changes to the splitLink functionality in tRPC, enabling string-based routing alongside boolean conditions while modifying the SOA example to demonstrate these changes.

  • Modified packages/client/src/links/splitLink.ts to support string-based routing keys, though type safety concerns exist with assertions and potential runtime errors
  • Changed examples/soa/client/client.ts to use splitLink instead of custom link implementation for server routing
  • Updated examples/soa/server-a/router.ts and server-b/router.ts to be async procedures with modified return types
  • Added new test cases in packages/client/src/links/splitLink.test.ts for string-based routing validation
  • Breaking changes in API design make this incompatible with existing implementations, requiring careful consideration before merging

💡 (1/5) You can manually trigger the bot by mentioning @greptileai in a comment!

6 file(s) reviewed, 8 comment(s)
Edit PR Review Bot Settings | Greptile

options: Record<string, TRPCLink<TRouter> | TRPCLink<TRouter>[]>;
},
): TRPCLink<TRouter> {
type $OptionRecord = Record<any, TRPCLink<TRouter> | TRPCLink<TRouter>[]>;
Copy link

Choose a reason for hiding this comment

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

logic: Using Record<any, ...> loses type safety. Consider using Record<string, ...> or a more specific type.

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.

2 participants