1
votes

I have an API endpoint that returns the following data:

{
  "2017": {
      "May": [
           {},
           {}
       ],
       "June": []
   },
   "2018": {}
  }

How can I create a schema for those nested objects as it seems I cannot create nested objects in the schema.

I am using the typeDefinitions with graphql-tools which works well for objects and arrays of objects but I could not find a way to tackle this.

a typical type looks like:

type Venue { 
  name: String, 
  url: String, 
  streetAddress: String, 
  streetAddress2: String, 
  streetAddress3: String, 
  city: String, 
  postalCode: String, 
  country: String, 
  phoneNumber: String, 
  info: String 
}

and can be used in another type as follow:

type Event {
    title: String,
    subTitle: String,
    slug: String,
    venues: [Venue],
    ...
}

but I cannot do something like:

type Calendar {
    year: {
        month: [Event]
    }
}
1

1 Answers

0
votes

try to separate the nested objects:

type Year {
    month: [Event]
}    

type Calendar {
    year: Year
}