Commit Graph

56 Commits

Author SHA1 Message Date
paritosh-08
bd55c39d3a server: fix schema registry server bugs
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9644
Co-authored-by: Auke Booij <164426+abooij@users.noreply.github.com>
GitOrigin-RevId: dc7be1dd63c2e3a7af8582cc6109992517386faf
2023-06-26 10:57:46 +00:00
Naveen Naidu
4796a9dd69 server/postgres: insert input validation [experimental]
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9620
Co-authored-by: Rakesh Emmadi <12475069+rakeshkky@users.noreply.github.com>
GitOrigin-RevId: 345c3f763f8dd3397c999c5967af39192b944640
2023-06-25 13:48:10 +00:00
Puru Gupta
f2fe9cfe3b server: add support for header resolution from env vars
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9509
GitOrigin-RevId: 818f747422c5444fcb55419729ad58d74b890d52
2023-06-23 08:39:28 +00:00
pranshi06
3124c93673 server: configurable header length limit for warp
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9363
GitOrigin-RevId: 8dd1e6a5f51d86ed20123c7ed7d42906fe5251bb
2023-06-19 12:34:35 +00:00
Philip Lykke Carlsen
5d76f9cabf Feat: No feature flags for Native Queries and Stored Procedures
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9541
GitOrigin-RevId: 81a33de3a35405c6e45cb5bad160ad00871745eb
2023-06-14 13:21:37 +00:00
paritosh-08
14b4de37f7 server: close subscriptions (with 1012) on metadata change
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9159
GitOrigin-RevId: 5ab25ef57782c126de8852f3546809feb66a9d44
2023-06-13 09:24:19 +00:00
Anon Ray
05862a4327 server: store collected source introspection to DB
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9237
Co-authored-by: Puru Gupta <32328846+purugupta99@users.noreply.github.com>
GitOrigin-RevId: 77327742db2f8440fdf770db5ae1c034cbb06e3b
2023-06-06 08:51:51 +00:00
Tom Harding
e0c0043e76 Upgrade Ormolu to 0.7.0.0
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9284
GitOrigin-RevId: 2f2cf2ad01900a54e4bdb970205ac0ef313c7e00
2023-05-24 13:53:53 +00:00
Sameer Kolhar
6d27ad97ae server: send request to schema_registry service every time the GQL schema is updated
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8922
Co-authored-by: Naveen Naidu <30195193+Naveenaidu@users.noreply.github.com>
GitOrigin-RevId: a0f3b0c2b2d039e9137ff816b41611e239ed2201
2023-05-24 12:51:19 +00:00
Puru Gupta
46451cf114 server: fetch and use stored introspection during Schema Cache (re)builds
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9272
GitOrigin-RevId: 08d7767489912ca1420453f5dda0e440352a19c0
2023-05-23 21:05:19 +00:00
Naveen Naidu
770407110c server: add total time, db exec time subscription metrics
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8899
Co-authored-by: paritosh-08 <85472423+paritosh-08@users.noreply.github.com>
Co-authored-by: Rob Dominguez <24390149+robertjdominguez@users.noreply.github.com>
GitOrigin-RevId: c8c4a89576ae95265a8e4f4e6803a12ba7e840d4
2023-05-18 12:57:26 +00:00
Daniel Chambers
c664e1fbba Add track_tables metadata API
[GDC-1198]: https://hasurahq.atlassian.net/browse/GDC-1198?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9120
GitOrigin-RevId: bb86acaf8b06529a34113a80c3fe2409c3d69a63
2023-05-16 04:05:02 +00:00
paritosh-08
ae49a3f9db server: add the env var for toggling metric granularity
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9034
GitOrigin-RevId: 24a4ae932b7467a53060025e2772edbebaf94b5b
2023-05-11 05:21:16 +00:00
Gil Mizrahi
d432eb4d3d Use a separate feature flag for stored procedures
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9040
GitOrigin-RevId: f577f34fd773cbc886546d7866e5a77603087a37
2023-05-04 12:45:37 +00:00
Daniel Harvey
a0b1d69392 chore(server): make native queries pro-only
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8926
GitOrigin-RevId: 68d2091c97ed80e86f851d656749eab865f73ec4
2023-04-27 14:31:53 +00:00
Tom Harding
4885a3fd9a Import J, not Aeson, A, JSON, Yaml...
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8948
GitOrigin-RevId: d70c4a50b94ffe7d42a1fb1017051d351f236acc
2023-04-26 17:30:24 +00:00
Tom Harding
7e334e08a4 Import HashMap, not HM, Map, M...
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8947
GitOrigin-RevId: 18e52c928e1df535579e2077b4af6c2ce92bdcef
2023-04-26 15:43:44 +00:00
Daniel Harvey
ea5c92acae chore(server): move Hasura.SQL.Backend to Hasura.RQL.Types.BackendType
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8876
GitOrigin-RevId: abfc18eeef96a1f3593bfe823adab4d161161333
2023-04-24 18:37:33 +00:00
Tom Harding
f8ae944dbc Move Hasura.GraphQL.Schema.Options to Hasura.RQL.Types.Options
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8877
GitOrigin-RevId: 8be82f60a57cd9582d6980a6dea2f34c7b0c13c1
2023-04-24 15:18:56 +00:00
Tom Harding
1698f9dd91 Extract RoleName from Hasura.Session, move it into Hasura.RQL.Types.Roles
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8856
Co-authored-by: Daniel Harvey <4729125+danieljharvey@users.noreply.github.com>
GitOrigin-RevId: 38ad67de9b3d765c4eb50943dd52b8fc32317540
2023-04-24 08:51:58 +00:00
Karthikeyan Chinnakonda
9869e3fcf4 Server: add hasura_active_subscription_pollers_in_error_state metric [Subscriptions observability - 2]
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8808
GitOrigin-RevId: 9686125e87bdf06cdb4b133d236bfa64c61bb6f3
2023-04-24 07:44:04 +00:00
Antoine Leblanc
0476331136 small cleanups of pro's init
### Description

(This PR is better reviewed commit by commit.)

This PR is an aggregation of small incremental changes to Pro's init:
- it deletes some dead code,
- it starts reorganizing the code of that file by sections, similar to OSS' init,
- it extracts and cleans up license key cache init (groups several blocks of code in one separate function)
- makes some changes to a service class to reduce the dependency on `_acAppStateRef`

This PR is a first step: our goal is to move the schema cache build _in_ the app monad, in order to achieve #8344. To do so, we will need to remove `_acAppStateRef` from Pro's `AppContext`. There are two different paths we can take from here, which is why i cut this PR here:
- the first would be to change the different instances we implement on `AppM` to take as an argument the parts of the schema cache they depend on, rather than reading them from `_acAppStateRef`; as of this PR, `MetricsConfig` is the only such field;
- the second would be to apply the same strategy we already used for the TLSAllowList, and use a `IORef` that can be updated after the schema cache is built; this change would have a smaller footprint, but introduces one new `IORef` per such field, which feels something we don't want to generalize

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8655
GitOrigin-RevId: 809697d460bdb5c83ef7d30a2e835f589bcd80a6
2023-04-06 15:37:15 +00:00
Antoine Leblanc
e6a8bcb1c9 Make flag value a part of the cache's dynamic config.
### Description

If i understand correctly, the _value_ of a feature flag **can** change at runtime. Since this has an impact on how the schema cache is built, this PR makes the value of the flag a part of the cache's "dynamic" config, therefore making it an arrow-ish argument for the incremental framework. It also removes `CheckFeatureFlag` from the static config, now obsolete.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8631
GitOrigin-RevId: 2ca898e4193e8552c40d2b21a819d3dd414601fe
2023-04-04 19:39:39 +00:00
Antoine Leblanc
306162f477 Remove ServerConfigCtx.
### Description

This PR removes `ServerConfigCtx` and `HasServerConfigCtx`. Instead, it favours different approaches:
- when the code was only using one field, it passes that field explicitly (usually `SQLGenCtx` or `CheckFeatureFlag`)
- when the code was using several fields, but in only one function, it inlines
- for the cache build, it introduces `CacheStaticConfig` and `CacheDynamicConfig`, which are subsets of `AppEnv` and `AppContext` respectively

The main goal of this is to help with the modularization of the engine: as `ServerConfigCtx` had fields whose types were imported from several unrelated parts of the engine, using it tied together parts of the engine that should not be aware of one another (such as tying together `Hasura.LogicalModel` and `Hasura.GraphQL.Schema`).

The bulk of this PR is a change to the cache build, as a follow up to #8509: instead of giving the entire `ServerConfigCtx` as a incremental rule argument, we only give the new `CacheDynamicConfig` struct, which has fewer fields. The other required fields, that were coming from the `AppEnv`, are now given via the `HasCacheStaticConfig` constraint, which is a "subset" of `HasAppEnv`.

