Commit Graph

580 Commits

Author SHA1 Message Date
Philip Lykke Carlsen
4431fb5ea9 Add schema implementation for Aggregation Predicates
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5259
GitOrigin-RevId: f53e310951fa4eb7570006d8c616398a98078632
2022-08-22 15:59:21 +00:00
Daniel Harvey
5a126a693e server: MSSQL varchars compared to nvarchars
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5536
GitOrigin-RevId: ff2e5c9a71dbb02e729b7715d5df752675fc4656
2022-08-22 08:34:41 +00:00
Tom Harding
4a9da49f8d Move ArrayParamPermissionSpec under Postgres
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5492
GitOrigin-RevId: f9f002934acdb9cb9eb82772969663983de05a23
2022-08-19 16:13:07 +00:00
Philip Lykke Carlsen
0e921ca9a5 Define IR types for AggregationPredicates.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5258
GitOrigin-RevId: 172b9de69f44635c5700b3f75ce17304ec56c18a
2022-08-19 15:41:47 +00:00
Tom Harding
283d51668f Move BackendOnlyPermissionsSpec
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5539
GitOrigin-RevId: 96851c840ea945af250c8eb876ea183b8384f5d9
2022-08-19 12:59:03 +00:00
Daniel Chambers
ef0ca7dea2 server: Data Connectors support for ordering by related table column and aggregates [GDW-126]
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5478
GitOrigin-RevId: 269d33d48f7d41efc7ab4ac6efd9442c6741d08c
2022-08-19 07:01:52 +00:00
Brandon Simmons
4be1ca758d Add allocation counter to trace spans and trace metadata
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5208
GitOrigin-RevId: c0197e69986109db73fa0734b5a093a5e7f0c2e3
2022-08-18 21:57:59 +00:00
Tom Harding
dea80bfac7 Refactor the InsertDefaultsSpec
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5534
GitOrigin-RevId: b5434dbaf86315b77cf9c5ed9d61f80e87c7fc64
2022-08-18 18:16:26 +00:00
Evie Ciobanu
1e48af2d03 server/nada: add unit tests for Postgres insert SQL generation
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5543
GitOrigin-RevId: 55646f653926559f1847aa692d3522627a463d25
2022-08-18 10:44:32 +00:00
Evie Ciobanu
56f2501ab9 server/nada: minor refactoring around SQL-generation unit tests
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5524
GitOrigin-RevId: a9f1bcf66f731829c48cb6ced5d968c2e2f4ae80
2022-08-18 09:01:07 +00:00
Solomon
7a2352dd6e Introduce GDC Add/Remove Agent and List Source Kinds Metadata API Actions
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5415
GitOrigin-RevId: b46f928eae85a747378bbc18968d93dcb81c895a
2022-08-17 22:14:40 +00:00
Abby Sassel
1fca1eeb7c server/tests: reorganise RunSQLSpec
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5512
GitOrigin-RevId: 45761ec297b629de283c310624d9ccb587f30c19
2022-08-17 13:35:09 +00:00
Tom Harding
78e6c9369a Move ObjectRelationshipsLimitSpec to the regression test directory
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5493
GitOrigin-RevId: e4303cd15229c3551269dac84dcb2670f875359c
2022-08-17 09:51:07 +00:00
Lyndon Maydwell
5d751bf0ba Adding metrics capability to data-connector agents (with specs)
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5444
GitOrigin-RevId: 49242e83fc1efeb5665515b44368e930818baf27
2022-08-17 01:47:36 +00:00
Solomon
418d0e2cc2 Use NonNegative types for arg/env parsing
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5305
GitOrigin-RevId: 8274ca8c4217d15939fa2a78664a2be486426bf7
2022-08-17 01:09:19 +00:00
Tom Harding
b4639fd10f Move the InsertOnConflictSpec test to regressions
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5495
GitOrigin-RevId: be6986ca1073b76be21fe52ef217dc84f901fe81
2022-08-16 12:29:47 +00:00
Tom Harding
7e6c9df291 Move CustomRootFieldsSpec under Subscriptions
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5494
GitOrigin-RevId: bdd0fd4e7a6b6465be59dd497c0ff06588f35445
2022-08-16 11:54:29 +00:00
Tom Harding
a54cbc17c3 Migrate InsertCheckPermissionSpec to the new structure
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5363
GitOrigin-RevId: 6de7600f7d9e6a04a10290d85bb83bb564352772
2022-08-15 18:10:44 +00:00
Brandon Martin
98ba6f8751 Merge pull request #5477 from hasura/gil/fix_ulls_first
server/postgres: Fix ulls first parsers + long identifiers + test

GitOrigin-RevId: 74e067b13ca0b4bc47147e715b87a187cd1aeb29
2022-08-15 15:42:34 +00:00
Daniel Harvey
57025ef3b3 tests: Rename DoNotTruncateSessionVariables regression test
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5485
GitOrigin-RevId: 4e29e05516e716958febcee03f21862944d5dd88
2022-08-15 13:58:14 +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
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
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
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
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
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
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
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
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
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
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
Daniel Chambers
b24b12b2e6 server: Improve test failure error message in Data Connector agent test suite
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5304
GitOrigin-RevId: 8238c1b59c378b7fe37ae0c9afecbf04f8841e2e
2022-08-04 01:02:22 +00:00
Philip Lykke Carlsen
b658df1c43 Spike attempt at adding logging to the hspec test-suite
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4772
Co-authored-by: Gil Mizrahi <8547573+soupi@users.noreply.github.com>
GitOrigin-RevId: 5c6c9056952574462d5b309774331a909a7eac6d
2022-08-03 14:19:53 +00:00
Tom Harding
c6ff297c71 Port the ColumnPresetsSpec test to the new structure
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5291
GitOrigin-RevId: 4106229cfd1c0d83df8d689b271e060fcbf9cc47
2022-08-03 09:14:50 +00:00
Gil Mizrahi
6dc1eab513 server/tests: Porting Context to Fixture - add custom options
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5270
GitOrigin-RevId: a0f2e401f681e5df0f6cbb6c138686537e3605ee
2022-08-02 18:02:43 +00:00
Tom Harding
4d478e78cf Migrate InsertEnumColumnSpec to the new structure
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5296
GitOrigin-RevId: 99e3f403a2b51cf0dfafbfb3330c931ca909ef9b
2022-08-02 16:25:50 +00:00
Daniel Harvey
4d74bb79ab tests: interpolateYaml quasiquoter for string interpolation
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5162
GitOrigin-RevId: 5b4efb6fe2d8445eb9fad428c1fb0da6d0ac604c
2022-08-02 12:52:58 +00:00
Tom Harding
4d123987d6 Refactor the NestedRelationshipsSpec into the new structure
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5269
GitOrigin-RevId: 0c02d0d2c273b04403972eb3357b9ad8352a8f74
2022-08-01 15:46:28 +00:00
Jesse Hallett
ab59be86c3 server: split metadata serialization helpers into new module
Moves code from `Hasura.RQL.Types.Metadata` that is specific to serialization into a new module, `Hasura.RQL.Types.Metadata.Serialization`.

