graphql-engine/server/src-lib/Hasura/Server
Antoine Leblanc 7aa341944b Remove HasServerConfigCtx from the schema cache build.
## Description

This PR is a incremental step towards achieving the goal of #8344. It is a less ambitious version of #8484.

This PR removes all references to `HasServerConfigCtx` from the cache build and removes `ServerConfigCtx` from `CacheBuildParams`, making `ServerConfigCtx` an argument being passed around manually instead. This has several benefits: by making it an arrow argument, we now properly integrate the fields that change over time in the dependency framework, as they should be, and we can clean up some of the top-level app code.

## Implementation

In practice, this PR introduces a `HasServerConfigCtx` instance for `CacheRWT`, the monad we use to build the cache, so we can retrieve the `ServerConfigCtx` in the implementation of `CacheRWM`. This contributes to reducing the amount of `HasServerConfigCtx` in the code: we can remove `SchemaUpdateT` altogether, and we can remove the `HasServerConfigCtx` instance of `Handler`. This makes `HasServerConfigCtx` almost **an implementation detail of the Metadata API**.

This first step is enough to achieve the goal of #8344: we can now build the schema cache in the app monad, since we no longer rely on `HasServerConfigCtx` to build it.

## Drawbacks

This PR does not attempt to remove the use of `ServerConfigCtx` itself in the schema cache build: doing so would make this PR much much bigger. Ideally, to avoid having all the static fields given as arrow-ish arguments to the cache, we could depend on `HasAppEnv` in the cache build, and use `AppContext` as an arrow argument. But making the cache build depend on the full `AppEnv` and `AppContext` creates a lot of circular imports; and since removing `ServerConfigCtx` itself isn't required to achieve #8344, this PR keeps it wholesale and defers cleaning it to a future PR.

A negative consequence of this is that we need an `Eq` instance on `ServerConfigCtx`, and that instance is inelegant.

## Future work

There are several further steps we can take in parallel after this is merged. First, again, we can make a new version of #8344, removing `CacheBuild`, FINALLY. As for `ServerConfigCtx`, we can split it / rename it to make ad-hoc structures. If it turns out that `ServerConfigCtx` is only ever used for the schema cache build, we could split it between `CacheBuildEnv` and `CacheBuildContext`, which will be subsets of `AppEnv` and `AppContext`, avoiding import loops.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8509
GitOrigin-RevId: 01b37cc3fd3490d6b117701e22fc4ac88b62b6b5
2023-03-27 17:44:27 +00:00
..
API Remove HasServerConfigCtx from the schema cache build. 2023-03-27 17:44:27 +00:00
Auth Simplify Transformable Requests Module 2023-03-22 00:01:07 +00:00
Init refactor: newtype alias for action checking feature flags 2023-03-22 10:48:22 +00:00
Migrate chore(server): various code cleanups 2023-03-14 17:47:49 +00:00
Telemetry rename naqi to logimo part 1 2023-02-21 13:46:44 +00:00
App.hs Remove HasServerConfigCtx from the schema cache build. 2023-03-27 17:44:27 +00:00
AppStateRef.hs Split catalog migration and cache build, and solve the manager chicken-egg problem. 2023-03-23 16:42:53 +00:00
Auth.hs server: rename SchemaCacheRef to AppStateRef and add AppContext to it 2023-03-17 10:30:38 +00:00
CheckUpdates.hs Upgrade Ormolu to v0.5. 2022-11-02 20:55:13 +00:00
Compression.hs chore: Fix all outstanding hlint hints 2023-02-20 17:43:28 +00:00
Cors.hs Upgrade Ormolu to v0.5. 2022-11-02 20:55:13 +00:00
Init.hs server: move apollo-federation to GA 2023-03-15 08:15:51 +00:00
Limits.hs Remove MetadataStorageT, clean up error handling. 2023-02-03 01:05:09 +00:00
Logging.hs server: always add query type in http-log logs (whenever available) 2023-03-20 16:14:25 +00:00
MetadataOpenAPI.hs server: codecs for TableMetadata, FunctionMetadata, and permissions 2022-09-12 20:31:07 +00:00
Metrics.hs server: fix value of created_at for postgres event triggers 2023-03-22 07:32:42 +00:00
Middleware.hs server: rename SchemaCacheRef to AppStateRef and add AppContext to it 2023-03-17 10:30:38 +00:00
Migrate.hs chore(server): various code cleanups 2023-03-14 17:47:49 +00:00
Name.hs server: Reorganize quasi-quoted names. 2022-06-23 09:15:31 +00:00
OpenAPI.hs Rewrite OpenAPI 2022-06-30 12:57:09 +00:00
Prometheus.hs server: replicate log-based data transfer metrics as prometheus metrics 2022-12-28 03:49:33 +00:00
Rest.hs delete ExecutionCtx in favour of explicit argument passing 2023-03-21 12:37:21 +00:00
SchemaUpdate.hs Remove HasServerConfigCtx from the schema cache build. 2023-03-27 17:44:27 +00:00
Telemetry.hs Separate the metadata and cache representations of logical models 2023-03-02 16:04:18 +00:00
Types.hs Remove HasServerConfigCtx from the schema cache build. 2023-03-27 17:44:27 +00:00
Utils.hs server: webhook auth token caching 2023-03-14 18:28:56 +00:00
Version.hs Amend console assets versioning scheme for CE 2022-08-26 12:39:16 +00:00