I have created this GraphQL schema and passed it to AppSync via Amplify:
type Member @model {
id: ID!
name: String!
}
type Team @model {
id: ID!
title: String!
members: [Member]
}
and AWS Amplify has generated the following mutation for team update:
export const updateTeam = /* GraphQL */ `
mutation UpdateTeam(
$input: UpdateTeamInput!
$condition: ModelTeamConditionInput
) {
updateTeam(input: $input, condition: $condition) {
id
name
...
}
}
`;
I'm wanting to update the Team via:
const doSomething = async (id) => {
try {
const team = teams[id];
team.title = // new title
// cut off automatically added bits
const teamData = await API.graphql(
graphqlOperation(updateTeam, { input: team })
);
} catch (error) {
console.error(`Mutation failed`, error);
}
};
I am reading the team
successfully and I can see that members
is a part of the team object. However, it raises an error:
message: "The variables input contains a field name 'members' that is not defined for input object type 'UpdateTeamInput' "
Where and how should I fix this? I mean do I have to go with something like:
...
graphqlOperation(updateTeam, { input: team, members: team.members })
...
although I'm not touching the members
object in team[id]
?