graphql-engine
graphql-engine copied to clipboard
Using input data in permissions
Discussed in https://github.com/hasura/graphql-engine/discussions/7038
Originally posted by andrewalex June 10, 2021 when setting a permission, can I refer back to a field in the initial record or insert data?
Pseudo Code
insert $storeid, $bookid, $quantity into inventory
where
store.manager = X-Hasura-UserId
and store.allowed_books contains $bookid
```</div>
I think this is beyond the capabilities of hasura currently, so I'm converting this to an issue.
This was added in v2.0 https://github.com/hasura/graphql-engine/releases/tag/v2.0.0 (Support comparing columns across related tables in permission's boolean expressions)
@andrewalex This should be possible by setting the condition on inventory table as follows:
{ "store": { "allowed_books": { "book_id": { "_ceq": ["$", "book_id"]} } } }
["$", "book_id"] is equivalent to saying 'inventory.book_id'