[英]react-relay delete mutation update
刪除行后我不知道如何更新表。 Apollo-server 用於客戶端的后端和中繼。 我正在嘗試使用NODE_DELETE但我不知道我做錯了什么
這是刪除突變
const mutation = graphql`
mutation DeleteAdMutation(
$id: ID!
) {
deleteEvent(
id: $id
)
{
deletedId
}
}`;
export const DeleteEvent = (input) => {
return new Promise((resolve, reject) => {
commitMutation(
environment,
{
type: 'NODE_DELETE',
deletedIDFieldName: 'deletedId',
mutation,
variables: input,
}
)
});};
deletedId 成功返回,但表中沒有任何變化
表查詢:
const GetADayTours = graphql`
query GetADayToursQuery(
$type: String!,
$page: Int!,
$row: Int!,
) {
getADayTours(
type: $type,
page: $page,
row: $row,
) {
page
row
total
data{
...on aDayTour{
...Row_row
}
}
}
}`;
export default GetADayTours;
這是行片段:
createFragmentContainer(RowComponent
, {
row: graphql`
fragment Row_row on aDayTour {
_id
id
title
}
`,
});
您必須在查詢數據時為分頁記錄添加 ConnectionKey
參考這個
https://relay.dev/docs/en/pagination-container.html#connection ,關於如何在查詢時添加連接。
之后,當您想使用 nodeId 刪除時,您必須使用“relay-runtime”中的 connectionHandler:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.