Commit Graph

571 Commits

Author SHA1 Message Date
Jesse Hallett
c6bcf1cd76 server: codecs for object & array relationships, and computed fields
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5923
GitOrigin-RevId: e0c7584539998f5af16795f023640aa5c659b783
2022-10-13 17:57:23 +00:00
Philip Lykke Carlsen
10ae79173e Mention all src-rsr files in 'extra-source-files' section
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/6341
GitOrigin-RevId: 90d9a43304ab48caa67f2d0267a821ebb51a362c
2022-10-13 13:58:20 +00:00
Jesse Hallett
332faabc24 server: codecs for remaining database configuration types
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/6062
GitOrigin-RevId: f1ba9fa30267d1825ba36480103cd973616f3079
2022-10-12 16:30:05 +00:00
Brandon Simmons
823babe885 server: switch to ghc 9.2 (2nd try)
## Migrating, for server devs

You will need the fork of 9.2.4 that we're using (for now):

```
ghcup -c -n install ghc --force -u "https://storage.googleapis.com/graphql-engine-cdn.hasura.io/ghc-bindists/ghc-x86_64-deb10-linux-9.2.4-hasura-fix.tar.xz" 9.2.4
```

or for m1 mac:

```
ghcup -c -n install ghc --force -u  "https://storage.googleapis.com/graphql-engine-cdn.hasura.io/ghc-bindists/ghc-arm64-apple-darwin-9.2.4-hasura-fix.tar.xz"
```

Samir is working on a nix build for nix folx

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/6154
GitOrigin-RevId: 6716e3f2ee19f0281c8ad25383a1241fc362d616
2022-10-06 09:09:01 +00:00
Tom Harding
f05f746b94 Extract the test harness from the Hspec tests
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/6095
Co-authored-by: Gil Mizrahi <8547573+soupi@users.noreply.github.com>
GitOrigin-RevId: 51693f7324e62e201a2bdc701255cf6c730745e2
2022-10-04 08:31:26 +00:00
Brandon Simmons
98a9c5af79 server: remove default +RTS -qn2 setting
We notice significant improvements to max GC pause time, for huge schema (both on 8.10 and 9.2)

This was added when we were on ghc-8.6.5. The referenced issues (from old oss repo) seem irrelevant or don't have useful information afaict

re. https://hasurahq.atlassian.net/browse/SRE-10
https://hasurahq.atlassian.net/browse/SRE-129

-----

**EDIT**: old discussion https://hasurahq.slack.com/archives/CKFUG6RCH/p1576518775017100

It sounds as though if the `replace_metadata` benchmark doesn't regress then we're okay