I'm breaking up #5184 into smaller PRs. This is the third and final PR in that effort. This PR is stacked on #5210 and #5211.

The tracking issue is https://hasurahq.atlassian.net/browse/MM-35

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5212
GitOrigin-RevId: 6cde6d52173590fafe0969a06f2a3411db4fbc78
2022-08-01 13:55:32 +00:00
Tom Harding
08c47b7568 Move and refactor the Directives tests
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5267
GitOrigin-RevId: ec37b8bcea8f50b97fca4008dec7575929ed1841
2022-08-01 12:05:56 +00:00
Jesse Hallett
4ed1fdb859 server: move Metadata code to avoid circular dependencies in upcoming work
A following PR moves serialization-related code out `Hasura.RQL.Types.Metadata` into a specialized submodule. To avoid circular dependencies a number of other definitions also need to be moved into their own submodule. This PR does that extra moving first so that we can keep each PR as small, and as easy to review as possible.

There are a lot of changed lines; but it's all moving code from one module to another.

I'm breaking up #5184 into smaller PRs, and this is the first PR in that effort.

The tracking issue is https://hasurahq.atlassian.net/browse/MM-35

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5210
GitOrigin-RevId: 6fb6e29a967ab5ad4724006c8e0addd2d63a3946
2022-07-30 00:15:18 +00:00
Tom Harding
178e452b6b Use witherable, remove catMaybes/mapMaybe
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5250
GitOrigin-RevId: 5f0a582b3a853d2dbcce20e88c17970290625fc6
2022-07-29 14:53:16 +00:00
Gil Mizrahi
34fd7b9f61 hspec: update to 2.10.0 and use custom ghc-options
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5232
GitOrigin-RevId: 24dfd5742a93445cb86cf2dd0500f9420b21b406
2022-07-29 10:16:37 +00:00
Tom Harding
0494ef3f2b Remove SerializationSpec, move to BigQuery-specific tests
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5218
GitOrigin-RevId: 3e14e7cefb02d21aa1c938185043e3af428d5190
2022-07-28 10:18:59 +00:00
Tom Harding
3dc17c3f77 Remove PostgresTypesSpec, create Test.Postgres.TimestampSpec
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5220
GitOrigin-RevId: eb892113ea1a9491c6cb793102ad5f56ae2713fb
2022-07-28 09:42:43 +00:00
Tom Harding
f7392a26e3 Move UpdateManySpec into Test.Mutations.MultiplePerRequest
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5206
GitOrigin-RevId: a3f1d37de38c40c2e08506ed30eb0a56ce3bb45e
2022-07-28 08:54:35 +00:00
Daniel Chambers
ac4f3d8ed0 server: Aggregates support for Data Connectors [GDW-187]
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5194
GitOrigin-RevId: f0f4f0974710af943b1e47d07d199a277156285d
2022-07-28 05:40:53 +00:00
Samir Talwar
f01c7f4ee6 server: Remove QErr and Code dependencies from the schema parsers.
In the process of decoupling the schema parsers from the GraphQL Engine, we need to remove dependencies on `Hasura.Base.Error`.

First of all, we have avoided using `QErr` in schema parsers code, instead returning a more appropriate data type which can be converted to a `Hasura.Base.Error.QErr` later.

