Amplify自动为删除生成突变,如下所示:
export const deleteTodo = /* GraphQL */ `
mutation DeleteTodo($input: DeleteTodoInput!) {
deleteTodo(input: $input) {
index
body
hasRead
}
这就是我在App.js中的称呼方式
await API.graphql(graphqlOperation(mutations.deleteTodo, {input: result}));
它返回这样的错误。似乎数据尚未传递
message: "The variables input contains a field name 'index' that is not defined for input object type 'DeleteTodoInput' "
答案 0 :(得分:0)
我不确定result
是什么,但是您可以尝试:
const result = {
index: 1,
body: 'blabla',
hasRead: true,
}
await API.graphql(graphqlOperation(mutations.deleteTodo, {input: { ...result }}));