My GraphQL Schema is as follows:
type Change_log {
id:Int @id
op_user_no: Int64 @search(by: [int64])
op_time: DateTime @search(by: [hour])
op_content_text: String @search(by: [fulltext])
ref_log_id: [change_log] @hasInverse(field: ref_log_id)
op_type: Int
}
I use GraphQL to add data, GraphQL is as follows:
mutation {
addChange_log(input: [{
id: 1
op_user_no: 123
op_time: "2022-05-26T16:05:45Z"
op_content_text: "test"
op_type: 1
ref_log_id: [{
id: 0
}
]
}
], upsert: true) {
numUids
}
}
All data in Type is associated with the data whose id is 0.
When I use multi-threading to execute GraphQL on the data, some data can be inserted normally, and some data are inserted abnormally. The exception information is as follows:
{
"errors": [{
"message": "mutation addChange_log failed because Dgraph execution failed because Input for predicate \"addChange_log.ref_log_id\" of type scalar is uid. Edge: entity:84293879 attr:\"\\000\\000\\000\\000\\000\\000\\000\\000addChange_log.ref_log_id\" value_type:UID value_id:84293878 ",
"locations": [{
"line": 2,
"column": 2
}
],
"path": ["addChange_log"]
}
],
"data": {
"addChange_log": null
},
"extensions": {
"touched_uids": 2,
"tracing": {
"version": 1,
"startTime": "2022-05-26T08:51:04.351495399Z",
"endTime": "2022-05-26T08:51:04.35609656Z",
"duration": 4601172,
"execution": {
"resolvers": [{
"path": ["addChange_log"],
"parentType": "Mutation",
"fieldName": "addChange_log",
"returnType": "AddChange_logPayload",
"startOffset": 186319,
"duration": 4406580,
"dgraph": [{
"label": "preMutationQuery",
"startOffset": 251187,
"duration": 1667669
}, {
"label": "mutation",
"startOffset": 2048529,
"duration": 0
}, {
"label": "query",
"startOffset": 0,
"duration": 0
}
]
}
]
}
}
}
}
But I took out the GraphQL that reported the error and executed it in Postman, and it was normal.
I don’t know why this happens, I hope to get everyone’s help, thank you very much.