menu

Prisma

🔴 The Prisma Spectrum community is not officially managed by Prisma's support team any more. Please seek help on GitHub or on Slack instead. Learn more: https://spectrum.chat/prisma/general/where-and-how-to-best-seek-help-with-questions-problems~687a1b8f-8658-4df3-8849-ea5ab3503f28

Channels
Chat
view-forward
# All channels
view-forward
# General
view-forward
# Beta
view-forward
# Community
view-forward
# GraphQL
view-forward
# OSS
view-forward
# Random
view-forward
Team

Retrieving many to many with additional Fields.

April 20, 2020 at 9:16pm

Retrieving many to many with additional Fields.

April 20, 2020 at 9:16pm
Hey just have you came across situation that you have many to many relationship with additonal fields? This is my schema:
model Medicine { id Int (autoincrement()) name String }
model ActiveSubstance { id Int (autoincrement()) name String }
model MedicineActiveSubstance { id Int (autoincrement()) medicine Medicine (fields: [medicineId], references: [id]) medicineId Int activeSubstance ActiveSubstance (fields: [activeSubstanceId], references: [id]) activeSubstanceId Int amountOfActiveSubstance Int }
this is my nexus:
export const Medicine = objectType({ name: 'Medicine', definition(t) { t.model.id() t.model.name() }, })
export const ActiveSubstance = objectType({ name: 'ActiveSubstance', definition(t) { t.model.id() t.model.name() }, })
I can add t.model.medicineActiveSubstances (to activeSubstances) and t.model.medicineActiveSubstances (to medicines). But this causes an error when I try to add type to it: "ERROR: No subset types are available. Please make sure that one of your GraphQL type is a subset of your t.model('<ModelName>')",
How do I retrieve medicine with all ActiveSubstances on it??
No messages yet