codeledge / ra-tools

React Admin Tools, namely the Prisma Data Adapter
66 stars 19 forks source link

Make handlers support DynamicClientExtension #75

Open mshd opened 10 months ago

mshd commented 10 months ago

currently the default handler has a type conflict with new PrismaClient({}).$extends({

mmxdr commented 3 months ago

hi, im facing the same issue

const prismaClientSingleton = () => {
  const prismaClient = new PrismaClient().$extends({
    result: {
      image: {
        url: {
          needs: { fileName: true },
          compute(image) {
            return `${process.env.NEXT_PUBLIC_HOST}/attachments/${image.fileName}`;
          },
        },
      },
    },
  });

  return prismaClient;
};

Argument of type 'DynamicClientExtensionThis<TypeMap<InternalArgs & { result: { image: { url: () => { needs: { fileName: true; }; compute(image: { fileName: string; }): string; }; }; }; model: {}; query: {}; client: {}; }>, TypeMapCb, { ...; }>' is not assignable to parameter of type 'PrismaClient<PrismaClientOptions, never, DefaultArgs>'.

ogroppo commented 3 months ago

yes there should be a solution that works for all versions... will have a look this month

ogroppo commented 1 month ago

Still looking into it, version 5.2.1 did not fix. for now casting the client to as PrismaClient does the job.