I'm building a Graphql schema to mutate/query restaurants and trying to store the opening times in a nested object.
The structure should look as follows:
[
{
monday: { open: restaurant.Open_Monday, close: restaurant.Close_Monday }
},
{
tuesday: { open: restaurant.Open_Tuesday, close: restaurant.Close_Tuesday }
},
{
wednesday: { open: restaurant.Open_Wednesday, close: restaurant.Close_Wednesday }
},
{
thursday: { open: restaurant.Open_Thursday, close: restaurant.Close_Thursday }
},
{
friday: { open: restaurant.Open_Friday, close: restaurant.Close_Friday }
},
{
saturday: { open: restaurant.Open_Saturday, close: restaurant.Close_Saturday }
},
{
sunday: { open: restaurant.Open_Sunday, close: restaurant.Close_Sunday }
},
]
The restaurant variable contains the values of the opening hours that I', formatting before sending them to the API and storing them.
My Graphql schema looks as follows:
input RestaurantInput {
key: Int!
name: String!
image: String!
telNumber: String!
bookingNumber: String
address1: String!
address2: String
suburb: String!
province: String!
postalCode: String
days: [DayInput]
cuisine: String
exclusions: String
restrictions: String
breakfast: String
lunch: String
supper: String
longitude: String
latitude: String
}
input DayInput {
monday: [TimeInput]
tuesday: [TimeInput]
wednesday: [TimeInput]
tursday: [TimeInput]
friday: [TimeInput]
saturday: [TimeInput]
sunday: [TimeInput]
}
input TimeInput {
open: String
close: String
}
When I hit that API endpoint I get the following error message:
Expected type [DayInput], found "[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]".
I'm not sure whether my call is incorrectly formatted or whether I'm making a mistake in the schema itself. I'm still rather new to Graphql and stuck on this.