-
Notifications
You must be signed in to change notification settings - Fork 2k
Description
If you are short-curcuting query call, result extensions would also be skipped. For example:
prisma.$extends({
query: {
$allOperations({ query, args }) {
if (someCondition) return someMockedResponse
return query(args)
}
}
}).$extends({
result: {
someModel: {
computedField: { ...}
}
}
})Imagine they are two separate extensions, not aware of each other and someMockedResponse perfectly mimics DB response for particular query. From the standpoint of mocking extension, it does everything correctly. However, return value of query extension acts as final decider on what gets returned from the query. So, in case mocking condition holds true, someMockedResponse would act as one and final result of the query and result extension will get skipped. So, mocked response won’t contain computedField, unlike normal request.
Result extensions should apply only and always after all query extensions are done and should not be observable in any way from within query extension.