如何在 Express-GraphQL 中实现接口或联合

问题描述

我正在使用 express-graphql 并且我正在尝试实现接口,例如 herehere。但是,我不知道如何实现这些,因为人们使用的符号与我在 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 (将#修改为@)