needs to observe the field `_acfCaseBoolExpression`, which decides
whether the column value should be nullified, as resulting from
inherited roles.
### Notes for Mutations
A GQL _Mutation_ however may result in either of `INSERT`, `UPDATE`, or `DELETE`
statements. Of these, `INSERT` has no obvious point in which to include a permissions
predicate over the rows inserted.
As a consequence of this we need to translate an insert-mutation into a MySQL
transaction, where performing the mutation and checking permissions on the
affected rows is split over multiple statements. <aname="footnote-4-ref"></a>[[4]](#footnote-4-def)
One suggested way to do this could be making a temporary table having the
permissions as `CHECK`-constraints, inserting the new rows into this table
(which fails if the permissions are not satisfied) and copying them over to the
table actually targeted by the mutation.
## Future
This document is a product of its time, brought into existence by the
contemporary need to elaborate on how permissons work because the development
work on MySQL needs to incorporate them.
An insight resulting from discussing this subject is that it would be more
appropriate to treat permissions not as a distinct topic of a dedicated RFC
document, but rather as associated concepts of the RFCs of the objects they
apply to, i.e. variants of _Queries_ and _Mutations_.
As it were, _permissions_ do not exist in a vacuum. In order to talk about them
we need to also talk about what they apply to. As such it makes for a more
elegant exposition to talk about permissons as associated aspects of the subject
they act on.
It it therefore expected that this document be superseded by dedicated RFCs on
the subjects of _Queries_, _Mutations_.
## Questions
How does the feature of _Inherited Roles_ interact with the permissions-support
in a backend?
> The permissions that result from Inherited Roles are completely resolved into
> base permissions before being handed over to schema building. So Inherited
> Roles have no interaction with backend code.
Do _Limit Permissions_ only apply to root-fields or also to array relationships?
> Yet unanswered.
## Footnotes
<aname="footnote-1-def"></a>[1][^](#footnote-1-ref): For example,
```
query {
articles_aggregate {
count
nodes { .. }
}
}
```
If the select permission on some role `r` specifies a limit of `5` and there are
a total of `10` rows accessible to `r` (as per active _Row Permissions_), the
`count` in the above query should return `10` while `nodes` should only return
`5`. I.e, the _Limit Permission_ should only be applied when returning rows and
not when computing aggregate data.
<aname="footnote-2-def"></a>[2][^](#footnote-2-ref): See [`server/src-lib/Hasura/RQL/IR/Select.hs`]( https://github.com/hasura/graphql-engine-mono/blob/dfba245a4dbe1a71b1e3cc7c92914fc0a919c2b0/server/src-lib/Hasura/RQL/IR/Select.hs#L67).
<aname="footnote-3-def"></a>[3][^](#footnote-3-ref): See [`server/src-lib/Hasura/RQL/IR/Select.hs`]( https://github.com/hasura/graphql-engine-mono/blob/dfba245a4dbe1a71b1e3cc7c92914fc0a919c2b0/server/src-lib/Hasura/RQL/IR/Select.hs#L305). Haddocks contain descriptions of use.
<aname="footnote-4-def"></a>[4][^](#footnote-4-ref): In PostgreSQL we exploit that `INSERT` supports a
`RETURNING` clause that lets us extract information from the affected rows.