graphql-engine/server/src-lib/Hasura/GraphQL/Schema
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
..
Action.hs Move RoleName into SchemaContext. 2022-07-29 15:38:44 +00:00
Backend.hs server: support for Apollo federation 2022-07-25 15:54:41 +00:00
BoolExp.hs Move RoleName into SchemaContext. 2022-07-29 15:38:44 +00:00
Build.hs Move RoleName into SchemaContext. 2022-07-29 15:38:44 +00:00
Common.hs Move RoleName into SchemaContext. 2022-07-29 15:38:44 +00:00
Instances.hs Rename Data Wrapper to Data Connector [GDW-89] 2022-05-02 05:04:07 +00:00
Introspect.hs server: Remove QErr and Code dependencies from the schema parsers. 2022-07-27 12:26:44 +00:00
Mutation.hs Move RoleName into SchemaContext. 2022-07-29 15:38:44 +00:00
NamingCase.hs server: transform enum with upper for graphql-default 2022-07-19 06:56:45 +00:00
Node.hs remove homebrew NESeq, use vendored 2022-07-19 08:42:28 +00:00
Options.hs Remove remote schema permissions from schema options. 2022-07-18 13:09:40 +00:00
OrderBy.hs Move RoleName into SchemaContext. 2022-07-29 15:38:44 +00:00
Parser.hs server: Remove QErr and Code dependencies from the schema parsers. 2022-07-27 12:26:44 +00:00
Postgres.hs server: Metadata origin for definitions (type parameter version v2) 2022-06-28 15:53:44 +00:00
Relay.hs Move RoleName into SchemaContext. 2022-07-29 15:38:44 +00:00
Remote.hs server: support for Apollo federation 2022-07-25 15:54:41 +00:00
RemoteRelationship.hs Move RoleName into SchemaContext. 2022-07-29 15:38:44 +00:00
Select.hs Move RoleName into SchemaContext. 2022-07-29 15:38:44 +00:00
SubscriptionStream.hs Move RoleName into SchemaContext. 2022-07-29 15:38:44 +00:00
Table.hs Move RoleName into SchemaContext. 2022-07-29 15:38:44 +00:00
Typename.hs Move MkTypename and NamingCase into their own modules. 2022-07-12 14:01:28 +00:00
Update.hs Move RoleName into SchemaContext. 2022-07-29 15:38:44 +00:00