demonsters/prisma-mock

Use Prisma's Fluent Api

singerla opened this issue · 2 comments

I was wondering if it is somehow possible to use Prisma's Fluent Api.

While this works with prisma-mock:

client = createPrismaMock({}, Prisma.dmmf.datamodel);

await client.category.create({
  data: {
    id: 1,
    name: 'cat 1',
  },
});

await client.tag.create({
  data: {
    id: 1,
    name: 'tag 1',
    categoryId: 1,
  },
});

// Nested tags are returned properly: 
const tmp = await client.category.findUnique({
  where: {
    id: 1,
  },
  include: {
    tags: true,
  },
});

but this will throw ....findUnique(...).tags is not a function:

const tmp = await this.prisma.category.findUnique({
  where: {
    id: 1,
  },
}).tags();

Thanks in advance for an answer & thanks a lot for this very useful library!

Hi @singerla Thank you! That is a good question. Unfortunatly no it is indeed not yet supported.

Do you think this will be a good approach to mock fluent API? Would you suggest to implement this in prisma-mock at all?