Secondly, we create a new `ParseErrorCode` type to represent parse failure types, which are then converted to a `Hasura.Base.Error.Code` later.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5181
GitOrigin-RevId: 8655e26adb1e7d5e3d552c77a8a403f987b53467
2022-07-27 12:26:44 +00:00
Tom Harding
63cc498619 Move PrimaryKeySpec into the new test structure
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5182
GitOrigin-RevId: 26dafbf95ff6d2cf2f7d3e9d9eec2441f2ef02ce
2022-07-27 11:04:16 +00:00
Tom Harding
bd1fde3d8b Create and organise OffsetSpec, remove LimitOffsetSpec
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5186
GitOrigin-RevId: 08687b3e77a6e8663cf0ec59e638aa917a334574
2022-07-27 09:46:55 +00:00
Tom Harding
04887f00de Remove Test.OrderingSpec, create Test.Queries.SortSpec
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5188
GitOrigin-RevId: 8d5ca048a838a29991ca4b4425ce0439c60f94b1
2022-07-27 09:08:20 +00:00
Tom Harding
9a55b50d0e Remove the BasicFieldsSpec module, reorganise its contents
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5189
GitOrigin-RevId: f68baca8cc5c0b52135141191bbbee5771d791e1
2022-07-27 08:33:59 +00:00
Naveen Naidu
b69182f4fe server: delete hasura SQL triggers when tables are untracked
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5130
GitOrigin-RevId: c8bec0c5ac0eb9c576e86a218311b5c0503ee400
2022-07-27 07:58:11 +00:00
David Overton
a6dca587d2 Update autodocodec
Updates to the latest version of autodocodec and uses the new features, in particular `discriminatedUnionCodec`.
This allows us to remove the `ValueWrapper*` types and `sumTypeCodec`. Sum types are now encoded as discriminated unions.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5155
GitOrigin-RevId: 20bfdc12b28d35db354c4a149b9175fab0b2b7d2
2022-07-27 05:28:47 +00:00
Samir Talwar
87456360ad server: Move ErrorMessage to its own package.
This is now the sole in-universe dependency of the schema parsers. As
such, we need to extract it as a library before we can extract the
schema parsers as a library.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5202
GitOrigin-RevId: fbe571855768e56dc8b8e259b8efe900de3ecc54
2022-07-27 04:38:12 +00:00
Tom Harding
b1bf07db34 Absorb SelectSpec into ObjectQueriesSpec
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5196
GitOrigin-RevId: ee1f2c53225904b63f3bd0c33aeecbdd5cb02f36
2022-07-26 14:18:58 +00:00
Tom Harding
307071840f Add the basic limit query
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5183
GitOrigin-RevId: 76e1f59c3e5212f69b4b13e431627cfff141a8b5
2022-07-26 13:32:16 +00:00
Tom Harding
5cca33611b Remove redundant test
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5187
GitOrigin-RevId: 25d711ef42f431d3aa6874581580ce2dad53f3f1
2022-07-26 09:28:31 +00:00
Daniel Chambers
2b9c224170 server: Simplify FieldValue in Data Connector query responses for agents
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5149
GitOrigin-RevId: 4ed438fdd9887b0b4d23a98156e350deb3403465
2022-07-26 02:30:14 +00:00
Tom Harding
15fa2f7b56 Remove HelloWorldSpec
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5178
GitOrigin-RevId: d8c48a01f452b632503ba7b90c9d549167e5c519
2022-07-25 18:07:08 +00:00
paritosh-08
95adde4ce2 server: support for Apollo federation
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4584
Co-authored-by: Auke Booij <164426+abooij@users.noreply.github.com>
GitOrigin-RevId: 0f60c263efb5fbaa25620dd8159e8cfda25a61b2
2022-07-25 15:54:41 +00:00
Tom Harding
73d8d35df3 Add the Schema.TableRelationshipsSpec tests
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5133
GitOrigin-RevId: 29b749ffc1e47f0d64cc6334bedb265b75fa7aa2
2022-07-25 14:52:42 +00:00
Tom Harding
7b2bb262b8 Add the Queries.SimpleSpec tests
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5138
GitOrigin-RevId: 1328772e5262f4cd4d931bfb40103fe619d39f83
2022-07-25 13:34:47 +00:00
Abby Sassel
77b4b395ef server/bigquery: test row level permissions
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5115
GitOrigin-RevId: 8fa2261cefc3d2932542be6b07499b47df74e9d1
2022-07-25 09:53:14 +00:00
awjchen
227e11d481 server: expose Prometheus metrics from Hasura Pro
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4972
GitOrigin-RevId: fadfcb0981cd9dfe0a316804ead87d7778ece1e9
2022-07-23 21:19:20 +00:00
Gil Mizrahi
ee15c804bc server/postgres: prefix identifiers longer than 63 characters with their md5 hash
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5080
GitOrigin-RevId: 58e5e6aab136617d1bbfc6621c89942da358b04d
2022-07-22 15:29:02 +00:00
Tom Harding
ca218706be Delete WhereSpec, add FilterSearchSpec
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5151
GitOrigin-RevId: 97628540f82bcff7d7fe5acf54586df96acd78f4
2022-07-22 14:51:02 +00:00
Daniel Chambers
2df835624d server: Nodes field support in Data Connector aggregate queries [GDW-187]
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5108
GitOrigin-RevId: 2d707abab0ae429e30be620225c4c419b960aa3f
2022-07-22 09:47:32 +00:00
Lyndon Maydwell
6821b90910 Moving kriti function references into a single module for coordination of availability
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5095
GitOrigin-RevId: 8394c33f0182baad53306c6efc3ab720957b7339
2022-07-21 07:07:29 +00:00
Daniel Chambers
c1380e1daf server: Data Connectors aggregation agent API contract [GDW-95]
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5069
GitOrigin-RevId: acd80975c162935d5594e55db47228cf689e5fd7
2022-07-20 05:21:54 +00:00
Naveen Naidu
38a10bebb7 server: delete hasura SQL triggers when MSSQL source is dropped
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5060
GitOrigin-RevId: 377df03697d973cdaa643999b213697d7a368dee
2022-07-19 11:40:50 +00:00
Evie Ciobanu
187bf385fc remove homebrew NESeq, use vendored
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5094
GitOrigin-RevId: 3342e571d3574a4d94fe3bfedb60f332b8c10853
2022-07-19 08:42:28 +00:00
Lyndon Maydwell
2107c70e17 Kriti Transform of the DataConnectors Configuration [GDW-144]
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4996
GitOrigin-RevId: 26d367ab83df4b161f58133afab2788c6f0c9746
2022-07-19 01:52:50 +00:00
Samir Talwar
eab4f75212 An ErrorMessage type, to encapsulate.
This introduces an `ErrorMessage` newtype which wraps `Text` in a manner which is designed to be easy to construct, and difficult to deconstruct.

It provides functionality similar to `Data.Text.Extended`, but designed _only_ for error messages. Error messages are constructed through `fromString`, concatenation, or the `toErrorValue` function, which is designed to be overridden for all meaningful domain types that might show up in an error message. Notably, there are not and should never be instances of `ToErrorValue` for `String`, `Text`, `Int`, etc. This is so that we correctly represent the value in a way that is specific to its type. For example, all `Name` values (from the _graphql-parser-hs_ library) are single-quoted now; no exceptions.

I have mostly had to add `instance ToErrorValue` for various backend types (and also add newtypes where necessary). Some of these are not strictly necessary for this changeset, as I had bigger aspirations when I started. These aspirations have been tempered by trying and failing twice.

As such, in this changeset, I have started by introducing this type to the `parseError` and `parseErrorWith` functions. In the future, I would like to extend this to the `QErr` record and the various `throwError` functions, but this is a much larger task and should probably be done in stages.

