【发布时间】:2020-01-02 05:17:16
【问题描述】:
我正在尝试复制我过去构建的 REST API,其中一个让我思考的部分是我的一个表是否有一组对象。例如,我有一个名为 Profile 的表,它包含数组 Experience 和 Education,它们严格位于 Profile 下,但也有自己的字段,但没有自己的表。
当我在 GraphQL 中添加字段时,我遇到了这个问题在体验/教育部分之前。我不确定这是否是正确的方法,或者是否有更好的方法。下面是我最终使用的一个 sn-p……查看管理页面,有为 Profile、Experience 和 Education 创建的表,这是预期的。但是有没有办法只拥有 Profile 并完成类似的事情?或者这更像是 GraphQL 的一种生活方式?
type Profile {
id: ID! @id
handle: String!
company: String
website: String
location: String
status: String!
githubUsername: String
experience: [Experience!] @relation(link: INLINE)
education: [Education!] @relation(link: INLINE)
}
type Experience {
id: ID! @id
title: String!
company: String!
}
type Education {
id: ID! @id
title: String!
company: String!
}
【问题讨论】:
-
这个问题确实是 Prisma 特有的。 GraphQL 本身并不关心存储层。
标签: graphql prisma prisma-graphql