question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Prisma interactive transactions API error: "Argument of type 'x' is not assignable to parameter of type 'PrismaPromise<any>[]'"

See original GitHub issue

Bug description

See discussion in the prisma chat: https://prisma.slack.com/archives/CA491RJH0/p1628865496360000

A simple update query inside the transaction gives me an error: Argument of type '() => Promise<Integration>' is not assignable to parameter of type 'PrismaPromise<any>[]'.

const trans = await this.prisma.$transaction(async () => {
	return this.prisma.integration.update({
		data: {
			...
		},
		where: {
			id: integration.id
		}
	});
});

I do have the preview feature on: previewFeatures = ["orderByRelation", "referentialActions", "interactiveTransactions"], also I did a generate.

How to reproduce

Simple query like:

const trans = await this.prisma.$transaction(async () => {
	return this.prisma.integration.update({
		data: {
			...
		},
		where: {
			id: integration.id
		}
	});
});

### Expected behavior

Not to show me the error

### Prisma information

```js
model Integration {
    id                        String   @id @db.VarChar(255)
    integrationMethodId       String   @db.VarChar(255)
    name                      String   @db.VarChar(255)
    username                  String   @db.VarChar(255)
    password                  String   @db.VarChar(255)
    descriptionCharacterLimit Int      @db.Integer
    createdAt                 DateTime @default(now()) @db.Timestamptz
    updatedAt                 DateTime @updatedAt @db.Timestamptz

    @@unique([integrationMethodId, username])
}

Environment & setup

- OS: Windows
- Database: PostgreSQL
- Node.js version: v14.15.5

Prisma Version

2.29.0

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Rykunocommented, Aug 18, 2021

Hey @Rykuno, I looked into the latest release code. You probably just need to add interactiveTransactions to the preview features in your schema.prisma file. This is not documented but is required.

generator client {
  provider = "prisma-client-js"
  previewFeatures = ["interactiveTransactions"]
}

Cheers!

Hey! Yes I did add add the preview feature, db push and try a few things but I’m not sure exactly what fixed it as I threw a bunch of solutions at once at the issue. It might just be my vscode being weird. One of those solutions i mentioned sure worked lol!

Just to clarify the transaction actually worked, just the ts typings were throwing linting errors

0reactions
millspcommented, Feb 4, 2022

Marking this issue as resolved. Feel free to re-open or ping me if you encounter this again. Please make sure that you have regenerated your Prisma Client after enabling the preview flag and restarted your TS server (or VSCode).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Prisma transaction in nodejs and typescript not working
Argument of type '(tx: any) => Promise' is not assignable to parameter of type 'PrismaPromise[]'. Type '(tx: any) => Promise' is missing the ......
Read more >
Typing for transaction doesn't include async function argument
Argument of type '(prismaClient: any) => Promise<any>' is not assignable to parameter of type 'PrismaPromise<any>[]'. Type '(prismaClient: ...
Read more >
prisma is not assignable to type - You.com | The AI Search ...
prisma /prismaPrisma interactive transactions API error: "Argument of type 'x' is not assignable to parameter of type 'PrismaPromise<any>[]'"#8739.
Read more >
Argument Type not assignable to Parameter Type Variables
I'm passing an object of arguments into the graphcool api and am getting this: Argument type {tag: string, from: string, to: [string], ...
Read more >
hi I am still having some issues with the interactive transa - Linen
Argument of type '() => Promise<Integration[]>' is not assignable to parameter of type 'PrismaPromise<any>[]' const [updatedIntegration] = await this.prisma ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found