For now, `toErrorMessage` and `fromErrorMessage` are provided for conversion to and from `Text`, but the intent is to stop exporting these once all error messages are converted to the new type.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5018
GitOrigin-RevId: 84b37e238992e4312255a87ca44f41af65e2d89a
2022-07-18 20:27:06 +00:00
Evie Ciobanu
d76aab99e1 server: postgres multiple updates
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4837
GitOrigin-RevId: 505f669298298fd004dfc4e84eaa0d21df055216
2022-07-18 15:16:47 +00:00
Tom Harding
4f3fc9853b Use hspec-discover for src-test, remove unitSpecs list.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5078
GitOrigin-RevId: c2137264810a2575bae8d83fcdd7a0c8251db50e
2022-07-18 14:15:17 +00:00
Solomon
044cd25df6 OSS Init Modules Restructure
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4938
GitOrigin-RevId: 578a9176f5f28303b74607e008712f75c37355d8
2022-07-15 08:55:25 +00:00
Solomon
59cf4d428e Adds unit tests to OSS Arg/Env parsing
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5056
GitOrigin-RevId: d5de7da9bc795813a3d0f2073919b935fb609d14
2022-07-15 05:04:02 +00:00
Tom Harding
2e7e6fd98a Move SchemaOptions to its own module, remove magic bools
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5048
GitOrigin-RevId: f666a10c6af5feda9d761d3ffee5c77695361fdf
2022-07-14 17:59:01 +00:00
Samir Talwar
c980af1b8f Move MkTypename and NamingCase into their own modules.
This moves `MkTypename` and `NamingCase` into their own modules, with the intent of reducing the scope of the schema parsers code, and trying to reduce imports of large modules when small ones will do.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4978
GitOrigin-RevId: 19541257fe010035390f6183a4eaa37bae0d3ca1
2022-07-12 14:01:28 +00:00
Daniel Chambers
728fcd011e Add Data Connector agent request logging, improve error messages, and add tracing support [GDW-83]
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4987
GitOrigin-RevId: 71570d1656e0cd5be49c179740be81804a3ad05a
2022-07-11 08:05:40 +00:00
Jesse Hallett
f4328c3076 server: move ordered Aeson into its own package
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4939
GitOrigin-RevId: 62e83ae7c69f4e0a5334cf1e0c85c22a5d378f59
2022-07-07 15:55:52 +00:00
Karthikeyan Chinnakonda
584aa666bd server: add support to customize streaming subscriptions root field
Earlier, if the `select` root field had a custom root field set, the same custom root field was then used for the streaming subscription root field as well. This leads to duplicate root fields being generated in the `subscription_root`.

This PR fixes that. It provides a way to customize the streaming subscription root field and not use the `select` root field's custom root field name for the streaming subscription root field.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4967
Co-authored-by: Anon Ray <616387+ecthiender@users.noreply.github.com>
GitOrigin-RevId: 54e74ce97561b0e5cfdfc60d1ca340aaebecf7d4
2022-07-06 12:14:25 +00:00
Samir Talwar
40617719ef server: Remove the Show instance from QErr and anything that touches it.
We only use these `Show` instances in error messages (where we call
`show` explicitly anyway) and test cases (in which Hspec requires `Show
a` for any `a` in an assertion).

This removes the instance in favor of a custom `showQErr` function
(which serializes the error to JSON). It is then used in certain error
message production which previously called `show` on a `QErr`.

There are two places where we serialize a QErr and then construct a new
QErr from the resulting string. Instead, we modify the existing QErr to
add extra information.

An orphan `Show QErr` instance is retained for tests so that we can have
nice test failure messages.

This is preparation for future changes in which the error message within
`QErr` will not be exposed directly, and therefore will not have a
`Show` instance. That said, it feels like a sensible kind of cleanup
anyway.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4897
GitOrigin-RevId: 8f79f7a356f0aea571156f39aefac242bf751f3a
2022-07-01 11:48:26 +00:00
Antoine Leblanc
3a400fab3d Rewrite OpenAPI
### Description

This PR rewrites OpenAPI to be more idiomatic. Some noteworthy changes:
- we accumulate all required information during the Analyze phase, to avoid having to do a single lookup in the schema cache during the OpenAPI generation phase (we now only need the schema cache as input to run the analysis)
- we no longer build intermediary endpoint information and aggregate it, we directly build the the `PathItem` for each endpoint; additionally, that means we no longer have to assume that different methods have the same metadata
- we no longer have to first declare types, then craft references: we do everything in one step
- we now properly deal with nullability by treating "typeName" and "typeName!" as different
- we add a bunch of additional fields in the generated "schema", such as title
- we do now support enum values in both input and output positions
- checking whether the request body is required is now performed on the fly rather than by introspecting the generated schema
- the methods in the file are sorted by topic

### Controversial point

However, this PR creates some additional complexity, that we might not want to keep. The main complexity is _knot-tying_: to avoid lookups when generating the OpenAPI, it builds an actual graph of input types, which means that we need something similar to (but simpler than) `MonadSchema`, to avoid infinite recursions when analyzing the input types of a query. To do this, this PR introduces `CircularT`, a lesser `SchemaT` that aims at avoiding ever having to reinvent this particular wheel ever again.

### Remaining work

- [x] fix existing tests (they are all failing due to some of the schema changes)
- [ ] add tests to cover the new features:
  - [x] tests for `CircularT`
  - [ ] tests for enums in output schemas
