Skip to content

Instantly share code, notes, and snippets.

@scottdomes
Last active January 26, 2019 00:05
Show Gist options
  • Save scottdomes/8d74a599edceb55eeed2f7f7e2198d1c to your computer and use it in GitHub Desktop.
Save scottdomes/8d74a599edceb55eeed2f7f7e2198d1c to your computer and use it in GitHub Desktop.
import { ConnectionHandler } from 'relay-runtime';
const sharedUpdater = (store, viewer, newEdge) => {
const viewerProxy = store.get(viewer.id);
const conn = ConnectionHandler.getConnection(viewerProxy, 'Main_allContacts');
ConnectionHandler.insertEdgeAfter(conn, newEdge);
};
const updateLocalStore = (store, data, viewer) => {
const payload = store.getRootField('createContact');
const newEdge = payload.getLinkedRecord('contactEdge');
sharedUpdater(store, viewer, newEdge);
};
export default updateLocalStore;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment