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

Client extensions: $allOperations limitations #5057

Open
Tracked by #19416
ul8 opened this issue Mar 2, 2023 · 5 comments
Open
Tracked by #19416

Client extensions: $allOperations limitations #5057

ul8 opened this issue Mar 2, 2023 · 5 comments
Labels
docs Documentation creation, updates or corrections

Comments

@ul8
Copy link

ul8 commented Mar 2, 2023

Bug description

prisma.$extends typescript validation fails when trying to modify all operations in a specific model

I get a type error on args.where

Property 'where' does not exist on type '({ readonly select?: ReadonlyDeep<CategoryTranslationSelect<DefaultArgs> | null | undefined>; readonly include?: ReadonlyDeep<CategoryTranslationInclude<DefaultArgs> | null | undefined>; } & { ...; }) | ... 12 more ... | ({ ...; } & { ...; })'.
  Property 'where' does not exist on type '{ readonly select?: ReadonlyDeep<CategoryTranslationSelect<DefaultArgs> | null | undefined>; readonly include?: ReadonlyDeep<CategoryTranslationInclude<DefaultArgs> | null | undefined>; } & { ...; }'.ts(2339)

How to reproduce

Code that works fine:

prisma.$extends({
    query: {
        categoryTranslation: {
            async findMany({ model, operation, args, query }) {
                args.where = { locale: { code: 'en_US' }, ...args.where };
                return query(args);
            }
        }
    }
});

When I change it to this it starts showing the above error

prisma.$extends({
    query: {
        categoryTranslation: {
            $allOperations({ model, operation, args, query }) {
                args.where = { locale: { code: 'en_US' }, ...args.where };
                return query(args);
            }
        }
    }
});

Expected behavior

From reading the documentation, I would expect not to see any error here.

If this is expected behavior, the documentation could probably be improved.

To be clear, it does work, just the type errors are the problem.

Prisma information

model CategoryTranslation {
  id                  Int               @id @default(autoincrement())
  localeId            Int
  locale              Locale            @relation(fields: [localeId], references: [id])
}

model Locale {
  id                        Int                        @id @default(autoincrement())
  code                      String                     @unique
  categoryTranslations      CategoryTranslation[]
}

Environment & setup

  • OS:macOS→
  • Database: SQLite→
  • Node.js version: 19.3

Prisma Version

prisma                  : 4.11.0
@prisma/client          : 4.11.0
Current platform        : darwin
Query Engine (Node-API) : libquery-engine 8fde8fef4033376662cad983758335009d522acb (at node_modules/@prisma/engines/libquery_engine-darwin.dylib.node)
Migration Engine        : migration-engine-cli 8fde8fef4033376662cad983758335009d522acb (at node_modules/@prisma/engines/migration-engine-darwin)
Format Wasm             : @prisma/prisma-fmt-wasm 4.11.0-57.8fde8fef4033376662cad983758335009d522acb
Default Engines Hash    : 8fde8fef4033376662cad983758335009d522acb
Studio                  : 0.483.0
Preview Features        : clientExtensions
@millsp
Copy link
Member

millsp commented Jun 1, 2023

@janpio janpio transferred this issue from prisma/prisma Jul 14, 2023
@janpio janpio added the docs Documentation creation, updates or corrections label Jul 14, 2023
@BrettBurbidge
Copy link

Do you know if there has been any progress on this issue? The code works just fine but there are build errors. I don't want to enable ignoreBuildError in next.config.js. Also, this error is not ignorable using // eslint-disable-next-line

$allOperations extensions are critical for our current multitenant solution. Would love to find a solution to this.

If anyone has found work or fix around, I'd love to hear.

@janpio
Copy link
Member

janpio commented Dec 5, 2023

Please open an issue in https://github.com/prisma/prisma. Thanks.

@BrettBurbidge
Copy link

This issue is already articulated very well on this ticket from @ul8. I am happy to create a new ticket, but it be a duplicate this one.

If an issue is required to get this fixed. I will submit one.

@gal1419
Copy link

gal1419 commented Feb 26, 2024

Having the same issue, would appreciate a fix. That is crucial for multi tenancy development.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation creation, updates or corrections
Projects
None yet
Development

No branches or pull requests

5 participants