Separate question.. I’m wrapping an external API w...
# prisma-whats-new
t
Separate question.. I’m wrapping an external API with a mutation resolver. The external API returns an array of objects. Doesn’t my resolver’s
schema.graphql
file need to define a type that reflects the API response? If so, I think I need 2 types: one that’s a list of the other. But apparently resolvers can only have one type 😕
Copy code
type TwilioPhoneNumberCapabilities {
  voice: Boolean
  SMS: Boolean
  MMS: Boolean
}

type TwilioPhoneNumber {
  friendly_name: String
  phone_number: String
  lata: String
  rate_center: String
  latitude: String
  longitude: String
  region: String
  postal_code: String
  iso_counry: String
  capabilities: TwilioPhoneNumberCapabilities
  beta: Boolean
}

type TwilioPhoneNumberList {
  uri: String
  available_phone_numbers: [TwilioPhoneNumber]
}

extend type Mutation {
  getAvailablePhoneNumbers(
    areaCode: String
  ): TwilioPhoneNumberList
}
b
Yeah, at the moment the schema extensions are quite basic - this issue (https://github.com/graphcool/framework/issues/743) is tracking it
a
The closest you can get is doing:
Copy code
extend type Mutation {
  getAvailablePhoneNumbers(
    areaCode: String
  ): [TwilioPhoneNumber]
}
and either split capabilities or make it a Json field
That way you can return and access most of the information
t
@agartha that looks perfect, thanks! I assume i can just leave out some of the fields I don’t need
a
Yes, you don't even have to change the returned value. Any fields not part of your payload type are automatically ignored
t
thanks
👍🏻 1