graphql-engine icon indicating copy to clipboard operation
graphql-engine copied to clipboard

Using input data in permissions

Open andrewalex opened this issue 5 years ago • 3 comments

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>

andrewalex avatar Jun 21 '21 18:06 andrewalex

I think this is beyond the capabilities of hasura currently, so I'm converting this to an issue.

andrewalex avatar Jun 21 '21 18:06 andrewalex

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)

leoalves avatar Aug 24 '21 01:08 leoalves

@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'

0x777 avatar Oct 07 '21 14:10 0x777