minor changes

This commit is contained in:
OrJDev
2022-10-15 23:51:39 +03:00
parent 2ee53b43b2
commit c7f622a0cc
4 changed files with 48 additions and 36 deletions
+6 -8
View File
@@ -1,22 +1,21 @@
{
"name": "solid-trpc",
"version": "0.0.5",
"version": "0.0.8",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "solid-trpc",
"version": "0.0.5",
"version": "0.0.8",
"license": "MIT",
"devDependencies": {
"@babel/core": "^7.18.13",
"@babel/preset-typescript": "^7.18.6",
"@rollup/plugin-babel": "5.3.1",
"@rollup/plugin-node-resolve": "13.3.0",
"@tanstack/query-core": "^4.6.1",
"@tanstack/solid-query": "^4.6.1",
"@trpc/client": "^9.27.2",
"@trpc/server": "^9.27.2",
"@trpc/client": "9.27.2",
"@trpc/server": "9.27.2",
"@types/node": "^18.7.14",
"babel-preset-solid": "^1.5.3",
"rollup": "^2.79.0",
@@ -24,10 +23,9 @@
"typescript": "^4.8.2"
},
"peerDependencies": {
"@tanstack/query-core": "^4.6.1",
"@tanstack/solid-query": "^4.6.1",
"@trpc/client": "^9.12.0",
"@trpc/server": "^9.12.0",
"@trpc/client": "9.27.2",
"@trpc/server": "9.27.2",
"solid-js": "^1.5.3"
}
},
+7 -8
View File
@@ -3,7 +3,7 @@
"description": "SolidJS tRPC",
"author": "OrJDev",
"license": "MIT",
"version": "0.0.5",
"version": "0.0.8",
"publishConfig": {
"access": "public"
},
@@ -29,21 +29,20 @@
"@babel/preset-typescript": "^7.18.6",
"@rollup/plugin-babel": "5.3.1",
"@rollup/plugin-node-resolve": "13.3.0",
"@tanstack/query-core": "^4.6.1",
"@tanstack/solid-query": "^4.6.1",
"@trpc/client": "^9.27.2",
"@trpc/server": "^9.27.2",
"@trpc/client": "9.27.2",
"@trpc/server": "9.27.2",
"@types/node": "^18.7.14",
"babel-preset-solid": "^1.5.3",
"rollup": "^2.79.0",
"solid-js": "^1.5.3",
"typescript": "^4.8.2"
"typescript": "^4.8.2",
"zod": "^3.0.0"
},
"peerDependencies": {
"@tanstack/query-core": "^4.6.1",
"@tanstack/solid-query": "^4.6.1",
"@trpc/client": "^9.12.0",
"@trpc/server": "^9.12.0",
"@trpc/client": "9.27.2",
"@trpc/server": "9.27.2",
"solid-js": "^1.5.3"
},
"keywords": [
+34 -19
View File
@@ -4,14 +4,16 @@ import {
TRPCClientErrorLike,
TRPCRequestOptions,
createTRPCClient,
OperationContext,
} from "@trpc/client";
import type {
import {
AnyRouter,
ProcedureRecord,
inferHandlerInput,
inferProcedureInput,
inferProcedureOutput,
inferSubscriptionOutput,
router,
} from "@trpc/server";
import {
CreateInfiniteQueryOptions,
@@ -38,27 +40,23 @@ export type OutputWithCursor<TData, TCursor extends any = any> = {
data: TData;
};
type OmitContext<T> = Omit<T, "context"> & {
context?: TRPCRequestOptions["context"];
};
type OmitContext<T> = Omit<T, "context"> & { context?: OperationContext };
export interface CreateTRPCQueryOptions<TPath, TInput, TOutput, TData, TError>
extends OmitContext<
CreateQueryOptions<TOutput, TError, TData, () => [TPath, TInput]>
>,
TRPCRequestOptions {}
CreateQueryOptions<TOutput, TError, TData, () => [TPath, TInput]>
> {}
export interface CreateTRPCInfiniteQueryOptions<TPath, TInput, TOutput, TError>
extends OmitContext<
CreateInfiniteQueryOptions<
TOutput,
TError,
TOutput,
TOutput,
() => [TPath, TInput]
>
>,
TRPCRequestOptions {}
CreateInfiniteQueryOptions<
TOutput,
TError,
TOutput,
TOutput,
() => [TPath, TInput]
>
> {}
export interface CreateTRPCMutationOptions<
TInput,
@@ -134,9 +132,10 @@ export function createSolidQueryHooks<TRouter extends AnyRouter>() {
) {
ctx.prefetchQuery(pathAndInput(), opts as any);
}
return __createQuery(pathAndInput, () =>
(ctx.client as any).query(...getClientArgs(pathAndInput(), opts))
return __createQuery(
pathAndInput,
() => (ctx.client as any).query(...getClientArgs(pathAndInput(), opts)),
opts as any
);
}
@@ -251,3 +250,19 @@ export function createSolidQueryHooks<TRouter extends AnyRouter>() {
}
export { default as TRPCProvider } from "./provider";
// // type testing
// const r = router().query("hello", {
// input: z.object({
// num: z.number(),
// }),
// resolve: ({ input }) => {
// return input.num;
// },
// });
// export type TRouter = typeof r;
// const res = createSolidQueryHooks<TRouter>()
// res.createQuery(()=> ['hello', {num: 1}])
+1 -1
View File
@@ -18,7 +18,7 @@ import {
RefetchQueryFilters,
SetDataOptions,
} from "@tanstack/solid-query";
import { Updater } from "@tanstack/query-core";
import { Updater } from "@tanstack/solid-query";
interface TRPCFetchQueryOptions<TInput, TError, TOutput>
extends FetchQueryOptions<TInput, TError, TOutput>,