I'm not able to update the existing data on AWS Graphql API. Here are my files.
Schema
type PersonalInfo @model @auth(rules: [{allow: private}]) {
id: ID!
firstName: String!
middleName: String
lastName: String!
dateOfBirth: String!
primaryLanguage: String!
countryOfBirth: String!
gender: String!
maritalStatus: String!
}
mutation
export const updatePersonalInfo = /* GraphQL */ `
mutation UpdatePersonalInfo(
$input: UpdatePersonalInfoInput!
$condition: ModelPersonalInfoConditionInput
) {
updatePersonalInfo(input: $input, condition: $condition) {
id
firstName
middleName
lastName
dateOfBirth
primaryLanguage
countryOfBirth
gender
maritalStatus
createdAt
updatedAt
_version
_deleted
_lastChangedAt
}
}
`;
My update function
const currentUser = await Auth.currentAuthenticatedUser();
try {
const result = await API.graphql({
query: updatePersonalInfo,
variables: {
input: {
id: currentUser.attributes.sub,
firstName: data.firstName,
middleName: data.middleName,
lastName: data.lastName,
dateOfBirth: data.dateOfBirth,
primaryLanguage: data.primaryLanguage,
countryOfBirth: data.countryOfBirth,
gender: data.gender,
maritalStatus: data.maritalStatus
}
}
});
I'm able to create a new model, but not able to update it. From network tab I see that I send the new first name for example but in the successful response but with the previous name that was on dataStore.
I'm new to AWS Amplify, any help would be appreciated.
Response Preview: