Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function commit(
environment: Environment,
todos: any,
user: any,
) {
const input: any = {
userId: user.userId,
};
commitMutation(environment, {
mutation,
variables: {
input,
},
updater: (store: any) => {
const payload = store.getRootField('removeCompletedTodos');
const deletedIds = payload.getValue('deletedTodoIds');
// $FlowFixMe `payload.getValue` returns mixed, not sure how to check refinement to $ReadOnlyArray
sharedUpdater(store, user, deletedIds);
},
optimisticUpdater: (store: any) => {
// Relay returns Maybe types a lot of times in a connection that we need to cater for
const completedNodeIds: ReadonlyArray = todos.edges
? todos.edges
.filter(Boolean)
totalCount: totalCount
}
}
},
configs: [{
type: 'RANGE_ADD',
parentID: user.id,
connectionInfo: [{
key: 'TodoList_todos',
rangeBehavior: 'append',
}],
edgeName: 'todoEdge',
}],
});*/
return commitMutation(environment, {
mutation,
variables: {
input,
},
onCompleted: data => {
console.log('onCompleted', data);
},
updater: store => {
// Get the payload returned from the server
const payload = store.getRootField('addTodo');
// Get the edge of the newly created Todo record
const newEdge = payload.getLinkedRecord('todoEdge');
// Add it to the user's todo list
sharedUpdater(store, user, newEdge);
totalCount: totalCount
}
}
},
configs: [{
type: 'RANGE_ADD',
parentID: user.id,
connectionInfo: [{
key: 'TodoList_todos',
rangeBehavior: 'append',
}],
edgeName: 'todoEdge',
}],
});*/
commitMutation(environment, {
mutation,
variables: {
input,
},
updater: (store: any) => {
// Get the payload returned from the server
const payload = store.getRootField('addTodo');
// Get the edge of the newly created Todo record
const newEdge = payload.getLinkedRecord('todoEdge');
// Add it to the user's todo list
sharedUpdater(store, user, newEdge);
},
optimisticUpdater: (store: any) => {
const id = idTodo;
totalCount: totalCount
}
}
},
configs: [{
type: 'RANGE_ADD',
parentID: user.id,
connectionInfo: [{
key: 'TodoList_todos',
rangeBehavior: 'append',
}],
edgeName: 'todoEdge',
}],
});*/
commitMutation(environment, {
mutation,
variables: {
input
},
updater: (store: any) => {
// Get the payload returned from the server
const payload = store.getRootField("addTodo");
// Get the edge of the newly created Todo record
const newEdge = payload.getLinkedRecord("todoEdge");
// Add it to the user's todo list
sharedUpdater(store, user, newEdge);
},
optimisticUpdater: (store: any) => {
const id = idTodo;
function commit(
environment: Environment,
complete: boolean,
todo: Todo_todo,
user: Todo_user,
): Disposable {
const input: ChangeTodoStatusInput = {
complete,
userId: user.userId,
id: todo.id,
};
return commitMutation(environment, {
mutation,
variables: {
input,
},
optimisticResponse: getOptimisticResponse(complete, todo, user),
});
}
function commit(
environment: Environment,
complete: boolean,
todo: any,
user: any,
) {
const input: any = {
complete,
userId: user.userId,
id: todo.id,
};
commitMutation(environment, {
mutation,
variables: {
input,
},
optimisticResponse: getOptimisticResponse(complete, todo, user),
});
}
function commit(
environment: Environment,
text: string,
user: TodoApp_user,
): Disposable {
const idTodo = uuid();
const input: AddTodoInput = {
id: idTodo,
text,
userId: user.userId,
clientMutationId: idTodo,
};
const totalCount = user.totalCount + 1;
const idTot = totalCount+user.completedCount;
return commitMutation(environment, {
mutation,
variables: {
input,
},
optimisticResponse: {
addTodo: {
todoEdge: {
node: {
id: idTodo,
text: text,
complete: false
},
cursor: null,
__typename: "TodoEdge"
},
user: {
function commit(environment: any, complete: boolean, todo: any, user: any) {
const input: any = {
complete,
userId: user.userId,
id: todo.id,
};
commitMutation(environment, {
mutation,
variables: {
input,
},
optimisticResponse: getOptimisticResponse(complete, todo, user),
});
}
function commit(
environment: any,
todo: any,
user: any,
): any {
const input: any = {
id: todo.id,
userId: user.userId,
};
return commitMutation(environment, {
mutation,
variables: {
input,
},
configs: [{
type: 'NODE_DELETE',
deletedIDFieldName: 'deletedTodoId',
},
],
optimisticResponse: {
removeTodo: {
deletedTodoId: todo.id,
user: {
id: user.id,
completedCount: user.completedCount - (todo.complete ? 1 : 0),
totalCount: (user.totalCount-1)
function commit(
environment: Environment,
text: string,
todo: Todo_todo,
): Disposable {
const input: RenameTodoInput = {
text,
id: todo.id,
};
return commitMutation(environment, {
mutation,
variables: {
input,
},
optimisticResponse: getOptimisticResponse(text, todo),
});
}