我正在尝试在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}}信息。我必须设置错误吗?我错过了什么?
答案 0 :(得分:0)
您是否在查询中使用了类型( CreditCard 或 ACH )?