如何解决如何在 Express-GraphQL 中实现接口或联合
我正在使用 express-graphql
并且我正在尝试实现接口,例如 here 和 here。但是,我不知道如何实现这些,因为人们使用的符号与我在 nodejs 中使用的完全不同。
例如,在第二个答案中,有人写道:
type Query {
blocks: [ ContentBlock! ]!
}
type Video implements ContentBlock {
id: ID!
url: String!
}
type Quote implements ContentBlock {
id: ID!
body: String!
author: String
}
type Advertisement implements ContentBlock {
id: ID!
src: String!
backgroundColor: String
}
interface ContentBlock {
id: ID!
}
我自己在 express-graphql
中的定义看起来更像这样:
const Quote = new GraphQLObjectType({
name: "Quote",fields: () => ({
id: { type: GraphQLID },body: { type: GraphQLString },author: { type: GraphQLString },}),});
有人可以帮我吗?我也想知道一般在哪里可以找到这些信息。我查看了 documentation of express-graphql on github,但找不到任何解释如何执行接口或联合的内容。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。