-
Notifications
You must be signed in to change notification settings - Fork 3
Make the RPC call as property access on the Proxy #21
Conversation
Really cool!
Does it matter if it is just the internals? Should not affect the users in any way? 🤔 |
In some cases it might, if they miss using the proxy object for instance or are doing backend-stuff and trying to explicitly call the functions |
Furthermore... Wondering how the React-api could look like. I've noticed that when I try to remap functions, I seem to lose CMD+click ability... A few options // this is a bit ugly but will work to do CMD+click on `greeting` with to jump to the backend
const { queries } = myQueries
trpc.useQuery(queries.greeting({ name: 'world' }), { /* .. further options */})
// these below won't work to CMD+click on :(
trpc.useQuery.greeting({ name: 'world' }, { /* .. further options */})
trpc.useGreetingQuery({ name: 'world' }, { /* .. further options */}) |
@colinhacks maybe you have ideas/input on the above? |
Hmm, direct proxy usage might a bit too magical. Explicit query argument does indeed communicate better that there's something more than just a function call going on. And if it does not work out for the React hook, there some value having them be consistent: client.query(query.greeting, { name: "world" });
useQuery(query.greeting, { name: "world" }); |
# Conflicts: # .big/client.ts # src/server.test.ts # src/server.ts # src/trpc/server/middlewares/zod.ts # src/trpc/server/procedure.ts # src/trpc/server/router.ts # src/trpc/server/types.ts
Merging for now - can be discussed in #26 |
ProcedureResult
to check the results of a procedureAllows you to call your API like this:
Upsides
Downsides
trpc.resolver(() => /* ... */)