Open Elijen opened 5 years ago
Is this expected behavior? The library was recommended by a Prisma team member as a solution to the need of manually defining resolvers for all relation fields (even to-one), but it does seem to generate these.
Model:
type User { id: ID! @unique name: String! assignedTasks: [Task!]! @relation(name: "UserAssignedTasks") createdTasks: [Task!]! @relation(name: "UserCreatedTasks") } type Task { id: ID! @unique title: String! assignedTo: User! @relation(name: "UserAssignedTasks") createdBy: User! @relation(name: "UserCreatedTasks") }
Query:
query MyTasks { myTasks { id title assignedTo { id name } } }
Query.myTasks resolver:
myTasks(parent, args, ctx: Context) { const id = getUserId(ctx); return ctx.prisma.tasks({ where: { assignedTo: { id } } }); }
Resolvers:
import { Query } from "./Query"; import { TaskResolvers, UserResolvers } from "../generated/graphqlgen"; export default { Query, User: UserResolvers.defaultResolvers, Task: TaskResolvers.defaultResolvers };
Query returns data successfully and includes the assignedTo field
Error is thrown:
Error: Cannot return null for non-nullable field Task.assignedTo.
Description
Is this expected behavior? The library was recommended by a Prisma team member as a solution to the need of manually defining resolvers for all relation fields (even to-one), but it does seem to generate these.
Steps to reproduce
Model:
Query:
Query.myTasks resolver:
Resolvers:
Expected results
Query returns data successfully and includes the assignedTo field
Actual results
Error is thrown:
Versions