Skip to content

Commit

Permalink
fix: pass ifRevisionID when encoding for Sanity mutation API
Browse files Browse the repository at this point in the history
  • Loading branch information
bjoerge committed Dec 2, 2023
1 parent b11cb3d commit 6e7b490
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/encoders/sanity/encode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,16 @@ export function encodeMutation(mutation: Mutation) {
delete: {id: mutation.id},
}
}
return mutation.patches.map(patch => ({
patch: {id: mutation.id, ...patchToSanity(patch)},
}))
const ifRevisionID = mutation.options?.ifRevision
return mutation.patches.map(patch => {
return {
patch: {
id: mutation.id,
...(ifRevisionID && {ifRevisionID}),
...patchToSanity(patch),
},
}
})
}

function patchToSanity(patch: NodePatch) {
Expand Down

0 comments on commit 6e7b490

Please sign in to comment.