From 12bb09c4c878f5138bcae27cdf7d9554071cdd48 Mon Sep 17 00:00:00 2001 From: Robert Soriano Date: Tue, 17 May 2022 16:52:50 -0700 Subject: [PATCH] remove mutation composable --- src/module.ts | 3 --- src/runtime/client.ts | 26 +------------------------- 2 files changed, 1 insertion(+), 28 deletions(-) diff --git a/src/module.ts b/src/module.ts index 6b83828..0e078b1 100644 --- a/src/module.ts +++ b/src/module.ts @@ -28,7 +28,6 @@ export default defineNuxtModule({ imports.push( { name: 'useTrpcQuery', from: clientPath }, { name: 'useLazyTrpcQuery', from: clientPath }, - { name: 'useTrpcMutation', from: clientPath }, { name: 'useClient', from: clientPath }, ) }) @@ -47,14 +46,12 @@ export default defineNuxtModule({ const { useTrpcQuery, useLazyTrpcQuery, - useTrpcMutation, useClient } = createTRPCComposables(client) export { useTrpcQuery, useLazyTrpcQuery, - useTrpcMutation, useClient } `) diff --git a/src/runtime/client.ts b/src/runtime/client.ts index 99e7f99..9f1b192 100644 --- a/src/runtime/client.ts +++ b/src/runtime/client.ts @@ -9,7 +9,6 @@ export function createTRPCComposables< Router extends AnyRouter, Client extends TRPCClient = TRPCClient, TQuery extends keyof Router['_def']['queries'] = keyof Router['_def']['queries'], - TMutation extends keyof Router['_def']['mutations'] = keyof Router['_def']['mutations'], >( client: Client ): { @@ -41,28 +40,10 @@ export function createTRPCComposables< >, true | Error > - useTrpcMutation: < - TRouteKey extends TMutation, - ProcedureInput = inferProcedureInput< - Router['_def']['mutations'][TRouteKey] - >, - ProcedureOutput = inferProcedureOutput< - Router['_def']['mutations'][TRouteKey] - >, - >( - path: TRouteKey, - input: ProcedureInput - ) => AsyncData< - PickFrom< - ProcedureOutput, - KeyOfRes<_Transform> - >, - true | Error - > useClient: () => Client } -export function createTRPCComposables(client: any) { +export function createTRPCComposables(client) { const useTrpcQuery = (...args) => { return useAsyncData(`trpc-${objectHash(args[0] + (args[1] ? JSON.stringify(args[1]) : ''))}`, () => client.query(...args)) } @@ -71,16 +52,11 @@ export function createTRPCComposables(client: any) { return useLazyAsyncData(`trpc-${objectHash(args[0] + (args[1] ? JSON.stringify(args[1]) : ''))}`, () => client.query(...args)) } - const useTrpcMutation = (...args) => { - return useAsyncData(`trpc-${objectHash(args[0] + (args[1] ? JSON.stringify(args[1]) : ''))}`, () => client.mutation(...args)) - } - const useClient = () => client return { useTrpcQuery, useLazyTrpcQuery, - useTrpcMutation, useClient, } }