如何在 Hasura 的权限中使用 graphql 变量?



我有一个突变。如何使用 graphql 查询中的变量在 hasura 中创建权限?

例如:

mutation MyMutation($name:String!) {
insert_post(objects: {name:$name}){
name
}
}

如何在权限中使用name变量?

是我在 Discord 上。

只是因为有人有同样的问题。目前,Hasura 不支持检查用户输入值的权限,它只接受来自x-hasura-user-idsession variables的值。

但我认为 Hasura 方法在不允许根据用户输入设置权限时是正确的。

如果我的回答是错误的,请纠正,谢谢。

> Hasura v2 现在允许这种模式。

例如,如果您有一个包含允许名称列表的表, 您可以检查要插入的名称是否在列表中 允许的名称,如下所示:

insert_permissions:
- role: user
permission:
check:
_exists:
_table:
name: allowed_names
schema: public
_where:
name:
_ceq: ["$", "name"]

另请参阅:

https://github.com/hasura/graphql-engine/issues/3459#issuecomment-1085666541

https://hasura.io/docs/latest/graphql/core/api-reference/syntax-defs/

最新更新