The general structure of my schema is this:
- A routine can have multiple days.
- A day can have multiple exercises.
I have a GraphQL mutation generated by the AWS Amplify CLI.
The mutation looks like this:
export const createRoutine = /* GraphQL */ `
mutation CreateRoutine(
$input: CreateRoutineInput!
$condition: ModelRoutineConditionInput
) {
createRoutine(input: $input, condition: $condition) {
id
name
description
days {
items {
id
routineID
name
description
exercises {
items {
id
dayID
name
description
reps
sets
}
}
}
}
}
}
`;
When I go to make a GraphQL mutation like this:
const inp = {
id: id,
name: "Test Routine Dynamic",
description: "Description for TRD",
days: {
items: {
id: id,
routineID: id,
name: "Day 1 of TRD",
description: "Description for Day 1 of TRD",
exercises: {
items: {
id: id,
dayID: id,
name: "Bench Press",
description: "Push the bar",
reps: "3",
sets: "5",
},
},
},
},
I get an error from my IDE saying: Object literal may only specify known properties, and 'days' does not exist in type
Because the type of input is CreateRoutineInput which looks like this:
export type CreateRoutineInput = {
id?: string | null,
name: string,
description?: string | null,
};
Why does the generated type of CreateRoutineInput not allow me to specify the nested items "Days"? I am a bit new to GraphQL so maybe this is something that is not meant to be done.
Would really appreciate any help, thanks.
