Omar Harras
11/11/2020, 11:08 PM// query
query {
allAlbums {
name
artist {
id
lastName
}
}
}
// schema
model Artist {
id String @id @default(cuid())
firstName String
lastName String
stageName String
cover String
age Int?
biography String?
song Song[]
album Album[]
}
model Album {
id String @id @default(cuid())
name String
cover String
genre Genre? @default(POP)
artistId String?
artist Artist? @relation(fields: [artistId], references: [id])
}
the query returns a list of albums but Artist is null, knowing that I have the artistId in the albums table in db…
anyone can help please ?Daniel Ughelli
11/11/2020, 11:22 PMRyan
11/12/2020, 7:05 AMOmar Harras
11/12/2020, 8:57 AMallAlbums
query :
allAlbums: async (parent, args, contect) => {
const albums = await contect.Prisma.album.findMany();
return albums;
},
Am i missing something ?Ryan
11/12/2020, 9:52 AMartist
?Omar Harras
11/12/2020, 11:04 AMRyan
11/12/2020, 11:14 AMallAlbums: async (parent, args, contect) => {
const albums = await contect.Prisma.album.findMany({ include: { artist: true } });
return albums;
},
Omar Harras
11/12/2020, 6:32 PM