Commit Graph

580 Commits

Author SHA1 Message Date
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
Daniel Harvey
cb9f822fc0 chore(server): move user-defined-functions into Hasura.Function.*
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8595
GitOrigin-RevId: b3b7dec8504fe4daf324125e4017fa7d1945b3ca
2023-04-03 10:20:20 +00:00
Daniel Harvey
79682e0598 chore(server): move custom types out of logical models
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8565
Co-authored-by: Tom Harding <6302310+i-am-tom@users.noreply.github.com>
GitOrigin-RevId: 38bf56cc420a6c818a9ca7d6f846f5018535c808
2023-03-31 15:35:13 +00:00
Auke Booij
79b8a6a07b chore(server): move some query tags code to a sensible place
Also add a `default` implementation for `MonadQueryTags`.

This avoids a bunch of imports on `Hasura.GraphQL.Execute.Backend` which is a big module with lots of (transitive) dependencies.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8571
GitOrigin-RevId: 8ecca452721b77953e6d088c79d8d6f003f2996f
2023-03-30 21:19:38 +00:00
Jesse Hallett
bd9f93eaef server: codecs for backend configs
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8269
GitOrigin-RevId: 34330f383ca82fb159842a171a763c178b462788
2023-03-30 15:53:55 +00:00
Daniel Harvey
7227e96278 feature(server): custom return types as discreet metadata entity
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8556
Co-authored-by: Tom Harding <6302310+i-am-tom@users.noreply.github.com>
GitOrigin-RevId: b7dcbcf378279c3bf4c8d223174b90c2cb4b9e53
2023-03-30 15:15:11 +00:00
paritosh-08
677a972956 server: improve connection template error message
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8517
GitOrigin-RevId: 3240e569322f3c9bf9376bbf4ea01c5d48218f07
2023-03-29 13:37:33 +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
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
Daniel Harvey
95f5553af6 chore(server): split new statistics log from QueryLog
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8326
GitOrigin-RevId: 02ee652302de5328e63054a6448dca10de7b5c1b
2023-03-15 13:06:47 +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
Daniel Chambers
dc83352863 Support for using Data Connectors as the target of remote relationships
[GDC-487]: https://hasurahq.atlassian.net/browse/GDC-487?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
[GDC-488]: https://hasurahq.atlassian.net/browse/GDC-488?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8182
GitOrigin-RevId: 712953666e1a5ea07500f1e1aed669f27650f7a4
2023-03-07 01:33:26 +00:00
Tom Harding
1574125f10 Separate the metadata and cache representations of logical models
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8176
GitOrigin-RevId: a1ead98ea9d07b30ee09298e7f27a139d87711fa
2023-03-02 16:04:18 +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
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
Gil Mizrahi
2b0e9ea14c rename NativeQuery module hierarchy to LogicalModel
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8063
GitOrigin-RevId: 0ed0cee7fb1d77f166770caae21cc05d5dd30b75
2023-02-22 09:23:54 +00:00
Gil Mizrahi
b761add3c4 rename naqi to logimo part 1
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8037
GitOrigin-RevId: 4839410ba836d4b69fd1ee30875bca9b46decc66
2023-02-21 13:46:44 +00:00
Krushan Bauva
2b1d5be10a server: catch TimeoutThread and InvalidRequest exceptions in websocket connections
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8014
GitOrigin-RevId: eef2d1ce99ec87bb239584c3ca4a9f056131b5cc
2023-02-21 11: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
17c3d25b1b server: warning in replace_metadata API
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7575
GitOrigin-RevId: 0171514056f725cb7a86dc7856eb57c674937c83
2023-02-20 14:20:38 +00:00
Daniel Harvey
3b42e704dd [server] Custom types prototype
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7807
Co-authored-by: Tom Harding <6302310+i-am-tom@users.noreply.github.com>
GitOrigin-RevId: ee3c644b92aa71a236d247a0cfc5deb7846f91c2
2023-02-15 17:56:58 +00:00
kodiakhq[bot]
b01d3a45de server: dev build modes
Add some configurations for modern profiling modes, and integration into dev.sh

