[英]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.