我正在尝试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
,但看不到CreditCard
或ACH
信息。我一定有什么设置错误?我错过了什么?