Use a custom index for a relationship in GraphQL

I believe that this is what you are doing in this post: How to handle deletedAt in Graphql and faunadb? - #5 by aprilmintacpineda

Correct.

getUserGoals is a custom query. However, that’s a query on its own, what I need is for the same thing to work for relationships as well.

So currently, to get all goals of the user sorted by sortOrder (desc) and also filtered by deletedAt (only shows goals that are not deleted), we do:

{
  getUserGoals {
    data {
      _id
      name
      sortOrder
    }
  }
}

But, we also have a query to fetch user data, it’s also a custom query getUserData, the function that powers it is as follows:

Update(Function("getUserData"), {
  role: "admin",
  body: Query(
    Lambda(
      "",
      Get(CurrentIdentity())
    )
  )
});

The question is: How can I do the following query:

{
  getUserData {
    _id
    email
    firstName
    lastName
    goals {
      data {
        _id
        name
        sortOrder
      }
    }
  }
}

and get the same effect? That is, the goal should be sorted by sortOrder (descending) and it should only give me goals that are not deleted.