**EDIT**: Ooh nice, replace_metadata is much faster across the benchmark sets (see "both compared" details)

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/6133
GitOrigin-RevId: c1e2292f29a52584062dfebf2dd676118fcd978f
2022-09-30 20:11:54 +00:00
Philip Lykke Carlsen
7739f8e4a0 server: Permit strings for numerical input fields
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5996
GitOrigin-RevId: 2ed36898aa0286618f3dafe3513ef4e01c58aaba
2022-09-30 13:25:57 +00:00
Jesse Hallett
d32dc881e3 server: fix MySQL connection pool settings getting swapped on parse
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/6063
GitOrigin-RevId: 90f6f8485aa6a9d073edc56dcba5530f5cf787c4
2022-09-28 21:11:26 +00:00
Tom Harding
a1c5ac46f6 Extract dc-api and its tests from graphql-engine.cabal
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/6000
Co-authored-by: Daniel Chambers <1214352+daniel-chambers@users.noreply.github.com>
GitOrigin-RevId: d8f3cd0194191ab4c51a5a7d350cb2c3a0a5a7f3
2022-09-27 07:21:54 +00:00
Daniel Harvey
f42bc4b816 server: feature flag for disabling TABLE_updates fields
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/6039
GitOrigin-RevId: fcbafe2e4b8cf72d739033b372b536d59c398c4e
2022-09-26 13:25:37 +00:00
Lyndon Maydwell
4d2e37b3e6 Raw Query Support for Data Connectors - GDW-394
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5890
Co-authored-by: Vijay Prasanna <11921040+vijayprasanna13@users.noreply.github.com>
GitOrigin-RevId: f6bd2ed5fe170bcce262564cf4f45c95c9bdff94
2022-09-22 21:09:06 +00:00
Tom Harding
e71496efa5 Replace Hasura.RQL.Types.Numeric with refined
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5913
GitOrigin-RevId: 96e218229a08dfbc5a598d709be1ee2083d41ec6
2022-09-21 18:03:04 +00:00
Tom Harding
8dcc8f8fca Implement aggregation tests for hspec
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5960
GitOrigin-RevId: bac9bae3ea39c005f0e7b9c5f7864f012d395ebb
2022-09-20 15:23:46 +00:00
Daniel Chambers
5c06eb7a3e Remove duplicated Data Connector API types
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5930
GitOrigin-RevId: 8c11387fa8556c3cdf8c92a0924ae53d31b953a5
2022-09-20 06:20:25 +00:00
Daniel Chambers
04ae6abf78 Exists support in filter expressions for Data Connector queries [GDW-133]
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5904
GitOrigin-RevId: 6bad4c29a7d14d3881f9c57fe983d14cc41bdc4b
2022-09-20 04:01:33 +00:00
awjchen
dcca0c6275 server: support 128-bit trace ids
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5905
GitOrigin-RevId: 48a981a432b2e979bc7b42b32f9c7f53ab9e2598
2022-09-20 02:50:06 +00:00
Samir Talwar
6c03eef990 server: Add test cases for inconsistencies upon reloading or replacing the metadata.
I am working on https://github.com/hasura/graphql-engine/issues/8807, and wanted to write a Haskell integration test case to reproduce it.