- [x] extract / document `CircularT` if we wish to keep it
- [x] add more comments to `OpenAPI`
- [x] have a second look at `buildVariableSchema`
- [x] fix all missing diagnostics in `Analyze`
- [x] add a Changelog entry?

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4654
Co-authored-by: David Overton <7734777+dmoverton@users.noreply.github.com>
GitOrigin-RevId: f4a9191f22dfcc1dccefd6a52f5c586b6ad17172
2022-06-30 12:57:09 +00:00
Naveen Naidu
f7178e75f9 server: fix unlockEventsInSource bug
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4821
GitOrigin-RevId: be417c1f05600e3b57fa1e448f69ebd8536c8ff7
2022-06-30 11:27:16 +00:00
Tom Harding
ffad733bd3 Port the "test_user_perms" pytest to hspec
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4828
GitOrigin-RevId: 6227b8601e6b4d6f6bf2bd199cdb4d94a200c96c
2022-06-30 10:28:08 +00:00
Daniel Chambers
3f405915e9 Added a healthcheck endpoint to the Data Connector Agent API spec
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4890
GitOrigin-RevId: 605408bddf03bef66eb03be8c242797e8fcf89bb
2022-06-30 08:37:53 +00:00
Philip Lykke Carlsen
a409e79167 Move postgres specific schema into the Postgres namespace
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4895
GitOrigin-RevId: 62772d966bf2b4a4dcb26c1dd0bd4f30749b7c91
2022-06-29 16:05:35 +00:00
Abby Sassel
9d93baa96f server/postgres: parameterise array variables in queries/subscriptions
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4776
Co-authored-by: Tom Harding <6302310+i-am-tom@users.noreply.github.com>
Co-authored-by: Brandon Martin <40686+codedmart@users.noreply.github.com>
GitOrigin-RevId: ca962e3bfaa28ef00c5d04273d6604348d7da1c8
2022-06-29 13:37:11 +00:00
Samir Talwar
5f38743f29 server: Encapsulate catalog versions in their own type.
This came about as I tried to add an instance over catalog versions and
found they were just simple integers most of the time (and in one case,
a float).

I think this change also clarifies how catalog versions work.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4864
GitOrigin-RevId: a6b7db86de564b71a8c2b602bee6a456b8e20d63
2022-06-29 08:19:33 +00:00
Karthikeyan Chinnakonda
4b2ca2ea63 server: Recreate event trigger tests
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4808
GitOrigin-RevId: c4eac26ec24036a6c6fb4fbdb1fdc57663eba21d
2022-06-29 06:46:18 +00:00
Daniel Chambers
f18e571455 Data Connectors: Fixed multiple relationships on the same table not generating correct query
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4880
GitOrigin-RevId: 537361cafca7ce4fc2a74b43740092bf09fcab6d
2022-06-29 01:08:11 +00:00
Auke Booij
8ccf7724ce server: Metadata origin for definitions (type parameter version v2)
The code that builds the GraphQL schema, and `buildGQLContext` in particular, is partial: not every value of `(ServerConfigCtx, GraphQLQueryType, SourceCache, HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject), ActionCache, AnnotatedCustomTypes)` results in a valid GraphQL schema. When it fails, we want to be able to return better error messages than we currently do.

The key thing that is missing is a way to trace back GraphQL type information to their origin from the Hasura metadata. Currently, we have a number of correctness checks of our GraphQL schema. But these correctness checks only have access to pure GraphQL type information, and hence can only report errors in terms of that. Possibly the worst is the "conflicting definitions" error, which, in practice, can only be debugged by Hasura engineers. This is terrible DX for customers.

This PR allows us to print better error messages, by adding a field to the `Definition` type that traces the GraphQL type to its origin in the metadata. So the idea is simple: just add `MetadataObjId`, or `Maybe` that, or some other sum type of that, to `Definition`.

However, we want to avoid having to import a `Hasura.RQL` module from `Hasura.GraphQL.Parser`. So we instead define this additional field of `Definition` through a new type parameter, which is threaded through in `Hasura.GraphQL.Parser`. We then define type synonyms in `Hasura.GraphQL.Schema.Parser` that fill in this type parameter, so that it is not visible for the majority of the codebase.

The idea of associating metadata information to `Definition`s really comes to fruition when combined with hasura/graphql-engine-mono#4517. Their combination would allow us to use the API of fatal errors (just like the current `MonadError QErr`) to report _inconsistencies_ in the metadata. Such inconsistencies are then _automatically_ ignored. So no ad-hoc decisions need to be made on how to cut out inconsistent metadata from the GraphQL schema. This will allow us to report much better errors, as well as improve the likelihood of a successful HGE startup.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4770
Co-authored-by: Samir Talwar <47582+SamirTalwar@users.noreply.github.com>
GitOrigin-RevId: 728402b0cae83ae8e83463a826ceeb609001acae
2022-06-28 15:53:44 +00:00
Daniel Harvey
e4da80421e server: Change withPath to take a single pathItem in MonadParse
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4815
GitOrigin-RevId: d0d889754944cc8270bdee2fd21b0cf5dcad9175
2022-06-28 10:08:09 +00:00
Jesse Hallett
2f3ae93ab0 server: initial set of DTO types for metadata
This implements an initial set of DTO types that represent serialized metadata. These new types come with codecs using autodocodec which are used to derive both JSON serialization, and OpenAPI documentation. This ensures that we can automatically generate API documentation that is guaranteed to match JSON produced by the server.

For the moment the new types are not used for anything except to generate an early version of an OpenAPI document. Because this is early work the DTO types for each metadata format version list top-level properties only with placeholders for the types of each top-level property. This early iteration demonstrates using a sum type in Haskell that maps to a tagged union in OpenAPI (using the `version` field value as a tag).

