0

我正在尝试interface在我的schema. 这是schema

export default new GraphQLObjectType({
  name: "Org",
  fields: () => ({
    name: {
      type: GraphQLString
    },
    paymentType: {
      type: PaymentType,
      resolveType: ({ isCreditCard }) => isCreditCard ? CreditCard : ACH
    }
});

export const PaymentType = new GraphQLInterfaceType({
  name: "PaymentType",
  fields: () => ({
    id: {
      type: new GraphQLNonNull(GraphQLID)
    },
    name: {
      type: new GraphQLNonNull(GraphQLString)
    },
    address: {
      type: new GraphQLNonNull(Address)
    }
  })
});

export const CreditCard = new GraphQLObjectType({
  name: "CreditCard",
  interfaces: [PaymentType],
  fields: () => ({
    number: new GraphQLNonNull(GraphQLInt),
  })
});

export const ACH = new GraphQLObjectType({
  name: "ACH",
  interfaces: [PaymentType],
  fields: () => ({
    routing: new GraphQLNonNull(GraphQLInt),
    accountNumber: new GraphQLNonNull(GraphQLInt),
  })
});

当我转到 myGraphiQL时,我可以看到 中的paymentType和 字段interface,但看不到CreditCardACH信息。我一定有什么设置错误?我错过了什么?

4

1 回答 1

0

例如,您是否在查询中使用类型(CreditCardACH)?

于 2018-01-01T01:11:26.323 回答