我的类型中有一个profilePicture
字段User
被返回为 null,即使我可以看到数据库中有数据。我有以下设置:
// datamodel.prisma
enum ContentType {
IMAGE
VIDEO
}
type Content @embedded {
type: ContentType! @default(value: IMAGE)
url: String
publicId: String
}
type User {
id: ID! @id
name: String
username: String! @unique
profilePicture: Content
website: String
bio: String
email: String! @unique
phoneNumber: Int
gender: Gender! @default(value: NOTSPECIFIED)
following: [User!]! @relation(name: "Following", link: INLINE)
followers: [User!]! @relation(name: "Followers", link: INLINE)
likes: [Like!]! @relation(name: "UserLikes")
comments: [Comment!]! @relation(name: "UserComments")
password: String!
resetToken: String
resetTokenExpiry: String
posts: [Post!]! @relation(name: "Posts")
verified: Boolean! @default(value: false)
permissions: [Permission!]! @default(value: USER)
createdAt: DateTime! @createdAt
updatedAt: DateTime! @updatedAt
}
// schema.graphql
type User {
id: ID!
name: String!
username: String!
profilePicture: Content
website: String
bio: String
email: String!
phoneNumber: Int
gender: Gender!
following: [User!]!
followers: [User!]!
verified: Boolean
posts: [Post!]!
likes: [Like!]!
comments: [Comment!]!
permissions: [Permission!]!
}
就像我说的数据库中有数据但是当我在 Playground 中运行以下查询时,我得到null
:
// query
{
user(id: "5c8e5fb424aa9a000767c6c0") {
profilePicture {
url
}
}
}
// response
{
"data": {
"user": {
"profilePicture": null
}
}
}
知道为什么吗?
ctx.prisma.user(({ id }), info);
即使profilePicture
该字段存在于generated/prisma.graphql