Prisma queryType Property 'id' does not exist on type '{}'. #959
|
I am trying to use the code in the example: https://pothos-graphql.dev/docs/plugins/prisma#example builder.queryType({
fields: (t) => ({
// Define a field that issues an optimized prisma query
me: t.prismaField({
type: 'User',
resolve: async (query, root, args, ctx, info) =>
prisma.user.findUniqueOrThrow({
// the `query` argument will add in `include`s or `select`s to
// resolve as much of the request in a single query as possible
...query,
where: { id: ctx.userId },
}),
}),
}),
});I am getting the error with the code: import { builder } from "../builder"
import prisma from "../../../prisma/prisma"
builder.prismaObject("md_comics", {
name: "comic",
fields: t => ({
id: t.exposeID("id"),
title: t.exposeString("title")
})
})
builder.queryType({
fields: t => ({
comics: t.prismaField({
type: "md_comics",
resolve: async (query, root, args, ctx, info) =>
prisma.md_comics.findUniqueOrThrow({
...query,
where: { id: ctx.id } // Property 'id' does not exist on type '{}'.
})
})
})
})I don't know how to solve it 🤔 |
Answered by
hayes
Jul 18, 2023
Replies: 1 comment 4 replies
|
I find out I need to pass the type manually. builder.queryType({
fields: t => ({
comics: t.prismaField({
type: "md_comics",
resolve: async (
query,
root,
args,
ctx: Prisma.md_comicsWhereUniqueInput,
info
) =>
prisma.md_comics.findUniqueOrThrow({
...query,
where: { id: ctx.id }
})
})
})
}) |
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

you would generally need to configure your context type when setting up the builder
eg:
This context type should match whatever context type you create in your server