Reputation: 3831
In my graphql-yoga
server I have a schema like this:
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
# }
}
}
I have resolvers for the query:
return await context.prisma.play({ id: args.playId })
I also have resolvers for the relationships, e.g.:
const frames = async (root, args, context) => {
return await context.prisma.frames({ play: { id: root.id }})
}
When I run the query with the lines commented out it executes as expected. When I add in the relationship I get an error:
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>)
I'm using [email protected]
, [email protected]
and [email protected]
Upvotes: 1
Views: 1226
Reputation: 3831
Turns out that this error was in the resolver, although the stack trace was unhelpful. I changed
const frames = async (root, args, context) => {
return await context.prisma.frames({ play: { id: root.id }})
}
To
const frames = async (root, args, context) => {
return await context.prisma.frames({ where: { play: { id: args.playId }}})
}
Upvotes: 4