我們在我們的項目中使用graphql並使用graphql-java 2.3.0(我們計劃更新,但目前不可能)。如何在graphql中設置null爲空?
我試圖進行這樣的突變:
mutation {
UPDATE_User(
id:3,
type: null
) {id}
}
響應:
{
"errors": [
{
"validationErrorType": "WrongType",
"message": "Validation error of type WrongType: argument value EnumValue{name='null'} has wrong type",
"locations": [
{
"line": 5,
"column": 7
}
],
"errorType": "ValidationError"
}
],
"data": null
}
我明白了。謝謝。但是什麼是reccomended解決方法?我認爲直到現在,graphql用戶還沒有使用null。 –
@Don_Quijote Null僅在幾個月前添加。在此之前,你所能做的就是根本不發送'type',但是你不能區分_update和null_並且_leave不變_。如果這對你很重要,你必須設置一個特殊的標記值來「輸入」,例如'type:「NONE」'並在後端處理相應的內容。 – kaqqao