This work is experimental and incomplete! Please do not incorporate the generated OpenAPI documentation into essential workflows at this time.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4801
GitOrigin-RevId: d2f110a6237b73520cdba24667333ef14e8cdd3d
2022-06-27 16:33:31 +00:00
Brandon Simmons
b704192268 server: GHC 9.2 changes compatible with 8.10 (#3550)
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4841
Co-authored-by: awjchen <13142944+awjchen@users.noreply.github.com>
GitOrigin-RevId: ce47b1290fefb07f3f800c6c62120437c02086e5
2022-06-25 22:09:05 +00:00
Solomon
baf196daa6 [GDW-111] Mockable GDC Agent for integration testing
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4802
GitOrigin-RevId: 36cdfcff4a864598a4d10e746ecdf93dae2b4c02
2022-06-25 19:06:54 +00:00
Daniel Chambers
7ec5e79bd1 AVRelationship Support for Data Connectors [GDW-123]
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4735
GitOrigin-RevId: f23965a6c7ea8a0e6b25dbf9d3faeccec0ef6ec3
2022-06-24 06:59:52 +00:00
Samir Talwar
8db9b77c77 server: Reorganize quasi-quoted names.
Pretty much all quasi-quoted names in the server code base have ended up in `Hasura.GraphQL.Parser.Constants`. I'm now finding this unpleasant for two reasons:

1. I would like to factor out the parser code into its own Cabal package, and I don't want to have to expose all these names.
2. Most of them really have nothing to do with the parsers.

In order to remedy this, I have:

1. moved the names used by parser code to `Hasura.GraphQL.Parser.DirectiveName`, as they're all related to directives;
2. moved `Hasura.GraphQL.Parser.Constants` to `Hasura.Name`, changing the qualified import name from `G` to `Name`;
3. moved names only used in tests to the appropriate test case;
4. removed unused items from `Hasura.Name`; and
5. grouped related names.

Most of the changes are simply changing `G` to `Name`, which I find much more meaningful.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4777
GitOrigin-RevId: a77aa0aee137b2b5e6faec94495d3a9fbfa1348b
2022-06-23 09:15:31 +00:00
Daniel Chambers
d896cc4d95 Replace Haskell DC Reference Agent with TypeScript DC Reference Agent in HSpec tests
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4689
Co-authored-by: Vishnu Bharathi <4211715+scriptnull@users.noreply.github.com>
GitOrigin-RevId: 9dc6a2e373b3d7ab0bdce7ddcd7b7e6e5b1dc498
2022-06-23 08:09:46 +00:00
Brandon Simmons
80cc53aaac server: vendor used bits of 'ip' package to cut dependencies
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4704
GitOrigin-RevId: 14759b410e99a1a97aa01b1139d9d61292301aff
2022-06-20 23:16:51 +00:00
Gil Mizrahi
3e81ab3a57 server/postgres: test identifier uniqueness rewrite
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4693
GitOrigin-RevId: bd882835b86a37df125f79d5597826a15498fcaf
2022-06-17 10:44:18 +00:00
Daniel Harvey
03c93ad96f server: Refactor TByteString to SerializableBlob
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4736
GitOrigin-RevId: 446832b00c24205c2237666ac9d954277c5fd05d
2022-06-17 09:57:38 +00:00
Philip Lykke Carlsen
f33fad5fc1 Zendesk-5146 followup tests
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4768
GitOrigin-RevId: 2d182344d724cf0fc07ec73f8a3c4d786afe9243
2022-06-17 08:45:13 +00:00
Evie Ciobanu
8f0b3f6d06 server: build/run unit tests faster
This aims to support loading up a `ghci repl` with both the `graphql-engine` library and the unit tests. This is currently not officially supported by cabal, but it uses a hack, which is why I added a flag. See the updated documentation for more info.

Also see

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4739
GitOrigin-RevId: 5e7b15855a7a829ed76b5830be1efc9146d25da6
2022-06-16 10:39:24 +00:00
Tom Harding
0f553cf1a3 Remove Data.Set.Extended
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4698
GitOrigin-RevId: 06104ea4c67301f058bb24fd395707bb69721954
2022-06-15 09:02:23 +00:00
Gil Mizrahi
5dd3f71539 server/telemetry: support multiple sources
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4493
GitOrigin-RevId: 3b34ea0aa6f78fa43c8d372d8b61d49191632eff
2022-06-15 08:03:31 +00:00
Daniel Chambers
0723925ffc Expose the entire official Chinook dataset through the DC Reference agent and use it in the tests
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4688
GitOrigin-RevId: f87b2e23be69aed3cc7f95e814f9426db174dc9b
2022-06-13 20:59:48 +00:00
Tom Harding
e22eb1afea Weeding (2/?)
## Description

Following on from #4572, this removes more dead code as identified by Weeder. Comments and thoughts similarly welcome!

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4587
GitOrigin-RevId: 73aa6a5a2833ee41d29b71fcd0a72ed19822ca73
2022-06-09 16:40:49 +00:00
Philip Lykke Carlsen
12c3eddef7 Amendments to the hspec testsuite
This PR proposes some changes to the hspec testsuite:

* It amends the framework to make it easier to test from the ghci REPL
* It introduces a new module `Fixture`, distinguished from `Context` by:
   * using a new concept of `SetupAction`s which bundle setup and teardown actions into one abstraction, making test system state setup more concise, modularized and safe (because the fixture know knows about the ordering of setup actions and can do partial rollbacks)
   * somewhat opinionated, elides the `Options` of `Context`, preferring instead that tests that care about stringification of json numbers manage that themselves.

(Note that this PR builds on #4390, so contains some spurious commits which will become irrelevant once that PR is merged)

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4630
GitOrigin-RevId: 619c8d985aed0aa42de31d6f16891d0782f4b4b5
2022-06-08 16:36:50 +00:00
Brandon Simmons
6e8da71ece server: migrate to aeson-2 in preparation for ghc 9.2 upgrade
(Work here originally done by awjchen, rebased and fixed up for merge by
jberryman)

This is part of a merge train towards GHC 9.2 compatibility. The main
issue is the use of the new abstract `KeyMap` in 2.0. See:
https://hackage.haskell.org/package/aeson-2.0.3.0/changelog

Alex's original work is here:
#4305

BEHAVIOR CHANGE NOTE: This change causes a different arbitrary ordering
of serialized Json, for example during metadata export. CLI users care
about this in particular, and so we need to call it out as a _behavior
change_ as we did in v2.5.0. The good news though is that after this
change ordering should be more stable (alphabetical key order).

See: https://hasurahq.slack.com/archives/C01M20G1YRW/p1654012632634389

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4611
Co-authored-by: awjchen <13142944+awjchen@users.noreply.github.com>
GitOrigin-RevId: 700265162c782739b2bb88300ee3cda3819b2e87
2022-06-08 15:32:27 +00:00
Philip Lykke Carlsen
3e33fd6ff7 Make on_conflict schema available abstract of update permissions
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4390
GitOrigin-RevId: 5f3f9da173cad37f9330c5a27fd1edfc2559a4d6
2022-06-07 23:25:48 +00:00
Antoine Leblanc
eaba2e08d3 Clean Relay's code, break schema cycles, introduce Node ID V2
## Motivation

This PR rewrites most of Relay to achieve the following:
- ~~fix a bug in which the same node id could refer to two different tables in the schema~~
- remove one of the few remaining uses of the source cache in the schema building code

In doing so, it also:
- simplifies the `BackendSchema` class by removing `node` from it,
- makes it much easier for other backends to support Relay,
- documents, re-organizes, and clarifies the code.

## Description

This PR introduces a new `NodeId` version ~~, and adapts the Postgres code to always generate this V2 version~~. This new id contains the source name, in addition to the table name, in order to disambiguate similar table names across different sources (which is now possible with source customization). In doing so, it now explicitly handles that case for V1 node ids, and returns an explicit error message instead of running the risk of _silently returning the wrong information_.

Furthermore, it adapts `nodeField` to support multiple backends; most of the code was trivial to generalize, and as a result it lowers the cost of entry for other backends, that now only need to support `AFNodeId` in their translation layer.

Finally, it removes one more cycle in the schema building code, by using the same trick we used for remote relationships instead of using the memoization trick of #4576.

## Remaining work

- ~~[ ]write a Changelog entry~~
- ~~[x] adapt all tests that were asserting on an old node id~~

## Future work

This PR was adapted from its original form to avoid a breaking change: while it introduces a Node ID V2, we keep generating V1 IDs and the parser rejects V2 IDs. It will be easy to make the switch at a later data in a subsequent PR.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4593
GitOrigin-RevId: 88e5cb91e8b0646900547fa8c7c0e1463de267a1
2022-06-07 13:36:29 +00:00
Karthikeyan Chinnakonda
d905911eab server: disable query/subscription root fields
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4524
Co-authored-by: Auke Booij <164426+abooij@users.noreply.github.com>
Co-authored-by: Rikin Kachhia <54616969+rikinsk@users.noreply.github.com>
GitOrigin-RevId: 1cae7a1596825925da9e82c2675507482f41c3fb
2022-06-07 05:33:12 +00:00
David Overton
6586053296 Gdw 85/capabilities endpoint
>

## Description ✍️

- Creates a new `/capabilities` endpoint for the GDC agent API
- Removes capabilities from the `/schema` endpoint
- Removes the `/config-schema` endpoint and includes the `ConfigSchemaResponse` within the `CapabilitiesResponse`

### Related Issues ✍
->

https://hasurahq.atlassian.net/browse/GDW-85

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4478
GitOrigin-RevId: 426662ee9e751343d94207d439a5025df65d2de7
2022-06-03 08:08:23 +00:00
Tom Harding
a3031aed03 Add Weeder, begin weeding (1/?)
## Description

This PR adds a config file for [`weeder`](https://github.com/ocharles/weeder) to the `-mono` repository. `weeder` checks for dead code by building a call graph from the given entry points (currently every module named `Main` with a `main` function) and then marking every function _not_ in that call graph as dead code.

To avoid very large PRs, I'm going to tackle this in a series. This first PR adds the basic configuration, plus removes as many weeds as it took for me to realise this was going to become a very big PR. The PRs after this will largely be removing dead code, until the final PR that will add Weeder to the CI pipeline.

### Related Issues

This closes #2973.

## Affected components

- Server

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4572
GitOrigin-RevId: ac8eaa9473e5ac1f16babcb35388694392d0d7dc
2022-05-31 15:43:34 +00:00
Naveen Naidu
11867b50a4 server: extend backend_only setting for update and delete permissions
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4530
Co-authored-by: Karthikeyan Chinnakonda <15602904+codingkarthik@users.noreply.github.com>
Co-authored-by: Rikin Kachhia <54616969+rikinsk@users.noreply.github.com>
GitOrigin-RevId: c4c1a3bd9736ec275e77c6f55c76049c550443f9
2022-05-31 14:42:14 +00:00
Auke Booij
13fc1c62d1 Move Hasura.GraphQL.Parser.Column to .RQL.IR. and .GraphQL.Schema.
This is a first step towards clarifying the role of `UnpreparedValue` as part of the IR. It certainly does not belong in the parser framework.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4588
GitOrigin-RevId: d1582a0b266729b79e00d31057178a4099168e6d
2022-05-30 22:07:57 +00:00
Rakesh Emmadi
af6eb1232e server/bigquery: computed fields SQL generation and execution
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4555
GitOrigin-RevId: c668cb6bd76ed646b9449d8037c2f9038c99e3a8
2022-05-30 15:24:33 +00:00
Evie Ciobanu
a8c0137f21 server: add infrastructure to write runit tests for update parsers
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4533
GitOrigin-RevId: d094149d6cbdeebe152c58032715bad725480d9b
2022-05-26 14:06:24 +00:00
paritosh-08
fd30fb343b server: naming conventions for auto generated fields
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3982
Co-authored-by: Brandon Simmons <210815+jberryman@users.noreply.github.com>
GitOrigin-RevId: f90b2e8f394e7bd69780f003d2d980475f104f42
2022-05-26 11:55:29 +00:00
Rakesh Emmadi
acde210fdc server/bigquery: generate graphql schema for table computed fields
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4460
GitOrigin-RevId: 7b772cd9fba6b612ad05eb1aca1fa13e6ae8556d
2022-05-25 10:25:38 +00:00
Gil Mizrahi
cd38a9a1fc server/postgres + server/mssql: Insert empty objects with default values
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4487
Co-authored-by: Abby Sassel <3883855+sassela@users.noreply.github.com>
GitOrigin-RevId: 3413f0b5dbe6ec42fff360d83b5202e4aa4aa86e
2022-05-11 16:01:57 +00:00
Solomon
b4f89569c8 GDC: Integration Tests and Servant Agent
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4467
GitOrigin-RevId: 5e81d8581197c90ad2de9106e724c63d7592ae72
2022-05-11 06:15:27 +00:00
Karthikeyan Chinnakonda
ce9912ff8c server: run_sql to not drop the SQL triggers created by the graphql-engine
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4397
GitOrigin-RevId: dcd43fc31f64af8c6c9c92c66d46a593d5b12fbd
2022-05-10 13:47:16 +00:00
Antoine Leblanc
697137dd77 Fix Postgres not padding timestamps correctly (fix hasura/graphql-engine#8096)
## Description

As identified in hasura/graphql-engine#8096, the format string we used for timestamps was incorrect; we were using `%F`, which expands to `%Y-%m-%d`; but that meant that the year was not padded to four digits: `0001` would be represented simply as `1`. However, Postgres inteprets that `1` as `2001`, probably due to interpretation rules about two-digit years (in `25/12/01`, `01` is indeed `2001`).

```
# create table timestamp_test ( test timestamptz );
CREATE TABLE
# insert into timestamp_test values ('1-01-01T00:00:57Z');
INSERT 0 1
# select * from timestamp_test;
          test
------------------------
 2001-01-01 00:00:57+00
(1 row)
```

To fix this, this PR changes the format string to use `%0Y`, which always pads the year number with zeroes.

## Remaining work

- [x] write Changelog entry
- [ ] copy timestamp tests from the python suite into the hspec tests

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3536
GitOrigin-RevId: fa144111358339fd4a35b32d888c1d2c5b418ea6
2022-05-09 12:18:18 +00:00
Daniel Chambers
97ac9cbcdc Data Connector Agent Configuration Schema [GDW-103]
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4450
GitOrigin-RevId: 2dce6e901c9734407d084d57166039fd94394279
2022-05-05 05:19:46 +00:00
Rakesh Emmadi
7474f50ef0 server/bigquery: enable metadata API to add/drop computed fields to BigQuery tables
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4414
GitOrigin-RevId: 7899824a49ba9fd479f4cf08789450153f454168
2022-05-04 14:53:31 +00:00
Sibi Prabakaran
49f2e0f4a3 Unify hspec test for SelectSpec and DirectiveSpec
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4387
GitOrigin-RevId: 890d07ebda838a4c6dc4221908bacba2ee75a0a2
2022-05-04 09:59:29 +00:00
Sibi Prabakaran
c199215947 Unified setup for NestedRelationshipsSpec
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4378
GitOrigin-RevId: 3881591ad0ec109352e09a989377121550632fdd
2022-05-03 07:38:47 +00:00
Daniel Chambers
4f835623b1 Rename Data Wrapper to Data Connector [GDW-89]
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4400
GitOrigin-RevId: 2d90542f95ef4dad70c8dfe1ca3b4c1f3bdaa527
2022-05-02 05:04:07 +00:00
Daniel Chambers
9453932112 Data Connector Agent Configuration via HGE Metadata [GDW-103]
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4358
GitOrigin-RevId: 36e18edf00ba0665b40a80c0b07c374ffcfe56e4
2022-05-01 23:02:08 +00:00
Daniel Chambers
970d69edd4 Added BackendConfig to allow sources to share configuration of Data Connectors [GDW-78]
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4271
GitOrigin-RevId: 6990010bff622a424ca0bb9d24579bf121819fb0
2022-04-29 02:14:10 +00:00
Naveen Naidu
1d641aa2ff server: support query tags for MSSQL data sources
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4373
GitOrigin-RevId: 45717defdc973f3b7f1c9b972e2d3c836eec4476
2022-04-28 19:34:45 +00:00
Solomon
db1c50affa Feature/gdw execute array literals GDW-82
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4319
GitOrigin-RevId: 20db2a1eb6e8521c4e572aa642c802129792468f
2022-04-28 01:53:06 +00:00
Antoine Leblanc
3cbcbd9291 Remove RQL/Types.hs
## Description

This PR removes `RQL.Types`, which was now only re-exporting a bunch of unrelated modules.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4363
GitOrigin-RevId: 894f29a19bff70b3dad8abc5d9858434d5065417
2022-04-27 13:58:47 +00:00
Rakesh Emmadi
6611fbd625 server/mssql: avoid encoding varchar values while generating SQL
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4314
GitOrigin-RevId: 852bc941782414c7d190c6195ff367493b927639
2022-04-26 13:48:37 +00:00
Karthikeyan Chinnakonda
2325755954 server: streaming subscriptions schema generation and tests (incremental PR - 3)
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4259
Co-authored-by: Rikin Kachhia <54616969+rikinsk@users.noreply.github.com>
Co-authored-by: Brandon Simmons <210815+jberryman@users.noreply.github.com>
Co-authored-by: paritosh-08 <85472423+paritosh-08@users.noreply.github.com>
GitOrigin-RevId: 4d1b4ec3c01f3a839f4392d3b77950fc3ab30236
2022-04-22 19:54:11 +00:00
Evie Ciobanu
0060a48009 server: minor nit-picks for the Postgres Select module split
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4338
GitOrigin-RevId: c2125275b32a5084c5a96afba79d4cb6c65687a8
2022-04-22 17:19:58 +00:00
Philip Lykke Carlsen
9a557ceeee Split up module Hasura.Backend.Postgres.Translate.Select into sub-modules
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4334
GitOrigin-RevId: d083512f3c4e534a10e571eeab10308ad45cc7a0
2022-04-22 13:39:40 +00:00
Rakesh Emmadi
1231d1145b server/tests: add hspec test case to parse legacy remote relationship definition json
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4327
GitOrigin-RevId: 321d59bb1f7e51d37893838cd6262a865eb943c5
2022-04-22 11:34:38 +00:00
Sibi Prabakaran
c9a5d51c70 Implements TestGraphQLBasicCommon tests using hspec
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4296
GitOrigin-RevId: aa442d7fa33464546fd3821fe989c738cc853c7c
2022-04-22 10:33:34 +00:00
Sibi Prabakaran
e43a5e4794 Rename State to TestEnvironment in hspec test suite
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4309
GitOrigin-RevId: 899b1aa3674654f5c4bdf94dcd45009570b34644
2022-04-20 17:16:42 +00:00
Solomon
c945b2d391 Replaces litName splices with name quasiquotes
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4267
GitOrigin-RevId: 2d93c35a7e34dbada3b72aabcae5fc2858bbfc29
2022-04-18 19:44:04 +00:00