Hi, I reposted here as react channel is a bit dead...
# prisma-whats-new
o
Hi, I reposted here as react channel is a bit dead. I'm following the relay modern tutorial

https://www.youtube.com/watch?v=XeALXh37WeU

and trying to recreate a simple note app using your relay api but I can't update the store as the connection returns undefined. Could someone tell me what I'm doing wrong? The full code can be found at https://github.com/otissv/relay-modern-note-app.git create mutation
Copy code
const config = {
    mutation,
    variables,
    optimisticUpdater: proxyStore => {
      // 1 - create the `newNote` as a mock that can be added to the store
      const id = 'client:newNote:' + tempID++;
      const newNote = proxyStore.create(id, 'Note');
      console.log(newNote);
      console.log(variables);

      newNote.setValue(id, 'id');
      console.log(variables);
      Object.keys(variables.input).forEach(key =>
        newNote.setValue(variables.input[key], `${key}`)
      );

      // // 2 - add `newNote` to the store
      const viewerProxy = proxyStore.get(viewerId);
      console.log(viewerProxy);
      const connection = ConnectionHandler.getConnection(
        viewerProxy,
        'ListPage_allNotes'
      );

      if (connection) {
        ConnectionHandler.insertEdgeAfter(connection, newNote);
      }
    },
    updater: proxyStore => {
      // 1 - retrieve the `newNote` from the server response
      const createNoteField = proxyStore.getRootField('createNote');
      const newNote = createNoteField.getLinkedRecord('Note');

      // 2 - add `newNote` to the store
      const viewerProxy = proxyStore.get(viewerId);
      const connection = ConnectionHandler.getConnection(
        viewerProxy,
        'ListPage_allNotes'
      );
      if (connection) {
        ConnectionHandler.insertEdgeAfter(connection, newNote);
      }
    },
    onError: error => console.log(error)
  };

  commitMutation(environment, config);
}
Thank you.