These require cabal 3.8 due to the use of `import`

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7671
GitOrigin-RevId: f793f64105cfd99fb51b247fa8bc050f6d4bd23e
2023-02-08 22:43:00 +00:00
Gil Mizrahi
f90373b1ca NaQI - validate against the database - infra and check syntax
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7778
GitOrigin-RevId: c8366ad7261d9c120dc0612bedb96fa5ae59eda3
2023-02-03 16:29:22 +00:00
Auke Booij
e6db044ecc server: fix some hspec tests
- One test suite wasn't getting picked up due to it not satisfying the [criteria](https://hspec.github.io/hspec-discover.html) for `hspec-discover`
- One test was broken ever since it was introduced in hasura/graphql-engine-mono#5181. This wasn't picked up due to the module not satisfying `hspec-discover`'s criteria until more recently.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7801
GitOrigin-RevId: fd5c31ccf12d6d0c4be0dc7bf99f14d63caccc83
2023-02-03 14:09:19 +00:00
Daniel Harvey
e953efeb40 [ci] test the libraries in server/lib
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7758
Co-authored-by: Tom Harding <6302310+i-am-tom@users.noreply.github.com>
GitOrigin-RevId: 311f6c4a5c629c18a55d75a5d5a74f826078e86d
2023-02-02 17:32:48 +00:00
Philip Lykke Carlsen
69ae616ae5 Bump autodocodec to 0.2.0.3, ditch Data.Voidable
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7753
GitOrigin-RevId: c5dce6cf125b6bc53fd5ac7b689d1ed71fd6257b
2023-02-02 10:54:59 +00:00
Tom Harding
e41654b133 Reject MonadUnique, embrace IO
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7751
GitOrigin-RevId: 3edc4dee10d58afac911c9862e3b55a4c458a293
2023-02-01 18:57:46 +00:00
Tom Harding
18b346bf44 Extract Hasura.Incremental into lib/hasura-incremental
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7534
GitOrigin-RevId: 85863cee836d348e8e314f8af1b50bb5cd912b46
2023-02-01 12:25:33 +00:00
Daniel Harvey
17dbc7bc32 [server] parser for interpolated SQL queries
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7726
GitOrigin-RevId: 4b6ad28aa8a4d75bfcf6ce1ec4d89324f7f1ae74
2023-01-31 12:54:11 +00:00
Philip Lykke Carlsen
70c8bc8700 Integrating Native Query metadata and schema
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7657
Co-authored-by: Daniel Harvey <4729125+danieljharvey@users.noreply.github.com>
GitOrigin-RevId: d5047559e3560f5d7870eac6e07c89704146ccab
2023-01-30 16:06:34 +00:00
Auke Booij
c36c085016 server: enable all the warnings (that we can)
See [Enable all the warnings](https://medium.com/mercury-bank/enable-all-the-warnings-a0517bc081c3). This PR follows that approach, except that it re-disables those warnings that would prevent a successful build.

There are some newer warning flags that older GHC versions don't recognize. So this also updates some of our CI routines to the GHC version that we're currently using for `graphql-engine` itself, namely 9.2.5. I don't see a reason to keep testing those libraries against older GHC versions.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7614
GitOrigin-RevId: d48a6db09dab29616e273549d0045f98ecb4586f
2023-01-30 11:24:49 +00:00
Rakesh Emmadi
ab99215828 server: log when events of scheduled & event triggers are fetched from database for delivery
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7651
Co-authored-by: Sean Park-Ross <94021366+seanparkross@users.noreply.github.com>
GitOrigin-RevId: 3149dae41c6a8a16caa1d44fbc0606451d6d2cfa
2023-01-30 06:08:08 +00:00
Rakesh Emmadi
f2a5d7cef3 server/pro/multitenant: Postgres connection routing using kriti templates
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/6822
Co-authored-by: paritosh-08 <85472423+paritosh-08@users.noreply.github.com>
Co-authored-by: Naveen Naidu <30195193+Naveenaidu@users.noreply.github.com>
Co-authored-by: Sooraj <8408875+soorajshankar@users.noreply.github.com>
Co-authored-by: Varun Choudhary <68095256+Varun-Choudhary@users.noreply.github.com>
Co-authored-by: Sean Park-Ross <94021366+seanparkross@users.noreply.github.com>
GitOrigin-RevId: 61cfc00a97de88df1ede3f26829a0d78ec9c0bc5
2023-01-25 07:14:31 +00:00
Abby Sassel
85cda65261 server: introduce Native Query Interface prototype feature flag
[NDAT-490]: https://hasurahq.atlassian.net/browse/NDAT-490?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
[NDAT-491]: https://hasurahq.atlassian.net/browse/NDAT-491?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
[NDAT-468]: https://hasurahq.atlassian.net/browse/NDAT-468?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7487
Co-authored-by: Solomon <24038+solomon-b@users.noreply.github.com>
GitOrigin-RevId: ba679fc69df4b669fc7936cd359b8268e8e1a23a
2023-01-23 13:37:13 +00:00
Philip Lykke Carlsen
cd5186be90 Implement Schema Parsers for Native Query Interface
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7574
GitOrigin-RevId: 0cb4638a7dd79abf6ccb05092c0c663c84675bbd
2023-01-19 11:27:24 +00:00
Daniel Chambers
bfdeaf0334 Data Connectors insert mutations support [GDC-609]
[GDC-609]: https://hasurahq.atlassian.net/browse/GDC-609?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7513
GitOrigin-RevId: cb401e3ed84c5b60ec59b63dc478a1162b360135
2023-01-17 00:35:22 +00:00
Daniel Harvey
06b284cf33 [server] metadata API for native access
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7476
Co-authored-by: Tom Harding <6302310+i-am-tom@users.noreply.github.com>
GitOrigin-RevId: 781c29666e92004dc82918c2292fdacc27fded4c
2023-01-16 17:21:22 +00:00
Daniel Chambers
57607f5295 Refactor Update IR to generalize Update vs Update Many across backends - compositional approach [GDC-687]
[GDC-687]: https://hasurahq.atlassian.net/browse/GDC-687?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
[GDC-687]: https://hasurahq.atlassian.net/browse/GDC-687?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7355
GitOrigin-RevId: fa02a83c0c594abe05c1071d0de5054478c32e56
2023-01-10 01:56:14 +00:00
Lyndon Maydwell
d34bea3e97 Metadata API for Suggesting Relationships from HGE
[GDC-629]: https://hasurahq.atlassian.net/browse/GDC-629?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7420
GitOrigin-RevId: 0bf69f8409d5141783f9cf5d8d54f798d9e05e65
2023-01-09 07:26:55 +00:00
Daniel Harvey
9a59204525 [server/tests] Round trip tests for BigQuery types
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7310
GitOrigin-RevId: aaff93e6288ca933770d9ecfa6c5350ebf8177b3
2022-12-21 13:58:58 +00:00
Jesse Hallett
4d6604ba08 server: event trigger codecs
Codecs for event triggers, including webhook transforms. These are not hooked into the higher-up table metadata codec yet because some backend implementations implement event triggers with `error` which causes an error when codecs are evaluated. I plan to follow up with another PR to resolve that.

Ticket: https://hasurahq.atlassian.net/browse/GDC-585

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7237
GitOrigin-RevId: 8ce40fe6fedcf8b109d6ca50a505333df855a8ce
2022-12-15 20:38:21 +00:00
Brandon Simmons
6451d9c9ce server: refactor Hasura.Server.Compression for clarity/correctness
context: This is  foundation work, before we change how the server chooses to compress or not
part of effort: #5518

-----

Prior to this change it was difficult to understand how the functionality in this module related to the semantics of Accept-Encoding. We also didn't correctly handle directives with qvalues.

After this change certain technical infelicities are called out without modifying the behavior of the server; for instance we continue to fall back to identity (no compression) in the case where technically we're supposed to return 406, and we also  continue to treat `*` conservatively as meaning “use no compression”.

The only external change here is `gzip;q=x.y` now results in a zipped response.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7213
GitOrigin-RevId: 1910ffd70d29f1ab8825c601f1bd998be70ceeeb
2022-12-09 06:08:27 +00:00
kodiakhq[bot]
26ce8ff768 server: -O1 + -funfolding-use-threshold=640, for memory residency
...and keep binary size down using `--gc-sections` (supported by all major linkers). Stripped size after this PR is `85.3 Mb` down from `121 Mb` on `main`.

This compliments Auke's recent work (though there is some overlap). See: https://github.com/hasura/graphql-engine-mono/pull/7033#issuecomment-1326673632

Old experiments, for reference:
https://github.com/hasura/graphql-engine-mono/pull/6605
https://github.com/hasura/graphql-engine-mono/pull/6606
https://github.com/hasura/graphql-engine-mono/pull/6589

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7079
GitOrigin-RevId: 0b0d86730fb959d6249bd17a87e39af12ef71261
2022-11-30 17:05:15 +00:00
Daniel Chambers
ed79049637 Mutation Data Connector API types [GDC-594]
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/6893
GitOrigin-RevId: edf0f72027197ae61bfa8d27d53eabf6ca626112
2022-11-29 03:37:13 +00:00
Daniel Harvey
79b50add5e [server] regularly ping selected sources
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/6945
GitOrigin-RevId: cad67b121090d4100330067d3d50f575292b4584
2022-11-23 16:41:46 +00:00
awjchen
339e19048b server: update metadata api for the OpenTelemetry exporter
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/6844
GitOrigin-RevId: 3d808215fc46a79caf85a1c4d964ac874f905029
2022-11-23 07:54:53 +00:00
awjchen
329f3f0a39 multitenant: make shutdown logic more abstract
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5836
GitOrigin-RevId: 2f94cdee01702e49ff130f6a40f6be26fa69ec88
2022-11-23 07:53:19 +00:00
Auke Booij
cdac24c79f server: delete the Cacheable type class in favor of Eq
What is the `Cacheable` type class about?
```haskell
class Eq a => Cacheable a where
  unchanged :: Accesses -> a -> a -> Bool
  default unchanged :: (Generic a, GCacheable (Rep a)) => Accesses -> a -> a -> Bool
  unchanged accesses a b = gunchanged (from a) (from b) accesses
```
Its only method is an alternative to `(==)`. The added value of `unchanged` (and the additional `Accesses` argument) arises _only_ for one type, namely `Dependency`. Indeed, the `Cacheable (Dependency a)` instance is non-trivial, whereas every other `Cacheable` instance is completely boilerplate (and indeed either generated from `Generic`, or simply `unchanged _ = (==)`). The `Cacheable (Dependency a)` instance is the only one where the `Accesses` argument is not just passed onwards.

The only callsite of the `unchanged` method is in the `ArrowCache (Rule m)` method. That is to say that the `Cacheable` type class is used to decide when we can re-use parts of the schema cache between Metadata operations.

So what is the `Cacheable (Dependency a)` instance about? Normally, the output of a `Rule m a b` is re-used when the new input (of type `a`) is equal to the old one. But sometimes, that's too coarse: it might be that a certain `Rule m a b` only depends on a small part of its input of type `a`. A `Dependency` allows us to spell out what parts of `a` are being depended on, and these parts are recorded as values of types `Access a` in the state `Accesses`.

If the input `a` changes, but not in a way that touches the recorded `Accesses`, then the output `b` of that rule can be re-used without recomputing.

So now you understand _why_ we're passing `Accesses` to the `unchanged` method: `unchanged` is an equality check in disguise that just needs some additional context.

But we don't need to pass `Accesses` as a function argument. We can use the `reflection` package to pass it as type-level context. So the core of this PR is that we change the instance declaration from
```haskell
instance (Cacheable a) => Cacheable (Dependency a) where
```
to
```haskell
 instance (Given Accesses, Eq a) => Eq (Dependency a) where
```
and use `(==)` instead of `unchanged`.

If you haven't seen `reflection` before: it's like a `MonadReader`, but it doesn't require a `Monad`.

In order to pass the current `Accesses` value, instead of simply passing the `Accesses` as a function argument, we need to instantiate the `Given Accesses` context. We use the `give` method from the `reflection` package for that.
```haskell
give :: forall r. Accesses -> (Given Accesses => r) -> r

unchanged :: (Given Accesses => Eq a) => Accesses -> a -> a -> Bool
unchanged accesses a b = give accesses (a == b)
```
With these three components in place, we can delete the `Cacheable` type class entirely.

The remainder of this PR is just to remove the `Cacheable` type class and its instances.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/6877
GitOrigin-RevId: 7125f5e11d856e7672ab810a23d5bf5ad176e77f
2022-11-21 16:35:37 +00:00