为什么GraphiQL不能自动完成/查找我的界面字段?

时间:2017-12-29 02:03:24

标签: graphql graphiql

我正在尝试在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),
  })
});

当我转到GraphiQL时,我可以看到paymentType以及interface中的字段,但我看不到CreditCard或{ {1}}信息。我必须设置错误吗?我错过了什么?

1 个答案:

答案 0 :(得分:0)

您是否在查询中使用了类型( CreditCard ACH )?

相关问题