我是GraphQL的新手,从事AWS AppSync并使用POSTMAN进行测试
我创建了API,并且能够运行createMutation和List查询
这是我的模式
input CreateUserInput {
id: ID!
name: String!
gender: String!
email: String!
password: String!
}
input DeleteUserInput {
id: ID!
name: String!
}
type Mutation {
createUser(input: CreateUserInput!): User
updateUser(input: UpdateUserInput!): User
deleteUser(input: DeleteUserInput!): User
}
input UpdateUserInput {
id: ID!
name: String!
gender: String
email: String
password: String
}
type User {
id: ID!
name: String!
gender: String!
email: String!
password: String!
}
以下在POSTMAN中的工作原理:
查询:
mutation createUser($createuserinput: CreateUserInput!) {
createUser(input: $createuserinput) {
id
name
gender
email
password
}
}
变量
{
"createuserinput": {
"id": "AAAUzF6XsJUCJ7tJw0NREODencTOp6wES",
"name": "Somename",
"gender": "male",
"email": "some@email",
"password": "12345"
}
}
以下操作无效
查询
mutation updateUser($updateuserinput: UpdateUserInput!) {
updateUser(input: $updateuserinput) {
id
name
gender
email
password
}
}
变量
{
"updateuserinput": {
"id": "AAAUzF6XsJUCJ7tJw0NREODencTOp6wES",
"name": "Somename2",
"gender": "male",
"email": "some@email2",
"password": "123456"
}
}
我得到了错误:
{
"data": {
"updateUser": null
},
"errors": [
{
"path": [
"updateUser"
],
"data": null,
"errorType": "DynamoDB:ConditionalCheckFailedException",
"errorInfo": null,
"locations": [
{
"line": 2,
"column": 3,
"sourceName": null
}
],
"message": "The conditional request failed (Service: AmazonDynamoDBv2; Status Code: 400; Error Code: ConditionalCheckFailedException; Request ID: MG0N1EP32Q7D946OU4JODOQHH7VV4KQNSO5AEMVJF66Q9ASUAAJG)"
}
]
}
我认为该ID未正确传递。我在这里做什么错了?
答案 0 :(得分:1)
我找到了问题。
在变异更新和删除中,名称被标记为必填。我还必须传递名称才能更新/删除。
示例:
data = [[
1 2 3
4 5 6
7 8 9
2 3 4
5 7 8
9 1 2
]]
--------------------------------------------------------------------------------
local cc = table.concat
--------------------------------------------------------------------------------
function save_csv(filenumber,t)
io.open(filenumber .. '.csv','w'):write(cc(t,'\n')):close()
end
--------------------------------------------------------------------------------
local filenumber = 1
local ans = {}
for line in (data..'\n'):gmatch '(.-)\n' do
local s = {}
for item in line:gmatch '%d+' do s[#s+1] = item end
if #s > 0 then
ans[#ans+1] = cc(s,',')
elseif #ans > 0 then
save_csv(filenumber,ans)
filenumber = filenumber + 1
ans = {}
end
end
在创建模型时选择名称作为排序键时发生了这种情况