[英]react-relay delete mutation update
I can't find out how to update table after deleting row.删除行后我不知道如何更新表。 Apollo-server is used in backend and relay for client.
Apollo-server 用于客户端的后端和中继。 I'm trying to use NODE_DELETE but I don't know what I'm doing wrong
我正在尝试使用NODE_DELETE但我不知道我做错了什么
this is delete mutation这是删除突变
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 returned successfully but nothing changes in table deletedId 成功返回,但表中没有任何变化
table query:表查询:
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;
and here is row fragment:这是行片段:
createFragmentContainer(RowComponent
, {
row: graphql`
fragment Row_row on aDayTour {
_id
id
title
}
`,
});
You have to add ConnectionKey for paginated records while querying data您必须在查询数据时为分页记录添加 ConnectionKey
refer this参考这个
https://relay.dev/docs/en/pagination-container.html#connection , on how to add connection while querying. https://relay.dev/docs/en/pagination-container.html#connection ,关于如何在查询时添加连接。
And after that when when you want to delete using nodeId, you have to use connectionHandler from 'relay-runtime':之后,当您想使用 nodeId 删除时,您必须使用“relay-runtime”中的 connectionHandler:
https://relay.dev/docs/en/relay-store#connectionhandler https://relay.dev/docs/en/relay-store#connectionhandler
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.