環境
- NodeJS
- ローカル環境
- AWSAppSyncClient利用
事象
AWSAppSyncClient.mutate実行時に掲題のエラーが出る。
原因
GraphQLのmutation queryの引数名が一致していなかった。
対応
- input, conditionの文言は変えないで統一
- graphql側のinput, conditionという引数名は統一
- NodeJS(呼び出し側)のinput, conditionも統一
対応後のイメージ
type Mutation {
updateHoge(input: UpdateHogeInput!,
condition: ModelHogeConditionInput): Hoge
@aws_api_key @aws_iam @aws_cognito_user_pools
}
const updateHoge =/* GraphQL */ `mutation Hoge(
$condition: ModelHogeConditionInput
$input: UpdateHogeInput!
){
updateHoge(condition: $condition,
input: $input){
id
}
}
`
async function disableHoge(updateHogeInput: UpdateHogeInput, updateTargetFieldValue:any) {
return await client.mutate<Hoge>({
mutation: gql(updateHoge),
variables: {
condition: {
hogehoge: {eq: updateHogeInput.hogehoge} as ModelStringInput
},
input: {
...updateHogeInput,
updateTargetField: updateTargetFieldValue
}
}
})
}