(Some further work could include moving `StringifyNumbers` out of `GraphQL.Schema.Options`, given how it is used all across the codebase, including in `RQL.DML`.)

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8513
GitOrigin-RevId: 818cbcd71494e3cd946b06adbb02ca328a8a298e
2023-04-04 16:01:42 +00:00
Auke Booij
7cc33dd8ec server: refactor Hasura.Metadata.Class
- Remove `MonadMetadataStorageQueryAPI` which was only implemented by a default implementation
- Introduce `TransT` which can be used to easily derive `lift`ing implementations for `MonadBlaBlaBla` classes

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8579
GitOrigin-RevId: 4f804fda7e2de5c9d75ee4df269f500ebd46b8c9
2023-04-03 13:36:50 +00:00
Anon Ray
5a81eaa9b6 server: core changes for zero-downtime env vars update on cloud
[GS-232]: https://hasurahq.atlassian.net/browse/GS-232?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7207
Co-authored-by: pranshi06 <85474619+pranshi06@users.noreply.github.com>
Co-authored-by: Rakesh Emmadi <12475069+rakeshkky@users.noreply.github.com>
Co-authored-by: Puru Gupta <32328846+purugupta99@users.noreply.github.com>
Co-authored-by: Naveen Naidu <30195193+Naveenaidu@users.noreply.github.com>
GitOrigin-RevId: 90a771036da5275cd277f3daaf410381955c69de
2023-03-30 16:33:39 +00:00
Auke Booij
cfd33e0dba ci(server): fix hlint ignore pragmas
Some fixes as a followup to #8311. In particular, some pragmas were referring to a now-nonexistent hlint rule.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8569
GitOrigin-RevId: 2a180427b3e93a71c47569ff10b6c8b6b407f7a2
2023-03-30 14:31:59 +00:00
Rakesh Emmadi
bfca9fd986 server/gardening: refactor scMetadataResourceVersion in SchemaCache
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8377
GitOrigin-RevId: 999a5112f8940b267c2765f4bed39bf6151f18f0
2023-03-28 13:27:32 +00:00
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
Antoine Leblanc
dd635fbbc7 Build the first schema cache in the app monad.
### Description

This PR is one more step towards #8344: it splits `initializeContext` into two parts: the first one builds the `AppEnv`, and the second builds the `AppContext` and its corresponding `AppStateRef`. Splitting it allows us to run the first schema cache build _in the app monad_, which was one of the steps required to remove `CacheBuild`, and ultimately to achieve #8344, which in turn is a blocker for several projects.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8445
GitOrigin-RevId: 0ef9eeec0c941b915da505cc9b1c60f36b108a56
2023-03-27 10:27:25 +00:00
Antoine Leblanc
068b5e4523 Rename and clean CE app monad.
### Description

This small PR is on top of #8440. It continues the cleanup of `Hasura/App` by grouping together all instances on the app monad, renaming the app monad, and removing its `m` parameter.

See [this commit](cb6ecba3d4) to see the diff in isolation.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8441
GitOrigin-RevId: 7abb6524a160bcb4f75e729e726ce2af69643998
2023-03-23 15:52:48 +00:00
Antoine Leblanc
d7309b811e Partial cleanup of Hasura/App, refactor of GlobalCtx
### Description

