私はシンプルなprisma.schema
⸺</p>
を持っています
model Joke {
id String @default(cuid()) @id
author Author
content String @unique
}
model Author {
id String @default(cuid()) @id
name String
jokes Joke[]
}
そしてこれが私のQuery
⸺</p>
t.list.field('getJokeByAuthor', {
type: 'Joke',
args: {
name: stringArg(),
},
resolve: (_, {name}, ctx) => {
return ctx.photon.authors.findMany({
where: {
name,
},
select: {
jokes: true,
},
});
// return ctx.photon.jokes.findMany({
// where: {
// author: {
// name,
// },
// },
// });
},
});
コメントされたものは機能しますが、コメントされていないものは機能せず、エラーが発生します"Cannot return null for non-nullable field Joke.id."
。なんで?を呼び出して、特定の作者のジョークにアクセスしたいctx.photon.authors
。どうすればそれを達成できますか?
また、getJokeByAuthor
の戻り値の型は[Joke]
? それはどこで得られますか?[Author]
帰るのは今じゃないのctx.photon.authors
?