Commit Graph

1980 Commits

Author SHA1 Message Date
Samir Talwar
061b2be9f1 server/tests-py: Fail fast and log more when HTTP requests hang.
`requests` does not set a default timeout, so tests can hang forever if you get something wrong.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5457
GitOrigin-RevId: 379d97705d6b52b019213cd46f92f3892dc8a46b
2022-08-15 12:40:17 +00:00
Tom Harding
147927e060 Mark RequestHeadersSpec explicitly as a regression test
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5364
GitOrigin-RevId: cef9a8c5c59e428c5c9b08af3a10b9f7012fa7cf
2022-08-15 11:38:16 +00:00
awjchen
1a4e3ae001 server: add event trigger metrics for Prometheus
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5346
GitOrigin-RevId: 0db925f85e06e99b636995887c0e19a49fe9be2d
2022-08-15 05:34:04 +00:00
Gil Mizrahi
e626d87a3c server/postgres: Long identifiers in insert with parameters
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5466
Co-authored-by: Brandon Martin <40686+codedmart@users.noreply.github.com>
GitOrigin-RevId: dbc028529081de6257cc24acd1a5bfde8b39d057
2022-08-12 00:27:31 +00:00
Philip Lykke Carlsen
6fe8b42798 Simplify instance boilerplate
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5412
GitOrigin-RevId: 19755ee2502758616d67ce42df7295424b61b6cf
2022-08-11 16:32:41 +00:00
Abby Sassel
26bbe2be34 server/tests: bigquery scalar type tests
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5405
Co-authored-by: Gil Mizrahi <8547573+soupi@users.noreply.github.com>
GitOrigin-RevId: fc0a509500068331f9d80d58b411f144e011f094
2022-08-11 15:37:07 +00:00
Gil Mizrahi
0922a3bb24 server/tests-hspec: delete Context and using NonEmpty for Fixtures
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5451
GitOrigin-RevId: 8847af09a83293c619326d22209289397911bc5a
2022-08-11 15:04:11 +00:00
Auke Booij
a96e0c33cd Refactor EncJSON: fewer footguns, better syntax
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5408
GitOrigin-RevId: 077afebc09e6aed6f201d5ed686d6f6e7050bf24
2022-08-11 14:19:29 +00:00
Auke Booij
4d5ee4c17e Inline a whole bunch of nothing for BackendSchema
This makes it easier to refactor `BackendSchema`, because if the type of a type class method is changed, it's easier to update the corresponding dummy implementations.

