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

Javascript 如何在Express GraphQL中实现接口或联合,javascript,node.js,graphql,graphql-js,express-graphql,Javascript,Node.js,Graphql,Graphql Js,Express Graphql,我正在使用expressgraphql,我正在尝试实现接口,比如和。然而,我不知道如何实现这些,因为人们使用的符号与我在nodejs中使用的符号完全不同 例如,在第二个答案中,有人写道: type Query { blocks: [ ContentBlock! ]! } type Video implements ContentBlock { id: ID! url: String! } type Quote implements ContentBlock { id: ID!

我正在使用
expressgraphql
,我正在尝试实现接口,比如和。然而,我不知道如何实现这些,因为人们使用的符号与我在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!
}
我自己在
expressgraphql
中的定义看起来更像这样:

const Quote = new GraphQLObjectType({
  name: "Quote",
  fields: () => ({
    id: { type: GraphQLID },
    body: { type: GraphQLString },
    author: { type: GraphQLString },
  }),
});

有人能帮帮我吗?我还想知道在哪里可以找到这些信息。我查看了,但找不到任何解释如何进行接口或联合的内容。

schema first ve code first。。。你正在使用。您只需创建一个
GraphQLInterfaceType
GraphQLUnionType