P
Prisma6mo ago
MatG13

Main .prisma file location with new prismaSchemaFolder feature (+ Bazel)

I'm applying some changes by splitting the main file into smaller pieces, thanks to this new cool feature. Anyway, as we are using BAZEL and a custom generator, I need to tell BAZEL build rules file where to locate the file which has all the models, and If I keep It like It was just aiming to the schema.prisma file, It will log several errors not finding the models: (As It is taking the schema.prisma raw directly from the folder). I can't seem to find the location (If that's how It works) where a single schema.prisma file is located having all the .prisma files of /schema folder. For now I managed to make it work concatenating all files through a script but I think there should be another way Sample of error If using the main schema.prisma:
error: Type "TicketRecord" is neither a built-in type, nor refers to another model, composite type, or enum.
--> schema/schema.prisma:1427
|
1426 | Assets AssetRecord[]
1427 | ticket TicketRecord @relation(fields: [ticketId], references: [tickerId])
|
error: Type "TicketRecord" is neither a built-in type, nor refers to another model, composite type, or enum.
--> schema/schema.prisma:1480
|
1479 |
1480 | ticket TicketRecord @relation(fields: [ticketId], references: [ticketId], onUpdate: Restrict, map: "system__ticket_assets_foreign_key")
error: Type "TicketRecord" is neither a built-in type, nor refers to another model, composite type, or enum.
--> schema/schema.prisma:1427
|
1426 | Assets AssetRecord[]
1427 | ticket TicketRecord @relation(fields: [ticketId], references: [tickerId])
|
error: Type "TicketRecord" is neither a built-in type, nor refers to another model, composite type, or enum.
--> schema/schema.prisma:1480
|
1479 |
1480 | ticket TicketRecord @relation(fields: [ticketId], references: [ticketId], onUpdate: Restrict, map: "system__ticket_assets_foreign_key")
It's currently working with this bazel genrule, but It seems hard-coded as I think there might be a single file already created by prisma where all the .prisma files are combined (?)
genrule(
name = "combine_prisma_schemas",
srcs = glob(["schema/*.prisma"]),
outs = ["schema.prisma"],
cmd = """
cat $(SRCS) > $@
""",
)
genrule(
name = "combine_prisma_schemas",
srcs = glob(["schema/*.prisma"]),
outs = ["schema.prisma"],
cmd = """
cat $(SRCS) > $@
""",
)
Solution:
Solved - Importing all files on schema folder in BUILD.bazel instead of just the schema.prisma, and then change command to generate --schema schema folder, worked just fine. No need to make bazel create a single file, prisma manages the folder correctly.
Jump to solution
1 Reply
Solution
MatG13
MatG136mo ago
Solved - Importing all files on schema folder in BUILD.bazel instead of just the schema.prisma, and then change command to generate --schema schema folder, worked just fine. No need to make bazel create a single file, prisma manages the folder correctly.
Want results from more Discord servers?
Add your server