Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using prisma-extension-supabase-rls with trpc? #5

Open
remusris opened this issue Oct 17, 2024 · 0 comments
Open

using prisma-extension-supabase-rls with trpc? #5

remusris opened this issue Oct 17, 2024 · 0 comments

Comments

@remusris
Copy link

remusris commented Oct 17, 2024

Below is my attempt of using this extension with trpc, is there anything that stops it from working with trpc?

import { PrismaClient } from "@prisma/client";

import { env } from "~/env.mjs";

import { supabaseRowLevelSecurity } from "~/supabase/useSupabaseRowLevelSecurity";

const globalForPrisma = globalThis as unknown as {
  prisma: PrismaClient | undefined;
};

// current method
/* export const prisma =
  globalForPrisma.prisma ??
  new PrismaClient({
    log:
      env.NODE_ENV === "development" ? ["query", "error", "warn"] : ["error"],
  }); */

// new method
export const prisma =
  globalForPrisma.prisma ??
  new PrismaClient({
    log:
      env.NODE_ENV === "development" ? ["query", "error", "warn"] : ["error"],
    datasources: {
      db: {
        url: env.DATABASE_URL
      }
    },
  }).$extends(supabaseRowLevelSecurity());


if (env.NODE_ENV !== "production") globalForPrisma.prisma = prisma;

We have an error on this line

if (env.NODE_ENV !== "production") globalForPrisma.prisma = prisma;

Type 'PrismaClient<PrismaClientOptions, never, DefaultArgs> | DynamicClientExtensionThis<TypeMap<InternalArgs & { result: {}; model: {}; query: {}; client: {}; }, PrismaClientOptions>, TypeMapCb, { ...; }, {}>' is not assignable to type 'PrismaClient<PrismaClientOptions, never, DefaultArgs> | undefined'.
  Type 'DynamicClientExtensionThis<TypeMap<InternalArgs & { result: {}; model: {}; query: {}; client: {}; }, PrismaClientOptions>, TypeMapCb, { result: {}; model: {}; query: {}; client: {}; }, {}>' is not assignable to type 'PrismaClient<PrismaClientOptions, never, DefaultArgs> | undefined'.
    Type 'DynamicClientExtensionThis<TypeMap<InternalArgs & { result: {}; model: {}; query: {}; client: {}; }, PrismaClientOptions>, TypeMapCb, { result: {}; model: {}; query: {}; client: {}; }, {}>' is missing the following properties from type 'PrismaClient<PrismaClientOptions, never, DefaultArgs>': $on, $usets(2322)

I renamed useSupabaseRowLevelSecurity to supabaseRowLevelSecurity.

Can this extension still work with trpc?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant