diff --git a/package-lock.json b/package-lock.json index b755711..3faa155 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "solid-trpc", - "version": "0.0.7-rc.1", + "version": "0.0.10-rc.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "solid-trpc", - "version": "0.0.7-rc.1", + "version": "0.0.10-rc.2", "license": "MIT", "devDependencies": { "@babel/core": "^7.18.13", @@ -24,8 +24,8 @@ }, "peerDependencies": { "@tanstack/solid-query": "^4.6.1", - "@trpc/client": "10.0.0-rc.2", - "@trpc/server": "10.0.0-rc.2", + "@trpc/client": "^10.0.0-rc.2", + "@trpc/server": "^10.0.0-rc.2", "solid-js": "^1.5.3" } }, diff --git a/package.json b/package.json index 50b09c0..cc677e0 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "description": "SolidJS tRPC", "author": "OrJDev", "license": "MIT", - "version": "0.0.10-rc.2", + "version": "0.0.11-rc.2", "publishConfig": { "access": "public", "tag": "next" diff --git a/src/shared/hooks/createHooksInternal.tsx b/src/shared/hooks/createHooksInternal.tsx index 1599a86..efaa304 100644 --- a/src/shared/hooks/createHooksInternal.tsx +++ b/src/shared/hooks/createHooksInternal.tsx @@ -1,6 +1,5 @@ import { DehydratedState, - QueryClient, CreateInfiniteQueryOptions, CreateInfiniteQueryResult, CreateMutationOptions, @@ -11,7 +10,6 @@ import { createMutation as __useMutation, createQuery as __useQuery, hashQueryKey, - useQueryClient, QueryClientProviderProps, QueryClientProvider, } from "@tanstack/solid-query"; @@ -50,7 +48,7 @@ import { TRPCContextState, } from "../../internals/context"; import { getArrayQueryKey } from "../../internals/getArrayQueryKey"; -import { CreateTRPCSolidOptions, UseMutationOverride } from "../types"; +import { CreateTRPCSolidOptions } from "../types"; export type OutputWithCursor = { cursor: TCursor | null; @@ -186,9 +184,9 @@ export function createHooksInternal< TRouter extends AnyRouter, TSSRContext = unknown >(config?: CreateTRPCSolidOptions) { - const mutationSuccessOverride: UseMutationOverride["onSuccess"] = - config?.unstable_overrides?.useMutation?.onSuccess ?? - ((options) => options.originalFn()); + // const mutationSuccessOverride: UseMutationOverride["onSuccess"] = + // config?.unstable_overrides?.useMutation?.onSuccess ?? + // ((options) => options.originalFn()); type TQueries = TRouter["_def"]["queries"]; type TSubscriptions = TRouter["_def"]["subscriptions"]; @@ -208,9 +206,9 @@ export function createHooksInternal< }; const Context = (config?.context ?? TRPCContext) as Context; - const SolidQueryContext = config?.solidQueryContext as Context< - QueryClient | undefined - >; + // const SolidQueryContext = config?.solidQueryContext as Context< + // QueryClient | undefined + // >; const createClient: CreateClient = (opts) => { return createTRPCClient(opts); @@ -406,10 +404,7 @@ export function createHooksInternal< ...getClientArgs(pathAndInput(), actualOpts()) ); }, - { - context: SolidQueryContext, - ...opts, - } as any + opts as any ) as UseTRPCQueryResult; } @@ -431,25 +426,15 @@ export function createHooksInternal< TContext > { const ctx = useContext(); - const queryClient = useQueryClient({ context: SolidQueryContext }); + // const queryClient = useQueryClient({ context: SolidQueryContext }); - return __useMutation( - (input) => { - const actualPath = Array.isArray(path) ? path[0] : path; + return __useMutation((input) => { + const actualPath = Array.isArray(path) ? path[0] : path; - return (ctx.client.mutation as any)( - ...getClientArgs([actualPath, input], opts) - ); - }, - { - context: SolidQueryContext, - ...opts, - onSuccess(...args) { - const originalFn = () => opts?.onSuccess?.(...args); - return mutationSuccessOverride({ originalFn, queryClient }); - }, - } - ) as UseTRPCMutationResult< + return (ctx.client.mutation as any)( + ...getClientArgs([actualPath, input], opts) + ); + }, opts as any) as UseTRPCMutationResult< TMutationValues[TPath]["output"], TError, TMutationValues[TPath]["input"], @@ -568,7 +553,7 @@ export function createHooksInternal< ...getClientArgs([pathAndInput()[0], actualInput], actualOpts()) ); }, - { context: SolidQueryContext, ...ssrOpts } as any + ssrOpts as any ) as UseTRPCInfiniteQueryResult; } const useDehydratedState: UseDehydratedState = (