diff --git a/.changeset/dry-eagles-hammer.md b/.changeset/dry-eagles-hammer.md new file mode 100644 index 0000000..d6bc98b --- /dev/null +++ b/.changeset/dry-eagles-hammer.md @@ -0,0 +1,5 @@ +--- +'@solid-mediakit/prpc': patch +--- + +fix: mutation input typings diff --git a/examples/prpc/src/routes/builder-mutation.tsx b/examples/prpc/src/routes/builder-mutation.tsx index 8e8109e..5a9536e 100644 --- a/examples/prpc/src/routes/builder-mutation.tsx +++ b/examples/prpc/src/routes/builder-mutation.tsx @@ -12,6 +12,7 @@ const Home: VoidComponent = () => { } }, })) + return (

{helloMut.data ?? 'No Data yet...'}

diff --git a/packages/prpc/solid/src/mutation.ts b/packages/prpc/solid/src/mutation.ts index 34adfe4..3ada55c 100644 --- a/packages/prpc/solid/src/mutation.ts +++ b/packages/prpc/solid/src/mutation.ts @@ -29,7 +29,11 @@ export const mutation$ = < mutationFn: async (input) => await tryAndWrap(props.mutationFn, input), mutationKey: ['prpc.mutation', props.key], ...(opts?.() ?? {}), - })) as CreateMutationResult> + })) as unknown as CreateMutationResult< + Fn$Output, + ZObj extends ZodSchema ? PRPCClientError : PRPCClientError, + Infer$PayLoad + > } } diff --git a/packages/prpc/solid/src/query.ts b/packages/prpc/solid/src/query.ts index 609e677..a66c3e6 100644 --- a/packages/prpc/solid/src/query.ts +++ b/packages/prpc/solid/src/query.ts @@ -102,7 +102,10 @@ export const query$ = < input ? JSON.stringify(input()) : undefined, ], ...((opts?.() ?? {}) as any), - })) as CreateQueryResult> + })) as unknown as CreateQueryResult< + Fn$Output, + ZObj extends ZodSchema ? PRPCClientError : PRPCClientError + > } return new Proxy(actualFn, { get(target, prop) { diff --git a/packages/prpc/solid/src/types.ts b/packages/prpc/solid/src/types.ts index f203507..0bb028a 100644 --- a/packages/prpc/solid/src/types.ts +++ b/packages/prpc/solid/src/types.ts @@ -4,6 +4,8 @@ import { Accessor } from 'solid-js' import { FCreateQueryOptions } from './query' import { CreateMutationResult, CreateQueryResult } from '@tanstack/solid-query' import { FCreateMutationOptions } from './mutation' +import { ZodSchema } from 'zod' +import { PRPCClientError } from './error' export type EmptySchema = void | undefined @@ -97,14 +99,21 @@ export type QueryBuilder< ? EmptySchema : Accessor>, opts?: FCreateQueryOptions>, - ): CreateQueryResult> + ): CreateQueryResult< + Fn$Output, + ZObj extends ZodSchema ? PRPCClientError : PRPCClientError + > } : {}) & (BuilderType extends 'mutation' ? { ( opts?: FCreateMutationOptions>, - ): CreateMutationResult> + ): CreateMutationResult< + Fn$Output, + ZObj extends ZodSchema ? PRPCClientError : PRPCClientError, + Infer$PayLoad + > } : {} & BuilderType extends void ? {