Skip to content

Is not working with @adminjs-prisma #27

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

Open
Kuro091 opened this issue Mar 13, 2024 · 6 comments
Open

Is not working with @adminjs-prisma #27

Kuro091 opened this issue Mar 13, 2024 · 6 comments

Comments

@Kuro091
Copy link

Kuro091 commented Mar 13, 2024

As per title. I'm trying to have the import export function working in a NestJS application

AdminModule.createAdminAsync({
      useFactory: async () => {
        const prisma = new PrismaService();

return {
          adminJsOptions: {
          resources: [{
              resource: {
                model: getModelByName('ContactSearch'),
                client: prisma,
              },
              options: {},
              features: [importExportFeature({
                new ComponentLoader()
              })]
            }]
        }
})

This did not work and I was referred to a broken link
image

@dziraf
Copy link
Contributor

dziraf commented Mar 13, 2024

              features: [importExportFeature({
                new ComponentLoader()
              })]

this is invalid configuration.

You have to setup one instance of ComponentLoader somewhere in your project, ideally in a separate file and import it. You're also missing componentLoader in AdminJS config.

import componentLoader from '../path/to/your/component-loader'

// ...

          adminJsOptions: {
          componentLoader,
          resources: [{
              resource: {
                model: getModelByName('ContactSearch'),
                client: prisma,
              },
              options: {},
              features: [importExportFeature({
                componentLoader,
              })]
            }]
        }

@Kuro091
Copy link
Author

Kuro091 commented Mar 13, 2024

Thanks for the quick response. As I mentioned I was using NestJs so that should only run once during its lifetime. The full code is as such
image

Let me try it in a separate file

@taksuparth
Copy link

taksuparth commented Oct 25, 2024

@dziraf tried with express server and @admin/prisma and facing the same issue. Can you please check? Also, I am using authenticate router.

@fl0-at
Copy link

fl0-at commented Apr 12, 2025

@Kuro091 did you ever find a solution for this? Facing the same issue trying to set up import/export functionality on a resource - I'm using express and prisma

@taksuparth
Copy link

This is not working in development environment but somehow works in production environment 🤭

@fl0-at
Copy link

fl0-at commented Apr 13, 2025

In case anyone else is struggling with this - I simply forgot to add the following lines of code to my code:

if (process.env.NODE_ENV === "development") { admin.watch(); } else { admin.initialize(); }

Basically, it was not working because without admin.watch() / admin.initialize(), no bundling was happening.

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

4 participants