Skip to content

Commit 5bfd695

Browse files
committed
fix(redwood): fix incorrect error type thrown
1 parent 32c258c commit 5bfd695

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

packages/misc/redwood/src/graphql.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import { ForbiddenError } from '@redwoodjs/graphql-server';
1+
import { ForbiddenError, ValidationError } from '@redwoodjs/graphql-server';
22
import {
33
CrudFailureReason,
44
EnhancementOptions,
55
PrismaErrorCode,
6-
ValidationError,
76
enhance,
87
isPrismaClientKnownRequestError,
98
type AuthUser,
@@ -47,7 +46,7 @@ export function useZenStack<PrismaClient extends object>(
4746

4847
// Transforms ZenStack errors into appropriate RedwoodJS errors
4948
function transformError(error: unknown) {
50-
if (isPrismaClientKnownRequestError(error) && error.code === PrismaErrorCode.CONSTRAINED_FAILED) {
49+
if (isPrismaClientKnownRequestError(error) && error.code === PrismaErrorCode.CONSTRAINT_FAILED) {
5150
if (
5251
error.meta?.reason === CrudFailureReason.ACCESS_POLICY_VIOLATION ||
5352
error.meta?.reason === CrudFailureReason.RESULT_NOT_READABLE

packages/runtime/src/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export enum PrismaErrorCode {
4040
/**
4141
* A constraint failed on the database
4242
*/
43-
CONSTRAINED_FAILED = 'P2004',
43+
CONSTRAINT_FAILED = 'P2004',
4444

4545
/**
4646
* The required connected records were not found

packages/runtime/src/enhancements/policy/policy-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1215,7 +1215,7 @@ export class PolicyUtil extends QueryUtils {
12151215
reason?: CrudFailureReason,
12161216
zodErrors?: ZodError
12171217
) {
1218-
const args: any = { clientVersion: getVersion(), code: PrismaErrorCode.CONSTRAINED_FAILED, meta: {} };
1218+
const args: any = { clientVersion: getVersion(), code: PrismaErrorCode.CONSTRAINT_FAILED, meta: {} };
12191219
if (reason) {
12201220
args.meta.reason = reason;
12211221
}

0 commit comments

Comments
 (0)