Closed KATT closed 8 months ago
Closes #24
When testing RPC function it's useful to be able to call them directly with the implementation
// retool.ts // [...] const rpc = new RetoolRPC({ // [...] }); export const helloWorld = rpc.register({ name: 'helloWorld', arguments: { name: { type: 'string', description: 'Your name', required: true }, }, implementation: async (args, context) => { return { message: `Hello ${args.name}`, context, }; }, });
// retool.test.ts import { helloWorld } from './retool'; test('helloWorld', async () => { const result = await helloWorld( { name: 'world', }, { // ... context }, ); expect(result.message).toBe(`Hello world`); });
It's possible to work around, but it's a bit annoying, it's nicer if the SDK could just return the function implementation
Change is live on 0.1.5
Closes #24
Why
When testing RPC function it's useful to be able to call them directly with the implementation
Example
What this does
Alternatives / workarounds
It's possible to work around, but it's a bit annoying, it's nicer if the SDK could just return the function implementation