1

在我的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.1graphql-yoga@1.16.2并且graphql@0.13.0

4

1 回答 1

4

事实证明,这个错误在解析器中,尽管堆栈跟踪没有帮助。我变了

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 }}})
}
于 2018-10-19T02:43:30.233 回答