在我的graphql-yoga
服务器上,我有一个类似的架构:
type Play {
id: ID!
frames: [Frame!]!
}
type Frame {
id: ID!
play: Play!
}
query {
play(playId: "myid") {
id
### The error occurs when I uncomment these lines:
# frames {
# id
# }
}
}
我有查询的解析器:
return await context.prisma.play({ id: args.playId })
我也有关系的解析器,例如:
const frames = async (root, args, context) => {
return await context.prisma.frames({ play: { id: root.id }})
}
运行带有注释行的查询时,它将按预期执行。当我添加关系时,我得到一个错误:
Error: Could not find argument play for type Frame
at server\node_modules\prisma-client-lib\dist\Client.js:248:31
at Array.forEach (<anonymous>)
at server\node_modules\prisma-client-lib\dist\Client.js:234:50
at Array.reduceRight (<anonymous>)
at Client.generateSelections (server\node_modules\prisma-client-lib\dist\Client.js:231:32)
at Client.<anonymous> (server\node_modules\prisma-client-lib\dist\Client.js:87:35)
at step (server\node_modules\prisma-client-lib\dist\Client.js:47:23)
at Object.next (server\node_modules\prisma-client-lib\dist\Client.js:28:53)
at server\node_modules\prisma-client-lib\dist\Client.js:22:71
at new Promise (<anonymous>)
我正在使用prisma-client-lib@1.18.1
,graphql-yoga@1.16.2
和graphql@0.13.0
答案 0 :(得分:3)
结果证明此错误在解析器中,尽管堆栈跟踪没有帮助。我改变了
const frames = async (root, args, context) => {
return await context.prisma.frames({ play: { id: root.id }})
}
收件人
const frames = async (root, args, context) => {
return await context.prisma.frames({ where: { play: { id: args.playId }}})
}