I have 2 (hopefully newbie) questions that I need input on, from the community:
(1) I have made changes to my application's schema.graphql file. How do i ensure that the corresponding queries.js, mutations.js, subscriptions.js files are updated? Previously these used to get updated(I think) when I ran the amplify push command but now they no longer do.
(2) How would I do a partial mutation using aws amplify? eg: if a mutation has fullName, city, how would i update fullName without passing city from the frontend application? I could be editing fullname in the first screen and city in second screen. If I do not pass city in the first screen's mutation, it gets overwritten to null.
Here's how the mutation looks like:
mutations.js:
const updateUserProfile =
mutation UpdateUserProfile(
$input: UpdateUserProfileInput!
$condition: ModelUserProfileConditionInput
) {
updateUserProfile(input: $input, condition: $condition) {
id
fullName
city
createdAt
updatedAt
owner
}
}
;
userprofile.vue
import { Auth } from 'aws-amplify';
import { createUserProfile, updateUserProfile} from '@/graphql/mutations';
const userProfileInput={
id:userId,
fullName:'Ajit Goel',
};
await API.graphql(graphqlOperation(updateUserProfile, {input: userProfileInput}));
schema.graphql:
type UserProfile @model
@key(fields:["id"])
@auth(rules: [{allow: owner}])
{
id: String!
fullName: String
city:String
}
Error in console when update mutation is run: