Proper way to delete items

I have a GraphQL schema that looks like this:

type User {
  firstName: String
  lastName: String
  email: String
  groups: [Group] @relation(name: "members")

type Group {
  name: String
  members: [User] @relation(name: "members")
  startDate: String

This creates an index called members_by_group and a Collection called members.

If I preform a deleteUser mutation:


The user is not “unlinked” from the group, and the members collection still contains the following record:

  "ref": Ref(Collection("members"), "351058485137375832"),
  "ts": 1671054310890000,
  "data": {
    "groupID": Ref(Collection("Group"), "329795413068481106"),
    "userID": Ref(Collection("User"), "329431630822244946")

This results in Instance not found errors when Querying the group:

findGroupByID(id: $id){

What is the proper way to delete items via GraphQL so that the corresponding collections and indexes update correctly? Do I need a to create a function? What would a cascading delete function in FQL look like? Thanks in advance.

Hi @levimoore

This post might be what you are looking for.

We also have a Knowlede Base article on how to perform cascading deletes in FQL - Cascading Deletes in FQL

Hope that helps!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.