As part of another project (the continuation of #8421), i have started a cleanup of `Hasura.App`, focusing on deleting old code and grouping together things that belong together. This quickly grew into a refactor of `GlobalCtx`, now renamed into `BasicConnectionInfo`. This small refactor adds comments, and aims at making clear what the purpose of those types and functions is.

Furthermore, it also changes the way the default postgres connection info is created, by making that part of the process of creating the `BasicConnectionInfo`, to deduplicate similar effort across different files.

This is expected to be a no-op.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8440
GitOrigin-RevId: 412c5b1905f629beb9c6cd262b9798cb31c93bdb
2023-03-22 21:41:53 +00:00
Philip Lykke Carlsen
34e40e6caf refactor: newtype alias for action checking feature flags
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8429
GitOrigin-RevId: e543b608a91e0c39c39f06b772a7d43f360d5dc3
2023-03-22 10:48:22 +00:00
Antoine Leblanc
0a1628c0cc Clean AppEnv and AppContext passing, remove RunT, reduce ServerConfigCtx uses
## Description

This PR does several different things that happen to overlap; the most important being:
- it removes `RunT`: it was redundant in places where we already had `Handler`, and only used in one other place, `SchemaUpdate`, for which a local `SchemaUpdateT` is more than enough;
- it reduces the number of places where we create a `ServerConfigCtx`, since now `HasServerConfigCtx` can be implemented directly by `SchemaUpdateT` and `Handler` based on the full `AppContext`;
- it drastically reduces the number of arguments we pass around in the app init code, by introducing `HasAppEnv`;
- it simplifies `HandlerCtx` to reduce duplication

In doing so, this changes paves the way towards removing `ServerConfigCtx`, since there are only very few places where we construct it: we can now introduce smaller classes than `HasServerConfigCtx`, that expose only a relevant subset of fields, and implement them where we now implement `HasServerConfigCtx`.

This PR is loosely based on ideas in #8337, that are no longer applicable due to the changes introduced in #8159. A challenge of this PR was the postgres tests, which were running in `PGMetadataStorageAppT CacheBuild` 🙀

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8392
GitOrigin-RevId: b90c1359066d20dbea329c87762ccdd1217b4d69
2023-03-21 10:45:56 +00:00
awjchen
4f6240fb04 server: refactor ConnectionTemplateResolver
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8381
GitOrigin-RevId: 5286c384bb8c739170c90960a9b4a324a629c43b
2023-03-20 21:56:20 +00:00
Puru Gupta
c437a42f6d server: rename SchemaCacheRef to AppStateRef and add AppContext to it
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8159
Co-authored-by: Naveen Naidu <30195193+Naveenaidu@users.noreply.github.com>
Co-authored-by: Anon Ray <616387+ecthiender@users.noreply.github.com>
GitOrigin-RevId: a57f6dc8b3e992d86490e5c51508827f00151dfe
2023-03-17 10:30:38 +00:00
paritosh-08
91552a1a05 server: move apollo-federation to GA
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8163
Co-authored-by: Tirumarai Selvan <8663570+tirumaraiselvan@users.noreply.github.com>
GitOrigin-RevId: d971720e79d5e08d1e68b31f7475c0eb6f06cac8
2023-03-15 08:15:51 +00:00
Antoine Leblanc
cf531b05cb Rewrite Tracing to allow for only one TraceT in the entire stack.
This PR is on top of #7789.

### Description

This PR entirely rewrites the API of the Tracing library, to make `interpTraceT` a thing of the past. Before this change, we ran traces by sticking a `TraceT` on top of whatever we were doing. This had several major drawbacks:
- we were carrying a bunch of `TraceT` across the codebase, and the entire codebase had to know about it
- we needed to carry a second class constraint around (`HasReporterM`) to be able to run all of those traces
- we kept having to do stack rewriting with `interpTraceT`, which went from inconvenient to horrible
- we had to declare several behavioral instances on `TraceT m`

This PR rewrite all of `Tracing` using a more conventional model: there is ONE `TraceT` at the bottom of the stack, and there is an associated class constraint `MonadTrace`: any part of the code that happens to satisfy `MonadTrace` is able to create new traces. We NEVER have to do stack rewriting, `interpTraceT` is gone, and `TraceT` and `Reporter` become  implementation details that 99% of the code is blissfully unaware of: code that needs to do tracing only needs to declare that the monad in which it operates implements `MonadTrace`.

In doing so, this PR revealed **several bugs in the codebase**: places where we were expecting to trace something, but due to the default instance of `HasReporterM IO` we would actually not do anything. This PR also splits the code of `Tracing` in more byte-sized modules, with the goal of potentially moving to `server/lib` down the line.

### Remaining work

This PR is a draft; what's left to do is:
- [x] make Pro compile; i haven't updated `HasuraPro/Main` yet
- [x] document Tracing by writing a note that explains how to use the library, and the meaning of "reporter", "trace" and "span", as well as the pitfalls
- [x] discuss some of the trade-offs in the implementation, which is why i'm opening this PR already despite it not fully building yet
- [x] it depends on #7789 being merged first

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7791
GitOrigin-RevId: cadd32d039134c93ddbf364599a2f4dd988adea8
2023-03-13 17:38:39 +00:00
pranshi06
823fca2d1c multitenant, server: throw a warning if user sets a time limit greater than the system limit
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7315
Co-authored-by: Sean Park-Ross <94021366+seanparkross@users.noreply.github.com>
GitOrigin-RevId: 639a99fc0651b74f187108613be3086bc52e3a65
2023-03-13 11:45:45 +00:00
Philip Lykke Carlsen
8d02c88c1a refactor(github, hlint): Add hlint white-list of modules that can import backend instances
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8133
Co-authored-by: Tom Harding <6302310+i-am-tom@users.noreply.github.com>
GitOrigin-RevId: 2c8aded4e77003d176931432e33e6d4c8cccfc6c
2023-03-02 14:45:57 +00:00
Puru Gupta
4e7fbbc2d6 server: use only server context and app env for dependent functions (remove passing of ServeOptions)
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7920
Co-authored-by: Rakesh Emmadi <12475069+rakeshkky@users.noreply.github.com>
GitOrigin-RevId: 6ebc4d0429fdfecf93950879b69e8b5f8f56b502
2023-02-28 09:11:27 +00:00
Puru Gupta
50f0e1df51 server: centralize various application state (introducing AppContext and AppEnv)
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8108
Co-authored-by: Rakesh Emmadi <12475069+rakeshkky@users.noreply.github.com>
Co-authored-by: Naveen Naidu <30195193+Naveenaidu@users.noreply.github.com>
Co-authored-by: Anon Ray <616387+ecthiender@users.noreply.github.com>
GitOrigin-RevId: 4a1f1ba960be4e0d4838188645d10162c73ecf06
2023-02-24 18:11:05 +00:00
Daniel Harvey
fbab8cd755 Revert "server: centralize various application state (introducing AppContext and AppEnv)"
The Postgres integration tests failed [here](https://buildkite.com/hasura/graphql-engine-mono/builds/30176#01867eb5-9635-4aaf-a147-44d43df03cbd), yet this merged. Looks like a missing required check. Have resolved that, but in the meantime, we should revert this PR until the test can be fixed.

Reverts hasura/graphql-engine-mono#7905

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8107
GitOrigin-RevId: 6ea329bc54f42d8c8686c5d26f0b2dbd43f991cf
2023-02-24 11:27:16 +00:00
Philip Lykke Carlsen
1af8d53c6f refactor(hlint): Demote Environment-from-OS to a suggestion
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8092
GitOrigin-RevId: 042aec936638fcb7890ecaa8cb368ed442100904
2023-02-23 21:44:44 +00:00
Puru Gupta
f45928b03b server: centralize various application state (introducing AppContext and AppEnv)
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7905
Co-authored-by: Rakesh Emmadi <12475069+rakeshkky@users.noreply.github.com>
Co-authored-by: Naveen Naidu <30195193+Naveenaidu@users.noreply.github.com>
Co-authored-by: Anon Ray <616387+ecthiender@users.noreply.github.com>
GitOrigin-RevId: 74ce763b266dc053c10888767d5b4a0d9692508a
2023-02-23 14:45:24 +00:00
Antoine Leblanc
6e574f1bbe harmonize network manager handling
## Description

### I want to speak to the `Manager`

Oh boy. This PR is both fairly straightforward and overreaching, so let's break it down.

For most network access, we need a [`HTTP.Manager`](https://hackage.haskell.org/package/http-client-0.1.0.0/docs/Network-HTTP-Client-Manager.html). It is created only once, at the top level, when starting the engine, and is then threaded through the application to wherever we need to make a network call. As of main, the way we do this is not standardized: most of the GraphQL execution code passes it "manually" as a function argument throughout the code. We also have a custom monad constraint, `HasHttpManagerM`, that describes a monad's ability to provide a manager. And, finally, several parts of the code store the manager in some kind of argument structure, such as `RunT`'s `RunCtx`.

This PR's first goal is to harmonize all of this: we always create the manager at the root, and we already have it when we do our very first `runReaderT`. Wouldn't it make sense for the rest of the code to not manually pass it anywhere, to not store it anywhere, but to always rely on the current monad providing it? This is, in short, what this PR does: it implements a constraint on the base monads, so that they provide the manager, and removes most explicit passing from the code.

### First come, first served

One way this PR goes a tiny bit further than "just" doing the aforementioned harmonization is that it starts the process of implementing the "Services oriented architecture" roughly outlined in this [draft document](https://docs.google.com/document/d/1FAigqrST0juU1WcT4HIxJxe1iEBwTuBZodTaeUvsKqQ/edit?usp=sharing). Instead of using the existing `HasHTTPManagerM`, this PR revamps it into the `ProvidesNetwork` service.

The idea is, again, that we should make all "external" dependencies of the engine, all things that the core of the engine doesn't care about, a "service". This allows us to define clear APIs for features, to choose different implementations based on which version of the engine we're running, harmonizes our many scattered monadic constraints... Which is why this service is called "Network": we can refine it, moving forward, to be the constraint that defines how all network communication is to operate, instead of relying on disparate classes constraint or hardcoded decisions. A comment in the code clarifies this intent.

### Side-effects? In my Haskell?

This PR also unavoidably touches some other aspects of the codebase. One such example: it introduces `Hasura.App.AppContext`, named after `HasuraPro.Context.AppContext`: a name for the reader structure at the base level. It also transforms `Handler` from a type alias to a newtype, as `Handler` is where we actually enforce HTTP limits; but without `Handler` being a distinct type, any code path could simply do a `runExceptT $ runReader` and forget to enforce them.

(As a rule of thumb, i am starting to consider any straggling `runReaderT` or `runExceptT` as a code smell: we should not stack / unstack monads haphazardly, and every layer should be an opaque `newtype` with a corresponding run function.)

## Further work

In several places, i have left TODOs when i have encountered things that suggest that we should do further unrelated cleanups. I'll write down the follow-up steps, either in the aforementioned document or on slack. But, in short, at a glance, in approximate order, we could:

- delete `ExecutionCtx` as it is only a subset of `ServerCtx`, and remove one more `runReaderT` call
- delete `ServerConfigCtx` as it is only a subset of `ServerCtx`, and remove it from `RunCtx`
- remove `ServerCtx` from `HandlerCtx`, and make it part of `AppContext`, or even make it the `AppContext` altogether (since, at least for the OSS version, `AppContext` is there again only a subset)
- remove `CacheBuildParams` and `CacheBuild` altogether, as they're just a distinct stack that is a `ReaderT` on top of `IO` that contains, you guessed it, the same thing as `ServerCtx`
- move `RunT` out of `RQL.Types` and rename it, since after the previous cleanups **it only contains `UserInfo`**; it could be bundled with the authentication service, made a small implementation detail in `Hasura.Server.Auth`
-  rename `PGMetadaStorageT` to something a bit more accurate, such as `App`, and enforce its IO base

This would significantly simply our complex stack. From there, or in parallel, we can start moving existing dependencies as Services. For the purpose of supporting read replicas entitlement, we could move `MonadResolveSource` to a `SourceResolver` service, as attempted in #7653, and transform `UserAuthenticationM` into a `Authentication` service.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7736
GitOrigin-RevId: 68cce710eb9e7d752bda1ba0c49541d24df8209f
2023-02-22 15:55:54 +00:00
Philip Lykke Carlsen
e979a39f6d chore: Fix all outstanding hlint hints
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8042
GitOrigin-RevId: 87c718fa7b09f375ea0e7c2465788ac49f575290
2023-02-20 17:43:28 +00:00
paritosh-08
775bdc8026 server: move event trigger schedule cleanup logic
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7606
Co-authored-by: Krushan Bauva <31391329+krushanbauva@users.noreply.github.com>
GitOrigin-RevId: 95819347aff4e6a86b2bc9acf214222e05dba496
2023-02-03 12:30:00 +00:00
Antoine Leblanc
e99f9a2f57 Remove MetadataStorageT, clean up error handling.
## Description

This PR removes `MetadataStorageT`, and cleans up all top-level error handling. In short: this PR changes `MonadMetadataStorage` to explicitly return a bunch of `Either QErr a`, instead of relying on the stack providing a `MonadError QErr`. Since we implement that class on the base monad *below any ExceptT*, this removes a lot of very complicated instances that make assumptions about the shape of the stack.

On the back of this, we can remove several layers of ExceptT from the core of the code, including the one in `RunT`, which allows us to remove several instances of `liftEitherM . runExceptT`.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7689
GitOrigin-RevId: 97d600154d690f58c0b93fb4cc2d30fd383fd8b8
2023-02-03 01:05:09 +00:00
Solomon
7842bc34ee Refactor/move namingcase default into arg merging
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5289
GitOrigin-RevId: 39c5a5b839534dc5416d62ca20c5051ae4d8ef57
2023-01-30 05:00:54 +00:00