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

clientModule occurs error #46

Open
ydhn opened this issue Sep 18, 2023 · 2 comments
Open

clientModule occurs error #46

ydhn opened this issue Sep 18, 2023 · 2 comments

Comments

@ydhn
Copy link
Contributor

ydhn commented Sep 18, 2023

TypeError: Invalid enum value: length
    at Object.get  /dist/generated/backend/client/runtime/library.js:129:966)
    at isArrayLike  /node_modules/lodash/isArrayLike.js:30:42)
    at keysIn  /node_modules/lodash/keysIn.js:29:10)
    at /node_modules/lodash/_createBaseFor.js:12:17
    at baseMerge  /node_modules/lodash/_baseMerge.js:24:3)
    at baseMergeDeep  /node_modules/lodash/_baseMergeDeep.js:88:5)
    at /node_modules/lodash/_baseMerge.js:27:7
    at /node_modules/lodash/_createBaseFor.js:17:11
    at baseMerge  /node_modules/lodash/_baseMerge.js:24:3)
    at baseMergeDeep  /node_modules/lodash/_baseMergeDeep.js:88:5)
    at /node_modules/lodash/_baseMerge.js:27:7
    at /node_modules/lodash/_createBaseFor.js:17:11
    at baseMerge  /node_modules/lodash/_baseMerge.js:24:3)
    at baseMergeDeep  /node_modules/lodash/_baseMergeDeep.js:88:5)
    at /node_modules/lodash/_baseMerge.js:27:7
    at /node_modules/lodash/_createBaseFor.js:17:11
    at baseMerge  /node_modules/lodash/_baseMerge.js:24:3)
    at baseMergeDeep  /node_modules/lodash/_baseMergeDeep.js:88:5)
    at /node_modules/lodash/_baseMerge.js:27:7
    at /node_modules/lodash/_createBaseFor.js:17:11
    at baseMerge  /node_modules/lodash/_baseMerge.js:24:3)
    at baseMergeDeep  /node_modules/lodash/_baseMergeDeep.js:88:5)
    at /node_modules/lodash/_baseMerge.js:27:7
    at /node_modules/lodash/_createBaseFor.js:17:11
    at baseMerge  /node_modules/lodash/_baseMerge.js:24:3)
    at baseMergeDeep  /node_modules/lodash/_baseMergeDeep.js:88:5)
    at /node_modules/lodash/_baseMerge.js:27:7
    at /node_modules/lodash/_createBaseFor.js:17:11
    at baseMerge  /node_modules/lodash/_baseMerge.js:24:3)
    at /node_modules/lodash/merge.js:36:3
    at /node_modules/lodash/_createAssigner.js:30:9
    at apply  /node_modules/lodash/_apply.js:15:25)
    at /node_modules/lodash/_overRest.js:32:12
    at new AdminJS (file:/ /node_modules/adminjs/lib/adminjs.js:72:20)

I tried to use clientModule (Custom Prisma Client) but if so, errors occured in this line:
https://github.com/SoftwareBrothers/adminjs/blob/8b7c19e/src/adminjs.ts#L114

I think some miscellaneous things in the Prisma module is not properly handled by the lodash merge.
What I found to workaround is not trying to do like README instructed:

// Not working
{
  resource: { 
    model: getModelByName('Profile', PrismaModule), 
    client: prisma, 
    clientModule: PrismaModule,
  },
}

but this:

// Working
{
  resource: { 
    model: getModelByName('Profile', { Prisma: { dmmf: PrismaModule.Prisma.dmmf } }), 
    client: prisma, 
    clientModule: { Prisma: { dmmf: PrismaModule.Prisma.dmmf } } 
  },
}

I think clientModule should not include everything Prisma gives. I can write a PR to rewrite from clientModule to customDmmf. What do maintainers think?

@hlab-pawat
Copy link

I got the same issue. The provided workaround saves my time. Thank you @ydhn

@iminif
Copy link

iminif commented Sep 21, 2024

@ydhn Great job! Thanks very much!

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

No branches or pull requests

3 participants