-
Hey again! I'm wondering what I'm missing when using an explicit many-to-many relation because the resolver function returns an array but the defined type is just This is my code: builder.prismaObject('UsersOnProjects', {
findUnique: (userOnProject) => ({
projectId_userId: {
projectId: userOnProject.projectId,
userId: userOnProject.userId
}
}),
fields: (t) => ({
project: t.relation('project')
})
})
builder.queryType({
fields: (t) => ({
projectsOfCurrentUser: t.prismaField({
type: 'UsersOnProjects',
authScopes: {
isAuthenticated: true
},
// TS error: Type 'Promise<UsersOnProjects[]>' is not assignable to type 'Promise<UsersOnProjects>'.
resolve: async (query, _root, _args, { request }) => {
const uid = await getUid(request)
return prisma.usersOnProjects.findMany({
...query,
where: { userId: uid }
})
}
})
})
}) Looks like I've missed something from the docs like defining it as a list but I can't find the problem here. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I've found that the docs use const UsersOnProjects = builder.prismaObject('UsersOnProjects', {
// ...
}) Is this correct because |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
type: ['UsersOnProjects']
should work