I am trying to create an object with a relationship.
I am using the auto generated amplify mutations
When I create an object without the relationship the operation succeeds. When I create an object with the relationship the operation fails.
The error message I get is
"The variables input contains a field name 'customer' that is not defined for input object type 'CreateCreditcardInput' "
The auto generated mutation is below.
export const createCreditcard = `mutation CreateCreditcard($input: CreateCreditcardInput!) {
createCreditcard(input: $input) {
id
number
expiration
customer {
id
firstName
lastName
phone
address1
address2
city
state
postcode
email
creditcards {
nextToken
}
}
payment {
id
paymentType
creditcard {
id
number
expiration
}
orderAmount
order {
id
date
orderStatus
}
}
}
}
`;
The solution was to change the property that contained the relationship ID from a nested object to a string.
The original that produced the error was
{id: "", number: 1212112, expiration: "12/20", customer: {id:"81d86584-e031-41db-9c20-e6d3c5b005a6"}}
The correction that now works is
{id: "", number: 1212112, expiration: "12/20", creditcardCustomerId: "81d86584-e031-41db-9c20-e6d3c5b005a6"}