Skip to content

feat(client): Add findUniqueOrThrow and findFirstOrThrow methods - #13920

Merged
SevInf merged 8 commits into
mainfrom
deprecate-rejectOnNotFound
Jun 22, 2022
Merged

SevInf merged 8 commits into
mainfrom
deprecate-rejectOnNotFound

Conversation

@SevInf

@SevInf SevInf commented Jun 20, 2022

Copy link
Copy Markdown
Contributor

Replacement for rejectOnNotFound. Introduces new gategory of model
actions: client-only actions, that are not defined on DMMF, but exist
solely on the client and work by wrapping the requests to the existing
DMMF-defined action and adding logic before or after it's performed.

Why do wrap request function specifically, and not, say, orginal methods
themselves. Two reasons:

  • To be 1:1 replacement to rejectOnNotFound, new methods should return
    PrismaPromise and do not start the query until awaited
  • Fluent API needs to work with new methods the same way it did with
    originals

Deprecate rejectOnNotFound. Deprecation warinings will be shown in
editors (via jsdoc comments) as well as logged to console once per
model/action combination

Close #12159

@SevInf
SevInf requested review from a team and aqrln June 20, 2022 17:47
@SevInf
SevInf requested review from Jolg42 and jkomyno as code owners June 20, 2022 17:47
@SevInf
SevInf force-pushed the deprecate-rejectOnNotFound branch from d27f684 to 72b0ee7 Compare June 20, 2022 18:06
@Jolg42 Jolg42 added this to the 4.0.x milestone Jun 21, 2022
Comment thread packages/client/src/generation/utils.ts Resolved
@aqrln

aqrln commented Jun 21, 2022

Copy link
Copy Markdown
Member

Overall it looks very good to me.

I agree with Pierre that it would be nice to avoid duplicating types.

@SevInf
SevInf requested review from danstarns and millsp June 21, 2022 14:50
@aqrln

aqrln commented Jun 21, 2022

Copy link
Copy Markdown
Member

Snapshots need to be updated

SevInf and others added 5 commits June 22, 2022 11:02
Replacement for `rejectOnNotFound`. Introduces new gategory of model
actions: client-only actions, that are not defined on DMMF, but exist
solely on the client and work by wrapping the requests to the existing
DMMF-defined action and adding logic before or after it's performed.

Why do wrap request function specifically, and not, say, orginal methods
themselves. Two reasons:
- To be 1:1 replacement to `rejectOnNotFound`, new methods should return
  `PrismaPromise` and do not start the query until awaited
- Fluent API needs to work with new methods the same way it did with
  originals

Deprecate `rejectOnNotFound`. Deprecation warinings will be shown in
editors (via jsdoc comments) as well as logged to console once per
model/action combination

Close #12159
@SevInf
SevInf force-pushed the deprecate-rejectOnNotFound branch from 5706eec to 206bc93 Compare June 22, 2022 09:02
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

Successfully merging this pull request may close these issues.

Consider replacing rejectOnNotFound

5 participants