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

Prisma preview feature extendedWhereUnique type error in PrismaStorage #4013

Closed
cfragkos opened this issue Dec 20, 2022 · 2 comments
Closed
Labels
kind/bug Something isn't working status/done

Comments

@cfragkos
Copy link

What is the problem?

When enabling the extendedWhereUnique Prisma preview feature the PrismaStorage function in blitz-server.ts throws a type error.

Paste all your error logs here:

Type error: Argument of type 'PrismaClient<PrismaClientOptions, unknown, RejectOnNotFound | RejectPerOperation | undefined> & EnhancedPrismaClientAddedMethods' is not assignable to parameter of type 'PrismaClientWithSession'.
  The types of 'session.update' are incompatible between these types.
    Type '<T extends SessionUpdateArgs>(args: SelectSubset<T, SessionUpdateArgs>) => Prisma__SessionClient<SessionGetPayload<T>, never>' is not assignable to type '(args: { data: Partial<SessionModel>; where: { handle?: string | undefined; }; }) => Promise<SessionModel>'.
      Types of parameters 'args' and 'args' are incompatible.
        Type '{ data: Partial<SessionModel>; where: { handle?: string | undefined; }; }' is not assignable to type '{ select?: SessionSelect | null | undefined; include?: SessionInclude | null | undefined; data: (Without<SessionUpdateInput, SessionUncheckedUpdateInput> & SessionUncheckedUpdateInput) | (Without<...> & SessionUpdateInput); where: SessionWhereUniqueInput; }'.
          Types of property 'where' are incompatible.
            Type '{ handle?: string | undefined; }' is not assignable to type 'SessionWhereUniqueInput'.
              Type '{ handle?: string | undefined; }' is not assignable to type '{ id: string | number; handle: string | number; } & { id?: number | undefined; handle?: string | undefined; AND?: Enumerable<SessionWhereInput> | undefined; ... 10 more ...; userId?: number | ... 2 more ... | undefined; }'.
                Property 'id' is missing in type '{ handle?: string | undefined; }' but required in type '{ id: string | number; handle: string | number; }'.

Paste all relevant code snippets here:

export const { gSSP, gSP, api } = setupBlitzServer({
	plugins: [
		AuthServerPlugin({
			...authConfig,
			storage: PrismaStorage(db),
			isAuthorized: simpleRolesIsAuthorized
		})
	],
	logger: BlitzLogger({})
});

What are detailed steps to reproduce this?

  1. Enable Prisma previewFeatures = ["extendedWhereUnique"]
  2. run prisma generate
  3. run blitz build or blitz dev

Run blitz -v and paste the output here:

PASTE_HERE (leave the ``` marks)

Please include below any other applicable logs and screenshots that show your problem:

Blitz version: 2.0.0-beta.20 (local)
Linux 6.0 | linux-x64 | Node: v16.18.0

Package manager: npm

System:
OS: Linux 6.0 Manjaro Linux
CPU: (20) x64 12th Gen Intel(R) Core(TM) i7-12700K
Memory: 16.03 GB / 31.10 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 16.18.0 - /tmp/xfs-d890acf3/node
Yarn: 3.3.0 - /tmp/xfs-d890acf3/yarn
npm: 8.19.2 - ~/.nvm/versions/node/v16.18.0/bin/npm
npmPackages:
@blitzjs/auth: 2.0.0-beta.20 => 2.0.0-beta.20
@blitzjs/next: 2.0.0-beta.20 => 2.0.0-beta.20
@blitzjs/rpc: 2.0.0-beta.20 => 2.0.0-beta.20
@prisma/client: ^4.8.0 => 4.8.0
blitz: 2.0.0-beta.20 => 2.0.0-beta.20
next: 12.2.5 => 12.2.5
prisma: ^4.8.0 => 4.8.0
react: 18.2.0 => 18.2.0
react-dom: 18.2.0 => 18.2.0
typescript: ^4.8.4 => 4.9.4

@cfragkos cfragkos added kind/bug Something isn't working status/triage labels Dec 20, 2022
@itsdillon
Copy link
Member

I can mark this as ready to work on for anyone who want's to tackle this. The type interface can be found here https://github.com/blitz-js/blitz/blob/a4294ad29ce721fc53b153499e068f175b6c1d40/packages/blitz-auth/src/server/auth-plugin.ts#LL22C7-L22C7

@itsdillon itsdillon added the status/ready-to-work-on This issue is up for grabs label Dec 29, 2022
@blitzjs-bot blitzjs-bot added status/done and removed status/ready-to-work-on This issue is up for grabs labels Oct 24, 2023
@justinbalaguer
Copy link

getting this issue as well when adding this:

generator client {
  provider = "prisma-client-js"
  binaryTargets = ["native", "linux-musl"]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working status/done
Projects
Status: Done
Development

No branches or pull requests

5 participants