Open steida opened 6 years ago
how this is related to relay?
@jgcmarins Check mentioned PR.
For people who experienced this error:
Relay v1.7 - clientMutationId not removed yet
Here is how to resolve this issue (kudos to https://github.com/este/este project)
diff --git a/client/components/Posts/createPostMutation.js b/client/components/Posts/createPostMutation.js
index b9cd342..a86b424 100644
--- a/client/components/Posts/createPostMutation.js
+++ b/client/components/Posts/createPostMutation.js
@@ -1,50 +1,55 @@
import { commitMutation, graphql } from 'react-relay';
import { ConnectionHandler } from 'relay-runtime';
+const getClientMutationId = () => Date.now().toString(36);
+
const mutation = graphql`
mutation createPostMutation($input: CreatePostInput!) {
createPost(input: $input) {
postEdge {
node {
headline
body
id
rowId
}
}
+
+ clientMutationId
}
}
`;
export default function commit(environment, headline) {
return commitMutation(
environment,
{
mutation,
variables: {
input: {
post: {
headline,
body: 'mybody',
},
+ clientMutationId: getClientMutationId()
},
},
updater: (store) => {
// Get the payload returned from the server
const payload = store.getRootField('createPost');
const newEdge = payload.getLinkedRecord('postEdge');
// Add to connection (relay connections are used for pagination)
const hostProxy = store.get('query');
const conn = ConnectionHandler.getConnection(hostProxy, 'AppQuery_allPosts');
ConnectionHandler.insertEdgeAfter(conn, newEdge);
conn.setValue(conn.getValue('totalCount') + 1, 'totalCount')
},
onCompleted: response => {
console.log('response', response)
},
onError: err => console.error(err)
}
);
related to https://github.com/facebook/relay/pull/2349
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This is an old bug. Probably fixed in https://github.com/facebook/relay/pull/2349
When I add two items with the same text prop, Relay will warn. I am not doing anything special in http://github.com/este/este.
It's clientMutationID thing. Care to comment, please?