0

I am trying to use an interface in my schema. Here is the 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),
  })
});

When I go to my GraphiQL, I can see the paymentType and the fields that are in the interface, but I can't see the CreditCard or ACH information. I must have something set up wrong? What am I missing?

jhamm
  • 24,124
  • 39
  • 105
  • 179

1 Answers1

0

Are you using the type(CreditCard or ACH) on a query for example ?

Lafi
  • 1,310
  • 1
  • 15
  • 14
  • Is that normal that you're using both type and resolveType together on the export default ? – Lafi Jan 01 '18 at 01:49