Amplify Graphql – How to create a pseudo folder structure

I have an app where users store links in “folders”. The way that I have it set up right now, there are 4 tables.

  1. A table of “links”
  2. A table for “folders”
  3. A table that ties the “links” to their parent “folders”
  4. A final table houses the “relationships” between those folders. It has a column for the ID of the parent folder and an ID for the child folder.

In this manner, I can have any number of parent and children folders and place those links anywhere. I can display the data in folder format with the links in the proper locations.

The problem is that I would like to be able to pull down the most recent “links” placed into any folder – including all children folders. So, if a user is looking at a top level folder, I would show the 5, 10, or whatever most recent links within it and all subfolders. I don’t feel like the current setup is optimal for this. What setup should I use? The app isn’t so far along that I can’t redo the structure.


BSNL 4G Data Only Vouchers Under Rs 100 You Can Buy

RRB Kolkata NTPC Result 2021 Out, Result Download Link