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