Graphql-engine: support columns comparison on permission rules

Created on 21 Apr 2019  路  4Comments  路  Source: hasura/graphql-engine

In my case, I have "bid" table has "amount" column and I want to check if that amount greater than the current "price" in the "auction" table.

expected query

{"auction":{"price":{"_lt":"current bid amount"}}}
console intermediate enhancement high

Most helpful comment

@rikinsk We already support column operators in permission definitions on server side, the operators are _ceq, _cne, _cgt, _clt, _cgte and _clte. We need to add these in the console?

All 4 comments

Hi @22mahmoud, currently we do not have support for operators which work on columns of the same table. This is being tracked here.

A quick and dirty workaround is to use a view as follows:

create view bid_v as select u.*, (u.amount > u.price) as is_amount_greater from bid u;

Then you can query it as follows:

{
  bid_v(where: {is_amount_greater: {_eq: true}}) {
    amount
  }
}

@rakeshkky Given the conversation with @22mahmoud on discord I think @22mahmoud wants to use it in a permission rule as a check constraint.

as @coco98 said I want to use it in a permission rule as a check

@rikinsk We already support column operators in permission definitions on server side, the operators are _ceq, _cne, _cgt, _clt, _cgte and _clte. We need to add these in the console?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bogdansoare picture bogdansoare  路  3Comments

sachaarbonel picture sachaarbonel  路  3Comments

egislook picture egislook  路  3Comments

EmrysMyrddin picture EmrysMyrddin  路  3Comments

codepunkt picture codepunkt  路  3Comments