openfga / community

The Community repository is the place to go for OpenFGA support
https://openfga.dev
Apache License 2.0
27 stars 32 forks source link

Difficulty Collecting Garbage Relations. #340

Closed xXAvoraXx closed 3 months ago

xXAvoraXx commented 3 months ago

Checklist

Describe the problem you'd like to have solved

When we delete an object from our database, we send a query with listobject to find all the relationships established by the type of that object one by one, then we create a delete query. This makes it difficult to collect, delete and maintain the garbage left in the openfga database when the object is deleted.

Describe the ideal solution

It would make it really easy if there was an api call like the one below, where the task of the api is to find out what relationships the type to be deleted has with other types and delete them.

fgaClient.deleteType(typeName, id);

{
  "deletes": {
    "tuple_keys": [
      {
        "type": "document",
        "id": "2021-budget"
      }
    ]
  }
}

Alternatives and current workarounds

Currently, the best way to know this is to determine which type the object to be deleted represents in the authorization schema, then determine which relationships that type has with which types, then send a listObjects query one by one, then try to find the opposite situations with listUsers.

Additional context

No response