是否可以使用Relay Modern命令突变API取消链接记录链接?

时间:2017-10-21 03:43:42

标签: relayjs relay relaymodern

我想写一个变异updater来取消链接记录与另一条记录的链接。

例如,假设我的商店中有以下内容:

client:root {
  user: {__ref: "someid"}
}

我正在寻找取消关联userclient:root的方法。 user是一个可以为空的字段。我希望对user字段感兴趣的订阅者看到它已经消失null

现在,我看到取消链接此字段的唯一方法是从商店中删除节点。我已尝试使用setLinkedRecord将链接设置为null,但会引发错误。

2 个答案:

答案 0 :(得分:1)

.setLinkedRecored()期望第一个参数是RecordProxy的实例。使用.setValue()取消链接节点,为whitep4nther commented above

store.getRoot().setValue(undefined, 'user');

答案 1 :(得分:0)

我也只是在与此斗争,在深入了解继电器代码库之后,我认为现在还没有合适的方法来解决这个问题。我opened an issue here