我嵌套了两个 Relay 突变,首先添加一个对象,然后设置它的名称。我相信我传递给第二个突变的实际上是 Relay 获取的数据,但它似乎不同意我的观点。React 视图中的代码如下:
Relay.Store.update(
new AddCampaignFeatureLabelMutation({
campaign: this.props.campaign
}),
{
onSuccess: (data) => {
Relay.Store.update(
new FeatureLabelNameMutation({
featureLabel: data.addCampaignFeatureLabel.featureLabelEdge.node,
name: this.addLabelInputField.value
})
);
},
onFailure: () => {}
}
);
这确实有效,但给了我一个警告:
Warning: RelayMutation: Expected prop `featureLabel` supplied to `FeatureLabelNameMutation` to be data fetched by Relay. This is likely an error unless you are purposely passing in mock data that conforms to the shape of this mutation's fragment.
为什么 Relay 认为数据没有被获取?我是否可能需要以某种方式在有效负载中显式返回新的 featureLabel ?