Partially addresses hasura/graphql-engine-mono#2971, in the sense that this aids refactors.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5443
GitOrigin-RevId: 65e169d01415a04e7c419a628cf32e743448543d
2022-08-11 11:58:40 +00:00
Daniel Harvey
c41fbfbb49 tests: tests-hspec docs to use Fixture
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5448
GitOrigin-RevId: 87b54feaef9dcf1139d64e85303797a9a273bda3
2022-08-11 11:02:02 +00:00
Evie Ciobanu
80cbf3ae33 server/nada: add unit test infrastructure for Postgres delete SQL generation
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5434
GitOrigin-RevId: 839a45a1469272def9d28c0f3e7454a5bf506f35
2022-08-11 10:46:49 +00:00
Daniel Harvey
99509da1f2 tests: convert EventTrigger hspec tests to use Fixture
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5432
GitOrigin-RevId: 402aa785255333bc90b6df6a398eefb09611dee0
2022-08-11 10:12:56 +00:00
Auke Booij
8888e06bbb Spell out the TH in Hasura.SQL.{Tag,AnyBackend}
The module `Hasura.SQL.AnyBackend` was introduced (in #751) to centralize the logic for case-switching behavior that depends on the particular flavor of relational DB backend (Postgres vs MSSQL vs BigQuery vs MySQL vs DataConnectors). This allows us to write a bunch of code in a backend-agnostic way, even if runtime behavior does depend on the chosen backend. At the same time, it allows us to write backend-specific code without having to care (too much) about the existence of other backends.

In #851 this module was rewritten to use Template Haskell.

I've heard that one of the reasons for the use of TH was that this would make it easier to keep backends out of the compilation product entirely. This would allow customers, especially on OSS, to benefit from simpler software licensing.

However:
1. This conditional compilation never materialized.
2. It's not clear whether writing this particular module based on TH would be sufficient for conditional compilation. And in any case, it can be done using CPP pragmas as well.
3. The TH code is extraordinarily complex. Since its introduction, it has been documented extraordinarily well, but it's still very difficult to maintain and/or refactor, due to its non-idiomatic nature.
4. Hasura's company objectives are now Cloud-oriented, so that software licensing issues work differently, and in particular, do not depend on what's part of the compilation product.

So this PR reverts on #851 by spelling out the code generated by TH. This is a net-negative diff size. IOW we used to generate less code than the size of the code doing the generating. This makes the code readable and maintainable.

The generated code has been modified in one way, which I'll now describe.

In the scenario that support for a new backend is introduced, a constructor is added to the `BackendType` type. This would then cause `liftTag` to be partial, thus raising a compiler warning. Resolving this requires adding corresponding constructors to the `BackendTag` and `AnyBackend` types. This would then require amending **almost** all other methods.

The exceptions are `composeAnyBackend` and `unpackAnyBackend`. These methods test whether two values are compatible, i.e. belong to the same backend. Both have a default case that in one way or another ignores the input values. Using TH here ensures that all values that belong together are caught. But after spelling out the TH, the presence of the default case means that no compiler warning is thrown for a missing match of matching values. So in the default case, we now do an explicit check for equality. If there _is_ an equality, that means that there is a missing `case`. So this is reported as an `error` (which is very crude, but it should be).

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5333
GitOrigin-RevId: 5aaf0a93394bd740aa7371526d3175c8142b3541
2022-08-11 09:11:07 +00:00
Antoine Leblanc
3b7cfcd10a move strictness where it is needed
### Description

This PR moves some strictness annotations to a concrete use site, rather than putting `seq` in an helper function.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5436
GitOrigin-RevId: 1f279e05333ab80167ad2e18d09b8792eddc52c3
2022-08-11 07:53:44 +00:00
Gil Mizrahi
51ceff71f7 server/tests-hspec: port Context to Fixture - DisableRootFields
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5430
GitOrigin-RevId: f31a692c0f2ac4dd6c88b2c60c9aeb26d6f5bfae
2022-08-11 07:25:39 +00:00
Solomon
7ae2a491ec Gardening: Cleanup Metadata Types Module
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5416
GitOrigin-RevId: 1d2d29da825942f9a0a472d034e68f0eb09a5c26
2022-08-10 23:19:25 +00:00
Gil Mizrahi
c08bb5377f server/tests-hspec: porting more tests to fixture
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5404
GitOrigin-RevId: 0be4f50b17765a8f0b1fb37944777ead7ec6bfc9
2022-08-10 20:38:39 +00:00
Solomon
3855efa9a5 Move soEventsHttpPoolSize and soEventsFetchInterval defaulting into arg parser
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5284
GitOrigin-RevId: f2302b3219f3aa9ebde623b4efa7f3ee8a97c031
2022-08-10 19:18:11 +00:00
Daniel Harvey
2bdc54ebb4 tests: convert RemoteRelationships hspec tests to use Fixture
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5424
GitOrigin-RevId: 0b23ba62aa0e2d279d8238aecd6c84ef8994097e
2022-08-10 16:45:19 +00:00
Daniel Harvey
548edcc6e6 tests: convert InsertDefaults Context test to Fixture
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5382
GitOrigin-RevId: 3964dda7307bde6e294be36791a76c8e459afa25
2022-08-10 16:16:49 +00:00
Vishnu Bharathi
a785c664e5 ci: tag release v2.10.0 and v2.11.0-beta.1
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5423
Co-authored-by: Rikin Kachhia <54616969+rikinsk@users.noreply.github.com>
GitOrigin-RevId: c0513156c9527f58bab86e8a67435e7be6ee035d
2022-08-10 13:54:03 +00:00
Gil Mizrahi
d5936a0a9b server/tests-hspec: port Context to Fixture - permissions
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5420
GitOrigin-RevId: aaf785b05bf54d8996c3f3c5148dd6c52e6aea5c
2022-08-10 13:09:07 +00:00
Karthikeyan Chinnakonda
f3dd172821 server: accept extensions_schema while adding a source
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5401
Co-authored-by: Naveen Naidu <30195193+Naveenaidu@users.noreply.github.com>
GitOrigin-RevId: 75b68c439fc68662a8e312f84132126d761dda48
2022-08-10 09:42:09 +00:00
Daniel Harvey
7bb5c2760a tests: convert DataConnector hspec tests from Context -> Fixture
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5388
GitOrigin-RevId: d645b360cd6f471c4bcaa18842cb2de2dc7a04d8
2022-08-10 07:54:26 +00:00
Gil Mizrahi
e1d0fbe0ff Fix querying multicolumn relationship in bigquery
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5407
GitOrigin-RevId: 21517278991a54a0f06231a10b36b7b69e352608
2022-08-09 18:40:39 +00:00
Karthikeyan Chinnakonda
66caae4a44 server: accept schema name as a target for the graphql-engine to install DB extensions
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5362
GitOrigin-RevId: 5e246c3af3bdf2a7b5b2a66e2e09f40abcdfd9c9
2022-08-09 11:43:48 +00:00
Tom Harding
d26b16106f Migrate ViewsSpec to the new structure
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5337
Co-authored-by: Gil Mizrahi <8547573+soupi@users.noreply.github.com>
GitOrigin-RevId: c1056790b42039630d649c96ad7aa2aa5c691ecf
2022-08-09 11:16:30 +00:00
Daniel Harvey
f3aefc8418 tests: expose SchemaName from Harness.Test.Schema
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5389
GitOrigin-RevId: fae69b4f49068bd05d6799f62d56b58bcbb96d06
2022-08-09 09:34:56 +00:00
Daniel Harvey
bcd7c01161 tests: Convert more Context -> Fixture in hspec tests
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5384
GitOrigin-RevId: 582583b1722bb9942eda96c6b418eff8a69921d5
2022-08-09 08:21:23 +00:00
Tom Harding
0460d7d6d1 Migrate CustomFieldNamesSpec to the new structure
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5323
Co-authored-by: Gil Mizrahi <8547573+soupi@users.noreply.github.com>
GitOrigin-RevId: 612cb72edf61227d8315102cb22eaaa603405b86
2022-08-09 07:26:14 +00:00
Daniel Harvey
744c03a84e tests: create BigQuery datasets for each test
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5288
GitOrigin-RevId: 7caedacd280fc6f8ea71af16397bb2c9641effc8
2022-08-08 14:29:51 +00:00
Antoine Leblanc
6c14a018e4 Run the reader context per schema block
### Description

This PR is a first step towards having a dedicated reader context per schema block. It adds the required Reader instance, and switches from a `SchemaT ReaderT` stack to a `ReaderT SchemaT` stack. Furthermore, it cleans up / harmonizes some of the top-level schema building functions.

Sources and remotes are now built each within their own run of `runReaderT`: for now, the reader context is the same in both cases, meaning no special care is required at the boundary of remote relationships.

Actions are explicitly run with the source context for now; we could envision creating a third and distinct context for them.

This PR is expected to be a no-op.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5300
GitOrigin-RevId: a014e5b3504eb4ef740c820d305d6d2695f622f7
2022-08-08 13:05:51 +00:00
Tom Harding
70f5b04ea2 Update InsertVarcharColumnSpec test
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5353
GitOrigin-RevId: 74f6e0a9322aa8926a162f8cfaae112669003f0b
2022-08-08 12:21:21 +00:00
Tom Harding
59d5853a95 Move EnumSpec into the Schema directory
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5324
GitOrigin-RevId: 50aa48c1ef42ee73b76742ab934ab90c5153b855
2022-08-08 10:56:35 +00:00
Evie Ciobanu
72cfb7fc9b server/nada: test mkUpdateCTE
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5341
GitOrigin-RevId: 39db14cc2d2329d8cadb7a6080b1e2361eba1fb5
2022-08-05 21:42:19 +00:00
Philip Lykke Carlsen
13113a5387 Reformat instance declarations
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5332
GitOrigin-RevId: 58b40e445dc0eac5e15efa725eaee128989aeeb5
2022-08-05 15:29:01 +00:00
Samir Talwar
aa18f65217 server: Move the schema parsers to their own library.
It's about time.

To do this I had to check a few more boxes.

* I copied the flags from `graphql-engine.cabal` to the libraries in `server/lib`.
* I moved `Cacheable` instances of schema parser types beside the typeclass declaration.
* I removed imports of `Hasura.Prelude` from the tests, and rewrote them accordingly.
* I copied the `TestMonad` parse monad into `server/src-test/Hasura/GraphQL/Schema/RemoteTest.hs`, which was using it. I think this could be done with the real thing, but I tried replacing it with constraints and it messed with my head somewhat.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5311
GitOrigin-RevId: ebebcc50a16f2d517b7f730fe72410827ca3e86c
2022-08-05 13:53:39 +00:00
Tom Harding
a61741fbf5 Migrate the GatheringUniqueConstraintsSpec test to the new structure
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5350
GitOrigin-RevId: ae622a859af4c308daf1aacc2825657ec7f0f8ab
2022-08-05 12:22:57 +00:00
Puru Gupta
2ca81b37e8 multitenant: fix dubious config status updates during tenant start
## Description ✍️
This PR fixes the config status update when the `Service configured successfully` message is written before the server is actually spawned. Now the status is updated only when the server is spawned successfully. To be specific, this change posts the status closer to where we log `starting API server`.

### Related Issues ✍
#2751

### Solution and Design ✍
We update the status inside `runHGEServer` function. This helps in adding the message only when the server is started. If any exception is thrown before the server is spawned, only that message is written to `config_status` table instead of the `Service configured successfully` message.

## Affected components ✍️

-  Server

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5179
Co-authored-by: Naveen Naidu <30195193+Naveenaidu@users.noreply.github.com>
Co-authored-by: Anon Ray <616387+ecthiender@users.noreply.github.com>
GitOrigin-RevId: 7860008403aa0645583e26915f620b66a5bbc531
2022-08-05 11:51:13 +00:00
Daniel Harvey
6f5416db3e tests: move yaml expectations out of yaml quoter file
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5295
GitOrigin-RevId: 66239be3f2b7c83721af174dc72a1e0796211842
2022-08-05 09:36:03 +00:00
Anon Ray
162e51c668 multitenant: refactor config status updates
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4383
Co-authored-by: Puru Gupta <32328846+purugupta99@users.noreply.github.com>
Co-authored-by: Naveen Naidu <30195193+Naveenaidu@users.noreply.github.com>
GitOrigin-RevId: f1e376d0b7ef8a64fb7f8bc38e8b764350f054ac
2022-08-05 06:31:07 +00:00
Solomon
07e4a49e5e Consolidate Arg/Env Parser Defaults and cleanup arg merging code
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5262
GitOrigin-RevId: 2501e44a8fe0a57b13141c307d2dd44b028052b6
2022-08-05 00:29:52 +00:00
Tom Harding
d8a4f2cf9b Update HelloWorldSpec to reflect the usual test structure
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5325
GitOrigin-RevId: 85b5aabcdf9fbca51d31eaa36e8a81dfac0a40d1
2022-08-04 14:34:28 +00:00
Auke Booij
1007ea27ae server: refactor MonadSchema into MonadMemoize
Followup to hasura/graphql-engine-mono#4713.

The `memoizeOn` method, part of `MonadSchema`, originally had the following type:
```haskell
  memoizeOn
    :: (HasCallStack, Ord a, Typeable a, Typeable b, Typeable k)
    => TH.Name
    -> a
    -> m (Parser k n b)
    -> m (Parser k n b)
```
The reason for operating on `Parser`s specifically was that the `MonadSchema` effect would additionally initialize certain `Unique` values, which appear (nested in) the type of `Parser`.

hasura/graphql-engine-mono#518 changed the type of `memoizeOn`, to additionally allow memoizing `FieldParser`s. These also contained a `Unique` value, which was similarly initialized by the `MonadSchema` effect. The new type of `memoizeOn` was as follows:
```haskell
  memoizeOn
    :: forall p d a b
     . (HasCallStack, HasDefinition (p n b) d, Ord a, Typeable p, Typeable a, Typeable b)
    => TH.Name
    -> a
    -> m (p n b)
    -> m (p n b)
```

Note the type `p n b` of the value being memoized: by choosing `p` to be either `Parser k` or `FieldParser`, both can be memoized. Also note the new `HasDefinition (p n b) d` constraint, which provided a `Lens` for accessing the `Unique` value to be initialized.

A quick simplification is that the `HasCallStack` constraint has never been used by any code. This was realized in hasura/graphql-engine-mono#4713, by removing that constraint.

hasura/graphql-engine-mono#2980 removed the `Unique` value from our GraphQL-related types entirely, as their original purpose was never truly realized. One part of removing `Unique` consisted of dropping the `HasDefinition (p n b) d` constraint from `memoizeOn`.

What I didn't realize at the time was that this meant that the type of `memoizeOn` could be generalized and simplified much further. This PR finally implements that generalization. The new type is as follows:
```haskell
  memoizeOn ::
    forall a p.
    (Ord a, Typeable a, Typeable p) =>
    TH.Name ->
    a ->
    m p ->
    m p
```

This change has a couple of consequences.

1. While constructing the schema, we often output `Maybe (Parser ...)`, to model that the existence of certain pieces of GraphQL schema sometimes depends on the permissions that a certain role has. The previous versions of `memoizeOn` were not able to handle this, as the only thing they could memoize was fully-defined (if not yet fully-evaluated) `(Field)Parser`s. This much more general API _would_ allow memoizing `Maybe (Parser ...)`s. However, we probably have to be continue being cautious with this: if we blindly memoize all `Maybe (Parser ...)`s, the resulting code may never be able to decide whether the value is `Just` or `Nothing` - i.e. it never commits to the existence-or-not of a GraphQL schema fragment. This would manifest as a non-well-founded knot tying, and this would get reported as an error by the implementation of `memoizeOn`.

   tl;dr: This generalization _technically_ allows for memoizing `Maybe` values, but we probably still want to avoid doing so.

   For this reason, the PR adds a specialized version of `memoizeOn` to `Hasura.GraphQL.Schema.Parser`.
2. There is no longer any need to connect the `MonadSchema` knot-tying effect with the `MonadParse` effect. In fact, after this PR, the `memoizeOn` method is completely GraphQL-agnostic, and so we implement hasura/graphql-engine-mono#4726, separating `memoizeOn` from `MonadParse` entirely - `memoizeOn` can be defined and implemented as a general Haskell typeclass method.

   Since `MonadSchema` has been made into a single-type-parameter type class, it has been renamed to something more general, namely `MonadMemoize`. Its only task is to memoize arbitrary `Typeable p` objects under a combined key consisting of a `TH.Name` and a `Typeable a`.

   Also for this reason, the new `MonadMemoize` has been moved to the more general `Control.Monad.Memoize`.
3. After this change, it's somewhat clearer what `memoizeOn` does: it memoizes an arbitrary value of a `Typeable` type. The only thing that needs to be understood in its implementation is how the manual blackholing works. There is no more semantic interaction with _any_ GraphQL code.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4725
Co-authored-by: Daniel Harvey <4729125+danieljharvey@users.noreply.github.com>
GitOrigin-RevId: 089fa2e82c2ce29da76850e994eabb1e261f9c92
2022-08-04 13:45:53 +00:00
paritosh-08
f6067cb977 server/console: add metadata API set_apollo_federation_config
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5294
Co-authored-by: Varun Choudhary <68095256+Varun-Choudhary@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
GitOrigin-RevId: 274d76ff92970ecffa43943125313ba84b07c495
2022-08-04 09:38:02 +00:00
Gil Mizrahi
52c1e9b0a8 Prefix the string md5_ to md5 renames
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5231
GitOrigin-RevId: 6e628a82b889dbc04e93dc5461adb302424c332c
2022-08-04 09:06:33 +00:00
Daniel Chambers
c209b60239 server: Support the namespacing of table names in Data Connectors
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5329
GitOrigin-RevId: 5cf492bc2b09fef6250f4dd50f74f750f55ebe6a
2022-08-04 08:35:52 +00:00
Tom Harding
bbafd0339c Add the HelloWorldSpec link back in the README
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5326
GitOrigin-RevId: 567c852117f5873f948c2cbbb7b62e467ceba171
2022-08-04 07:17:25 +00:00
Solomon
ca1bb1d745 Resolve a variety of smaller TODOs in the OSS Arg/Env Parser
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5303
GitOrigin-RevId: f45cf4b828c31d918ed16f5de19d9880bf8a5579
2022-08-04 03:23:30 +00:00
Solomon
24932c0d56 Monomorphize AuthHookG
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5279
GitOrigin-RevId: a54d23ca96c3178f134ad8be271645775fe3edd4
2022-08-04 02:25:41 +00:00