简体   繁体   中英

Relay Store Updater Not Working

Im trying to do an updater to a mutation and its not working well it says to me that the 'setValue is not a function', and when do a console.log on the newEvent and on relayEvent it returns to me the right data can somebody help me please!

My mutation its workin but somehow the data is not being updated, so i needed to do a updater that is not working

Heres my code:

/* @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 };
updater: (store, data) => {
      let createAttendedField = store.getRootField("EventSetAttended");
      let newEvent = createAttendedField.getLinkedRecord("event");

      const relayEvent = store.get(input.eventId);

      relayEvent.setLinkedRecord(newEvent, "event");
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM