paljs / prisma-tools

Prisma tools to help you generate CRUD system for GraphQL servers
https://paljs.com
MIT License
684 stars 54 forks source link

Delete - Cannot read property 'find' of undefined. #103

Closed danhollick closed 4 years ago

danhollick commented 4 years ago

When using the Delete package I get the following error. Cannot read property 'find' of undefined.

My code looks like this:

    const prismaDelete = new PrismaDelete(
      context.prisma,
      path.join(process.cwd(), 'backend', 'prisma', 'schema.prisma')
    )
    await prismaDelete.onDelete({
      model: 'Invoice',
      where: { invoiceId: { in: id } },
    })

I think it' coming from this line:

    return this.schema.models.find((item) => item.name === modelName);

I think the problem is that PrismaDelete expects the schema to be of type SchemaObject from your prisma-tools/select package but I can't see anywhere that the schema is being parsed into that format? Am I missing something?

The docs also don't mention anything about needing to do that manually.

AhmedElywa commented 4 years ago

Sorry for this confusing I updated my tool to get schema as an object because converting .prisma file every request takes a long time and slow our server. I just updated docs please take look here https://prisma-tools.ahmedelywa.com/delete/

danhollick commented 4 years ago

Okay cool. Might be nice for it fail with an error message in the future, especially because it depends on another package.