0
我試圖做一個更新到一個突變,它不能很好地工作它告訴我,'setValue不是一個函數',並且當在newEvent和relayEvent上做一個console.log返回給我正確的數據可以有人幫助我!中繼存儲更新不起作用
我突變的幹活,但不知該數據沒有更新,所以我需要做的是不工作
繼承人我的代碼更新:
/* @flow */
import { graphql, commitMutation } from "react-relay";
import environment from "../../../relay/environment";
import type { EventSetAttendedInput } from "./__generated__/EventSetAttendedMutation.graphql";
import { connectionUpdater } from "../../../relay/mutationUtils";
const mutation = graphql`
mutation EventSetAttendedMutation($input: EventSetAttendedInput!) {
EventSetAttended(input: $input) {
event {
id
_id
attended(first: 10000) {
__typename
edges {
node {
person {
name
_id
id
}
}
}
}
invitations(first: 10000) {
__typename
edges {
node {
attended
person {
name
_id
id
}
}
}
}
}
error
}
}
`;
let tempID = 0;
const commit = (input: EventSetAttendedInput, onCompleted, onError) => {
return commitMutation(environment, {
mutation,
variables: {
input: {
...input,
clientMutationId: tempID++
}
},
onCompleted,
onError,
updater: store => {
let createAttendedField = store.getRootField("EventSetAttended");
let newEvent = createAttendedField.getLinkedRecord("event");
const relayEvent = store.get(input.eventId);
console.log(`eventStore: `, newEvent);
console.log(`relayEvent: `, relayEvent);
store.setValue(newEvent, "event");
}
});
};
export default { commit };