@@ -330,6 +330,76 @@ var options = new ClientWriteOptions()
330330var response = fgaClient.write(request, options).get();
331331```
332332
333+ ###### Conflict options for write operations
334+
335+ Write conflict handling can be controlled using the `onDuplicate` option for writes and the `onMissing` option for deletes.
336+
337+ > Note: this requires OpenFGA [v1.10.0](https://github.com/openfga/openfga/releases/tag/v1.10.0) or later.
338+
339+ - `onDuplicate`: Controls behavior when attempting to create a tuple that already exists
340+ - `WriteRequestWrites.OnDuplicateEnum.ERROR` (default): Return an error
341+ - `WriteRequestWrites.OnDuplicateEnum.IGNORE`: Skip the duplicate tuple and continue
342+
343+ - `onMissing`: Controls behavior when attempting to delete a tuple that doesn't exist
344+ - `WriteRequestDeletes.OnMissingEnum.ERROR` (default): Return an error
345+ - `WriteRequestDeletes.OnMissingEnum.IGNORE`: Skip the missing tuple and continue
346+
347+ **Using conflict options with the `write()` method:**
348+
349+ ```java
350+ var request = new ClientWriteRequest()
351+ .writes(List.of(
352+ new ClientTupleKey()
353+ .user("user:81684243-9356-4421-8fbf-a4f8d36aa31b")
354+ .relation("viewer")
355+ ._object("document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a")
356+ ))
357+ .deletes(List.of(
358+ new ClientTupleKeyWithoutCondition()
359+ .user("user:81684243-9356-4421-8fbf-a4f8d36aa31b")
360+ .relation("writer")
361+ ._object("document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a")
362+ ));
363+
364+ var options = new ClientWriteOptions()
365+ .onDuplicate(WriteRequestWrites.OnDuplicateEnum.IGNORE)
366+ .onMissing(WriteRequestDeletes.OnMissingEnum.IGNORE);
367+
368+ var response = fgaClient.write(request, options).get();
369+ ```
370+
371+ **Using conflict options with the `writeTuples()` convenience method:**
372+
373+ ```java
374+ var tuples = List.of(
375+ new ClientTupleKey()
376+ .user("user:81684243-9356-4421-8fbf-a4f8d36aa31b")
377+ .relation("viewer")
378+ ._object("document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a")
379+ );
380+
381+ var options = new ClientWriteTuplesOptions()
382+ .onDuplicate(WriteRequestWrites.OnDuplicateEnum.IGNORE);
383+
384+ var response = fgaClient.writeTuples(tuples, options).get();
385+ ```
386+
387+ **Using conflict options with the `deleteTuples()` convenience method:**
388+
389+ ```java
390+ var tuples = List.of(
391+ new ClientTupleKeyWithoutCondition()
392+ .user("user:81684243-9356-4421-8fbf-a4f8d36aa31b")
393+ .relation("writer")
394+ ._object("document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a")
395+ );
396+
397+ var options = new ClientDeleteTuplesOptions()
398+ .onMissing(WriteRequestDeletes.OnMissingEnum.IGNORE);
399+
400+ var response = fgaClient.deleteTuples(tuples, options).get();
401+ ```
402+
333403#### Relationship Queries
334404
335405##### Check
0 commit comments