Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Commit

Permalink
fix: optimistic response id check fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenCoady authored and wtrocki committed May 15, 2019
1 parent b2aff3c commit 73b5b1e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion packages/sync/src/cache/createMutationOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,19 @@ export const createMutationOptions = (options: MutationHelperOptions): MutationO
mutation,
variables,
updateQuery,
typeName,
operationType = CacheOperation.ADD,
idField = "id"
} = options;
const operationName = getOperationFieldName(mutation);
const optimisticResponse = createOptimisticResponse(options);
const optimisticResponse = createOptimisticResponse({
mutation,
variables,
updateQuery,
operationType,
idField,
typeName
});

const update = getUpdateFunction(operationName, idField, updateQuery, operationType);
return { mutation, variables, optimisticResponse, update };
Expand Down
2 changes: 1 addition & 1 deletion packages/sync/src/cache/createOptimisticResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const createOptimisticResponse = (options: MutationHelperOptions) => {
...variables,
optimisticResponse: true
};
if (operationType !== CacheOperation.REFRESH) {
if (operationType === CacheOperation.ADD) {
optimisticResponse[operation][idField] = generateId();
}

Expand Down

0 comments on commit 73b5b1e

Please sign in to comment.