graphql-engine/server/src-lib/Hasura/Backends/Postgres/Instances
Antoine Leblanc 0a69db81c9 Move RoleName into SchemaContext.
### Description

I am not 100% sure about this PR; while I think the code is better this way, I'm willing to be convinced otherwise.

In short, this PR moves the `RoleName` field into the `SchemaContext`, instead of being a nebulous `Has RoleName` constraint on the reader monad. The major upside of this is that it makes it an explicit named field, rather than something that must be given as part of a tuple of arguments when calling `runReader`.

However, the downside is that it breaks the helper permissions functions of `Schema.Table`, which relied on `Has RoleName r`. This PR makes the choice of passing the role name explicitly to all of those functions, which in turn means first explicitly fetching the role name in a lot of places. It makes it more explicit when a schema building block relies on the role name, but is a bit verbose...

### Alternatives

Some alternatives worth considering:
- attempting something like `Has context r, Has RoleName context`, which would allow them to be independent from the context but still fetch the role name from the reader, but might require type annotations to not be ambiguous
- keeping the permission functions the same, with `Has RoleName r`, and introducing a bunch of newtypes instead of using tuples to explicitly implement all the required `Has` instances
- changing the permission functions to `Has SchemaContext r`, since they are functions used only to build the schema, and therefore may be allowed to be tied to the context.

What do y'all think?

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5073
GitOrigin-RevId: 8fd09fafb54905a4d115ef30842d35da0c3db5d2
2022-07-29 15:38:44 +00:00
..
API.hs server/bigquery: enable metadata API to add/drop computed fields to BigQuery tables 2022-05-04 14:53:31 +00:00
Execute.hs Remove strictness annotations from data types in the Hasura.Backends hierarchy 2022-07-29 14:06:23 +00:00
Metadata.hs server/bigquery: generate graphql schema for table computed fields 2022-05-25 10:25:38 +00:00
Schema.hs Move RoleName into SchemaContext. 2022-07-29 15:38:44 +00:00
Transport.hs server: Reorganize quasi-quoted names. 2022-06-23 09:15:31 +00:00
Types.hs server: postgres multiple updates 2022-07-18 15:16:47 +00:00