中继突变错误:预期响应有效负载中的记录ID

时间:2016-05-11 15:36:29

标签: reactjs graphql relayjs relay

我有一个Relay Mutation删除连接中的节点:

export default class DeleteDefectMutation extends Relay.Mutation {

    getMutation() {
        return Relay.QL`mutation { deleteDefect }`;
    }

    getVariables() {
        return {
            photoId: this.props.photoId,
            defectId : this.props.defectId
        }
    }

    getFatQuery() {
        return Relay.QL`
            fragment on DeleteDefectMutationPayload {
                updatedPhoto { issues }
                deletedDefectId
            }
        `
    }

    getConfigs() {
        return [{
            type : "NODE_DELETE",
            parentName: 'updatedPhoto',
            parentID: this.props.photoId,
            connectionName: 'issues',
            deletedIDFieldName: 'deletedDefectId'
        }]
    }

    getOptimisticResponse() {
        return {
            deletedDefectId : this.props.defectId,
            updatedPhoto : {
                id : this.props.photoId
            }
        }
    }
}

当我用它时:

Relay.Store.commitUpdate(new DeleteDefectMutation({photoId, defectId},{
    onSuccess : () => console.log('Mutation Success !'),
    onFailure : transaction => console.error(transaction.error ? transaction.error : new Error("Mutation Failed"))
}))

我收到一条我不明白的错误:

Uncaught Invariant Violation: writeRelayUpdatePayload(): Expected a record ID in the response payload supplied to update the store

0 个答案:

没有答案