Commit Graph

500 Commits

Author SHA1 Message Date
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