0

I'm setting up some permissions in hasura, I have an 'assigned' table which maps an assigned item to a user, I require the user to be able to only access items they have been assigned. I figured the best way to do this was with the _exists operator where I have:

{"_exists":{"_table":{"name":"assigned_item","schema":"public"},"_where":{"_and":[{"userid":{"_eq":"X-Hasura-User-Id"}},{"feed_item_id":{"_eq":"XXX"}}]}}

My issue comes into play with the last _eq: XXX - I need for it to equal the value from the item table.

The permission is being created against the assigned item.

meds
  • 21,699
  • 37
  • 163
  • 314

1 Answers1

1

Assuming your assigned_item table has userid and feed_item_id .. your permissions should be:

  1. on the assigned_item table, just add the permission: userid _eq X-Hasura-User-Id as in "A user can see all their assigned items".
  2. on the feed_items? table, use the relationship to reach the user_id through the assigned_item table. Assuming the relationship on feed_items is called say "assigned_users", then the permission is: feed_items > assigned_users > user_id _eq X-Hasura-User-Id
O. Mills
  • 216
  • 2
  • 10