我被迷惑了。我最初创建了用户查询,它给了我错误,我认为是语法错误。但后来我创建了一个相同的车辆查询,效果非常好。我怀疑这和ID有关!类型,但我已经没有线索了。任何帮助,将不胜感激!
这是我的类型定义和解析器。
//类型定义//
type User {
id: ID!
fname: String
lname: String
email: String
password: String
vehicles: [Vehicle]
}
type Vehicle {
id: ID!
vin: String
model: String
make: String
drivers: [User]
}
type Query {
users: [User]
user(id: ID!): User
vehicles: [Vehicle]
vehicle(vin: String): Vehicle
}
Run Code Online (Sandbox Code Playgroud)
//解析器//
user: async (parent, args, context) => {
const { id } = args
return context.prisma.user.findUnique({
where: {
id,
},
})
},
vehicle: async (parent, args, context) => { …Run Code Online (Sandbox Code Playgroud)