trpc / v10-playground

tRPC v10 procedure play
https://stackblitz.com/github/trpc/v10-playground?file=src%2Fserver%2Findex.ts,src%2Fclient.ts,src%2Fserver%2Frouters%2FpostRouter.ts&view=editor
13 stars 3 forks source link

Make the RPC call as property access on the Proxy? #19

Closed esamattis closed 2 years ago

esamattis commented 2 years ago

Since you are using JS Proxies why not go all in and implement the rpc calls directly as a property access?

Eg. instead of

client.query(queries.greeting, {hello: 'string'})

why not allow

client.greeting({hello: 'string'})

Although with this it could be trickier for the go-to-definition implementation.

esamattis commented 2 years ago

Also one could argue that "dotted" queries are uglier with this

client["todo.add"]({task: 'string'})

Personally I don't care. I'd just stay with camel casing.

KATT commented 2 years ago

Also one could argue that "dotted" queries are uglier with this

client["todo.add"]({task: 'string'})

Personally I don't care. I'd just stay with camel casing.

See https://github.com/trpc/v10-playground/issues/6#issuecomment-1018998345

KATT commented 2 years ago

Eg. instead of

client.query(queries.greeting, {hello: 'string'})

why not allow

client.greeting({hello: 'string'})

I will have a play with this!

KATT commented 2 years ago

Closing in favor of #26