zenstack icon indicating copy to clipboard operation
zenstack copied to clipboard

[Feature Request]

Open cqh963852 opened this issue 11 months ago • 0 comments

Is your feature request related to a problem? Please describe.

I am using nextjs + zenstack + swr

I found the error of hook's return value is unknown.

image

Is there any way I can define it?

Describe the solution you'd like

generate hook function like

export function useCreateUser<Error = unknown>(options?: MutationOptions<Prisma.UserGetPayload<Prisma.UserCreateArgs> | undefined, Error, Prisma.UserCreateArgs>) {
    const mutation = request.useModelMutation('User', 'POST', 'create', metadata, options, true);
    return {
        ...mutation,
        trigger: <T extends Prisma.UserCreateArgs>(args: Prisma.SelectSubset<T, Prisma.UserCreateArgs>) => {
            return mutation.trigger(args, options as any) as Promise<Prisma.UserGetPayload<T> | undefined>;
        }
    };
}

cqh963852 avatar Jan 04 '25 04:01 cqh963852