为什么NODE_DELETE配置需要指定连接?

Why does the NODE_DELETE configuration needs to specify a connection?

我目前正在构建一个删除节点的突变。 我查看了 NODE_DELETE 增变器配置,但它指定它需要 parentNameparentIDconnectionName.

为什么删除节点需要这些字段?由于 Relay 使用全局 ID,因此从所有连接 and/or 引用它的所有字段中删除节点应该相当容易。

查看文档:
Relay NODE_DELETE documentation

您的直觉是正确的。 为了从数据存储中删除节点,这些字段是多余的,在此类操作期间仅使用 config.deletedIDFieldNamewriteRelayUpdatePayload 模块中的详细信息)。

但是 您不能将其他字段留空,因为在验证 扩展 RelayMutation class 的突变期间仍然需要它们。我不知道这种不一致从何而来,但值得注意的是,Relay 团队改变了开发方向,RelayMutation 将被弃用。

RelayMutation and fat/tracked queries. Future releases will deprecate this API in favor of a static mutation API. We recommend using RelayGraphQLMutation to ease the transition to new mutations.

来源:Related issue on github

快速查看 Relay 的源代码后,似乎这个过渡 API 没有使用旧的配置验证方法,但我还没有机会试验它,所以你可以自己确认.