We have Python integration tests somewhat covering this behavior in *test_inconsistent_meta.py*, but no Haskell tests, so I thought I'd shore up the coverage here by adding a few test cases for working behavior.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5897
GitOrigin-RevId: 21500e530e413feaede5cbd8b4a94b07d25a6260
2022-09-19 18:49:31 +00:00
Solomon
85cfd91908 allow exporting dc-agent test descriptions
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5925
GitOrigin-RevId: a508e942c61c775823dff440a37fd8769ca42e21
2022-09-17 02:20:31 +00:00
Abby Sassel
3056678e04 server/postgres: Implement execution of aggregation predicates
PR for the translation / execution step of [aggregation predicate filters](https://github.com/hasura/graphql-engine-mono/issues/5174).

[`translateAVAggregationPredicates`](translateAVAggregationPredicates) is the main change of note, everything else is a supporting or helper function. Please note this doesn't yet include [tests relating to permissions](https://hasurahq.slack.com/archives/C01RZPEPF0W/p1662560092197769); I decided to raise a PR without them for slightly faster feedback. I may include them in this PR or a separately if it's not trivial.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5724
GitOrigin-RevId: fcac258b64066e2bd45108372165a16fd957f5ab
2022-09-16 15:01:03 +00:00
paritosh-08
ab71adc3a0 server, pro: event trigger auto cleanup (increment 3)
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5823
Co-authored-by: pranshi06 <85474619+pranshi06@users.noreply.github.com>
Co-authored-by: Puru Gupta <32328846+purugupta99@users.noreply.github.com>
Co-authored-by: Karthikeyan Chinnakonda <15602904+codingkarthik@users.noreply.github.com>
GitOrigin-RevId: 3d4af905d5df4c05107ad46ef29f4c0a567ff754
2022-09-15 11:46:22 +00:00
David Overton
cbddcce26b Data connector cache invalidations
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5820
GitOrigin-RevId: ded80e378901cc0c0ca12eb67d9264756a8d6ff4
2022-09-14 13:00:47 +00:00
Naveen Naidu
005dbf43cb server: event triggers should be dropped when a previously present source is dropped in replace_metadata
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5739
Co-authored-by: paritosh-08 <85472423+paritosh-08@users.noreply.github.com>
GitOrigin-RevId: 772de8bb6a55a0002885e08a778c16f22ea0b113
2022-09-13 04:18:21 +00:00
Jesse Hallett
b094947239 server: codecs for TableMetadata, FunctionMetadata, and permissions
This PR expands the set of codecs for source metadata to include `TableMetadata`, `FunctionMetadata`, and various permission types. This fills out more detail in the generated OpenAPI document.

See the [generated OpenAPI spec](https://gist.github.com/hallettj/783d06a926cbc854eececa4964e8aa5b) based on this PR.

See also the
[generated TypeScript types](https://github.com/hasura/graphql-engine-mono/files/9448102/client-typescript.tar.gz) based on that spec.

Ticket: https://hasurahq.atlassian.net/browse/MM-66

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5664
GitOrigin-RevId: b6e1f32c669368cd6150e6f69fc36b78b748d9bb
2022-09-12 20:31:07 +00:00
Daniel Harvey
00b1acaf38 tests: JSON and JSONB hspec tests
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5721
GitOrigin-RevId: dde515a364566aa8d517923281ea670a8decbdd9
2022-09-12 14:17:19 +00:00
Tom Harding
70515d94c7 Extract Hasura.Prelude from src-lib
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5776
GitOrigin-RevId: 0df263a4d800e694e68e31c189c360c88cf48abc
2022-09-09 13:58:48 +00:00
Jesse Hallett
977c624c9e server: prune health check from codecs for backends that don't support it
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5822
GitOrigin-RevId: 637a8c668299409385f340d62fc6a84df5c4aa0f
2022-09-09 13:07:33 +00:00
Samir Talwar
f48c882521 server: Share tests between CircularT and MemoizeT.
This abstracts `CircularT`'s test cases to work against "any" memoizer, and then runs them against `MemoizeT` as well.

Surprisingly (or not), this works without issue; `MemoizeT` passes all tests with a couple of extra instances.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5780
GitOrigin-RevId: 461880caf9220dc3f52d622a22e8b8bcd594e404
2022-09-08 19:38:49 +00:00
Philip Lykke Carlsen
d43a30e8fc feat(tests): Introduce AggregationPredicatesSpec
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5686
GitOrigin-RevId: 85b39ad569180929e5620c45bf9a98ef6ee99d42
2022-09-07 12:10:52 +00:00
David Overton
f4419236ed Gdc capabilities scalar types - GDW-87
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5597
GitOrigin-RevId: 4f561bf476266955d7b1d3dbca4d406a97bf8b34
2022-09-06 04:26:03 +00:00
Daniel Harvey
4964ddc6e9 server: skip SOH header in FromCol EncJSON instance
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5710
GitOrigin-RevId: 6065c5b378cd458ad7ea05ce5ca5ff3cee5b13a7
2022-09-05 15:04:32 +00:00
Tom Harding
136349a70a Tidy up simple object query tests, match fixtures to docs
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5752
GitOrigin-RevId: 2e308504a188745ad5714d60d0fe449a65d6f950
2022-09-05 11:09:38 +00:00
awjchen
78cf1d544e server/pro: enable health check on data sources and report via logging and API
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4868
Co-authored-by: Rakesh Emmadi <12475069+rakeshkky@users.noreply.github.com>
Co-authored-by: Sean Park-Ross <94021366+seanparkross@users.noreply.github.com>
GitOrigin-RevId: b8d43e3f7d977c4bb37b8506ac87ce7bf289d542
2022-09-02 06:34:29 +00:00
Philip Lykke Carlsen
b0d2262b20 Let the same SQL function serve as both a computed field and as a root field (fixes hasura/graphql-engine#8643)
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5676
GitOrigin-RevId: f891e4172504897bb125bb1e524dc75b11e319c1
2022-08-30 15:00:45 +00:00
Daniel Harvey
2e2b894ed3 tests: log everything posted to HGE in hspec tests
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5636
GitOrigin-RevId: d6bc47857e3ad3c6a995284ba6756a643cfb9c4c
2022-08-30 08:54:04 +00:00
Lyndon Maydwell
88c5b14c3d Adding EXPLAIN endpoint capability and implementation for SQLite data connector agent GDW-181
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5603
GitOrigin-RevId: b9255d265ceb88d96643c95f409387fb93df6676
2022-08-29 03:40:16 +00:00
Solomon
18f9bf481c Fix GDC Metadata API Tests and Typescript Code Generation
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5624
GitOrigin-RevId: a595aeb94971a5ee4968b403af4670e06684b708
2022-08-29 00:21:26 +00:00
Auke Booij
99f7a0fb87 Amend console assets versioning scheme for CE
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5628
GitOrigin-RevId: 550cc987a7142f46f4c380d8217fe6ad8ce53fe9
2022-08-26 12:39:16 +00:00
Gil Mizrahi
a35bd278ad server/postgres: fix string literals in arrays
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5634
GitOrigin-RevId: 67970b0c0f10c187c1a4b97d457717e14fdbd2c8
2022-08-26 09:42:26 +00:00
Jesse Hallett
84fd5910b0 server: polymorphic codec for metadata sources
This PR expands the OpenAPI specification generated for metadata to include separate definitions for `SourceMetadata` for each native database type, and for DataConnector.

For the most part the changes add `HasCodec` implementations, and don't modify existing code otherwise.

The generated OpenAPI spec can be used to generate TypeScript definitions that distinguish different source metadata types based on the value of the `kind` properly. There is a problem: because the specified `kind` value for a data connector source is any string, when TypeScript gets a source with a `kind` value of, say, `"postgres"`, it cannot unambiguously determine whether the source is postgres, or a data connector. For example,

```ts
function consumeSourceMetadata(source: SourceMetadata) {
    if (source.kind === "postgres" || source.kind === "pg") {
        // At this point TypeScript infers that `source` is either an instance
        // of `PostgresSourceMetadata`, or `DataconnectorSourceMetadata`. It
        // can't narrow further.
        source
    }
    if (source.kind === "something else") {
        // TypeScript infers that this `source` must be an instance of
        // `DataconnectorSourceMetadata` because `source.kind` does not match
        // any of the other options.
        source
    }
}
```

The simplest way I can think of to fix this would be to add a boolean property to the `SourceMetadata` type along the lines of `isNative` or `isDataConnector`. This could be a field that only exists in serialized data, like the metadata version field. The combination of one of the native database names for `kind`, and a true value for `isNative` would be enough for TypeScript to unambiguously distinguish the source kinds.

But note that in the current state TypeScript is able to reference the short `"pg"` name correctly!

~~Tests are not passing yet due to some discrepancies in DTO serialization vs existing Metadata serialization. I'm working on that.~~

The placeholders that I used for table and function metadata are not compatible with the ordered JSON serialization in use. I think the best solution is to write compatible codecs for those types in another PR. For now I have disabled some DTO tests for this PR.

Here are the generated [OpenAPI spec](https://github.com/hasura/graphql-engine-mono/files/9397333/openapi.tar.gz) based on these changes, and the generated [TypeScript client code](https://github.com/hasura/graphql-engine-mono/files/9397339/client-typescript.tar.gz) based on that spec.

Ticket: [MM-66](https://hasurahq.atlassian.net/browse/MM-66)

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5582
GitOrigin-RevId: e1446191c6c832879db04f129daa397a3be03f62
2022-08-25 18:36:02 +00:00
Gil Mizrahi
5aab7e5ce9 add cockroach to docker compose and tests-hspec
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5558
Co-authored-by: Daniel Harvey <4729125+danieljharvey@users.noreply.github.com>
GitOrigin-RevId: b7f242939e718d5bb4f22b11c093ae77d21cdcce
2022-08-25 17:18:40 +00:00
Naveen Naidu
dae6cfa9a6 server: enforce event triggers name in a source to be unique
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5394
GitOrigin-RevId: 78015262365985329c18ed25897ca6d6f4422ecb
2022-08-23 08:51:11 +00:00
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