Skip to content

Conversation

@SevInf
Copy link
Contributor

@SevInf SevInf commented Jul 28, 2023

Fix #20437

/integration

@SevInf SevInf requested a review from a team as a code owner July 28, 2023 14:17
@SevInf SevInf requested review from Druue and aqrln and removed request for a team July 28, 2023 14:17
@SevInf SevInf added this to the 5.1.0 milestone Jul 28, 2023
@SevInf SevInf requested review from millsp and removed request for Druue July 28, 2023 14:17
@SevInf SevInf force-pushed the fix/result-query-ext branch from 73cecc6 to 5585688 Compare July 28, 2023 14:56
@SevInf SevInf merged commit b15ac85 into main Jul 31, 2023
@SevInf SevInf deleted the fix/result-query-ext branch July 31, 2023 07:28
overbit pushed a commit to overbit/prisma that referenced this pull request Jul 31, 2023
…ensions (prisma#20438)

* fix(client): Ensure result extensions are applied after all query extensions

Fix prisma#20437

* Move recursive `applyExtensions` into it's own module
SevInf pushed a commit that referenced this pull request Aug 2, 2023
Problem: after #20438, we were trying to apply result extensions to
"sugared" result of `.count` method - plain number. Theoretically,
extensions should not apply there at all, but field with no `needs`
applies to every result of a corresponding model. And since result
extensions use proxies and proxy can not be created over non-objects,
the code thrown very undescriptive error instead.

Fix #20499
SevInf pushed a commit that referenced this pull request Aug 2, 2023
* fix(client): Make sure result extensions don't break `.count`

Problem: after #20438, we were trying to apply result extensions to
"sugared" result of `.count` method - plain number. Theoretically,
extensions should not apply there at all, but field with no `needs`
applies to every result of a corresponding model. And since result
extensions use proxies and proxy can not be created over non-objects,
the code thrown very undescriptive error instead.

Fix #20499

* Update packages/client/src/runtime/core/extensions/applyAllResultExtensions.ts

Co-authored-by: Joël Galeran <[email protected]>

---------

Co-authored-by: Joël Galeran <[email protected]>
SevInf pushed a commit that referenced this pull request Aug 2, 2023
* fix(client): Make sure result extensions don't break `.count`

Problem: after #20438, we were trying to apply result extensions to
"sugared" result of `.count` method - plain number. Theoretically,
extensions should not apply there at all, but field with no `needs`
applies to every result of a corresponding model. And since result
extensions use proxies and proxy can not be created over non-objects,
the code thrown very undescriptive error instead.

Fix #20499

* Update packages/client/src/runtime/core/extensions/applyAllResultExtensions.ts

Co-authored-by: Joël Galeran <[email protected]>

---------

Co-authored-by: Joël Galeran <[email protected]>
@greg0x
Copy link

greg0x commented Aug 28, 2023

@SevInf I am not sure about the original intention but I assume, that the result extensions should also work for nested queries as well. At the moment if the model is loaded through a select, then the result extensions are not applied because the model is the "parent" model.

See my comment for a bit more detail: prisma/docs#5217 (comment)

What would be a good next step here?

@SevInf
Copy link
Contributor Author

SevInf commented Aug 29, 2023

@greg-nagy Result extensions are intended to work with nested read and writes and we have several tests for that inside of our repo. If that's not the case - please, open a separate issue and share all reproduction steps.
This PR generally has nothing to do with this. You are incorrect about applyAllResultExtensions function being introduced here - it existed ever since result extensions were introduced, just in the difference place under different name.

@greg0x
Copy link

greg0x commented Aug 30, 2023

thanks for the response!

are intended to work with nested read and writes ... If that's not the case - please, open a separate issue and share all reproduction steps.

That doesn't seem to be the case — although I am 1 version behind atm. I will create reproduction steps and open an issue when I get there.

You are incorrect about applyAllResultExtensions function being introduced here - it existed ever since result extensions were introduced, just in the difference place under different name.

Might be the case easily. Thanks for the clarification. I just checked the last PR that changed the relevant parts.

@greg0x
Copy link

greg0x commented Aug 31, 2023

@SevInf You have just updated your docs with this limitation https://github.com/prisma/docs/pull/5246/files

Does this mean that you are aware of the issue and no need to open a new issue from me?

@SevInf
Copy link
Contributor Author

SevInf commented Sep 1, 2023

@greg-nagy, no, I believe that doc change was incorrect, we are working on it.
I'd appreciate if we continued this conversation in a dedicated issue with a reproduction, rather than on unrelated closed PR.

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.

Client extensions: result extensions should be applied after query extensions

4 participants