https://authzed.com logo
#spicedb
Title
# spicedb
k

Killian

12/14/2021, 9:13 AM
Hello 👋 I have a question about resource deletion using the gRPC api. Currently I use the method
WriteRelationships
to create my users with something like that :
Copy code
message WriteRelationships {
   // Check that the user is not already linked to another project
   optionalPreconditions: [{
     optional_preconditions: MUST_NOT_MATCH
     filter: {
        resource_type: 'user'
        optional_resource_id: 'user_id'
        optional_subject_filter: {
           subject_type: 'project'
        }
     }
   }],

   updates: [{
      operation: 'CREATE'
      relationship: {
         subject: {
            object: {
              object_type: 'project'
              object_id: 'project_id'
            }
         }
         reference: {
            object_type: 'user',
            object_id: 'user_id'
         }
      }
   }]
}
Until then everything works as expected, however if I delete the relation calling
DeleteRelationships
:
Copy code
message DeleteRelationshipsRequest {
   relationship_filter: {
      resource_type: 'user'
      optional_resource_id: 'user_id'
   }
}
I'm not able to re-call the same WriteRelationships request as the precondition fails. Is it a normal behaviour ? Is there something I missing during the deletion ?