javascript - Graphql 突变正在覆盖现有数据
问题描述
我正在使用 React.js 构建看板,而对于后端,我正在使用 Canonic 低代码平台
我的突变代码是
const UPDATE_SECTION = gql`
mutation UpdateSection($_id: ID!, $label: String!, $cardId: [ID!]!) {
updateSection(_id: $_id, input: { label: $label, cardId: $cardId }) {
label
_id
cardId {
title
}
}
}
`;
而且,我正在像这样触发它
let createId = data.createCard._id;
updateSection({
variables: {
_id: item._id,
label: item.label,
cardId: `${createId}`,
},
});
我想要的是当cardId:${createId}
作为突变发送到graphql时,它应该附加到现有数据,目前正在发生的是,上述代码正在用通过突变推送的最新数据替换“卡片”数组中的所有内容。
graphql 的类型定义如下所示
type Section {
_id: String
createdAt: Date
updatedAt: Date
title: String
label: String!
description: String
pos: Float
cardId: [Card]
}
有谁知道如何解决这个问题?谢谢你。
解决方案
推荐阅读
- java - 哪个更有效率?为地图值的临时结果声明一个对象?还是直接从地图根中获取?
- c - 将结构数组传递给函数并在C中计算平均值?
- java - If multiple classes contain same code for error checking should I extract it into new class?
- java - java.lang.IllegalArgumentException:未注册的过滤器类后无法注册
- javascript - 从服务获取数据后,清除 ngOnDestroy 上的静态数据
- sql-server - 如何调试 Azure SQL 触发器?
- amazon-web-services - AWS EMR pyspark 笔记本因“无法运行命令 /usr/bin/virtualenv (...)”而失败
- python - 如何在 Python 3.7 中应用 argrelextrema 函数?
- r - 组大小不匹配列
- c - 连接两个字符串程序没有给出正确的输出