Commit Graph

47 Commits

Author SHA1 Message Date
Tom Harding
d48493ff24 Move stored procedure validation into the schema cache builder
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9521
GitOrigin-RevId: a7fdfa67271df7477950ed0f2b3a68cdb38cc106
2023-06-13 13:31:06 +00:00
Daniel Harvey
d5467d8d3a chore(server): add track_logical_model and untrack_logical_model to bulk_atomic command
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9484
Co-authored-by: Gil Mizrahi <8547573+soupi@users.noreply.github.com>
GitOrigin-RevId: d10490be355e859396e20e2a4a66361ed9d01893
2023-06-12 06:52:39 +00:00
Gil Mizrahi
15ce5196d0 throw an error on non-existing source in get_logical_model / get_native_query
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9421
GitOrigin-RevId: 2839e587c2966aa4580a631c3eff389c98b275df
2023-06-05 15:17:24 +00:00
Tom Harding
b124c943a9 chore(server): allow recursive native queries
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9373
Co-authored-by: Gil Mizrahi <8547573+soupi@users.noreply.github.com>
Co-authored-by: Daniel Harvey <4729125+danieljharvey@users.noreply.github.com>
GitOrigin-RevId: b998da0e2725f687a00c2c6c993435e44df4f70f
2023-06-02 10:37:55 +00:00
Daniel Harvey
7d011644ac chore(server): allow non-nullable NQ -> NQ object relationships
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9353
GitOrigin-RevId: 9da95675d224f3045509592c2515b7afa2500d00
2023-05-31 10:34:28 +00:00
Daniel Harvey
9de3db4729 chore(server): respect logical model array nullability
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9303
GitOrigin-RevId: 4d38a125a6889e2b0be34905e21a78036a77881e
2023-05-31 00:15:47 +00:00
Daniel Harvey
090a41ebf4 Move Logical Model parsers to Hasura.LogicalModel.Schema
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9298
GitOrigin-RevId: 8a4fdff7381495c94eede9d91437b635c8a60eac
2023-05-25 12:30:32 +00:00
Tom Harding
e0c0043e76 Upgrade Ormolu to 0.7.0.0
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9284
GitOrigin-RevId: 2f2cf2ad01900a54e4bdb970205ac0ef313c7e00
2023-05-24 13:53:53 +00:00
David Overton
e5f88d8039 Nested array support for Data Connectors Backend and MongoDB
## Description

This change adds support for querying into nested arrays in Data Connector agents that support such a concept (currently MongoDB).

### DC API changes

- New API type `ColumnType` which allows representing the type of a "column" as either a scalar type, an object reference or an array of `ColumnType`s. This recursive definition allows arbitrary nesting of arrays of types.
- The `type` fields in the API types `ColumnInfo` and `ColumnInsertSchema` now take a `ColumnType` instead of a `ScalarType`.
- To ensure backwards compatibility, a `ColumnType` representing a scalar serialises and deserialises to the same representation as `ScalarType`.
- In queries, the `Field` type now has a new constructor `NestedArrayField`. This contains a nested `Field` along with optional `limit`, `offset`, `where` and `order_by` arguments. (These optional arguments are not yet used by either HGE or the MongoDB agent.)

### MongoDB Haskell agent changes

- The `/schema` endpoint will now recognise arrays within the JSON validation schema and generate corresponding arrays in the DC schema.
- The `/query` endpoint will now handle `NestedArrayField`s within queries (although it does not yet handle `limit`, `offset`, `where` and `order_by`).

### HGE server changes

- The `Backend` type class adds a new type family `XNestedArrays b` to enable nested arrays on a per-backend basis (currently enabled only for the `DataConnector` backend.
- Within `RawColumnInfo` the column type is now represented by a new type `RawColumnType b` which mirrors the shape of the DC API `ColumnType`, but uses `XNestedObjects b` and `XNestedArrays b` type families to allow turning nested object and array supports on or off for a particular backend. In the `DataConnector` backend `API.CustomType` is converted into `RawColumnInfo 'DataConnector` while building the schema.
- In the next stage of schema building, the `RawColumnInfo` is converted into a `StructuredColumnInfo` which allows us to represent the three different types of columns: scalar, object and array. TODO: the `StructuredColumnInfo` looks very similar to the Logical Model types. The main difference is that it uses the `XNestedObjects` and `XNestedArrays` type families. We should be able to combine these two representations.
- The `StructuredColumnInfo` is then placed into a `FIColumn` `FieldInfo`. This involved some refactoring of `FieldInfo` as I had previously split out `FINestedObject` into a separate constructor. However it works out better to represent all "column" fields (i.e. scalar, object and array) using `FIColumn` as this make it easier to implement permission checking correctly. This is the reason the `StructuredColumnInfo` was needed.
- Next, the `FieldInfo` are used to generate `FieldParser`s. We add a new constructor to `AnnFieldG` for `AFNestedArray`. An `AFNestedArray` field parser can contain either a simple array selection or an array aggregate. Simple array `FieldParsers` are currently limited to subfield selection. We will add support for limit, offset, where and order_by in a future PR. We also don't yet generate array aggregate `FieldParsers.
- The new `AFNestedArray` field is handled by the `QueryPlan` module in the `DataConnector` backend. There we generate an `API.NestedArrayField` from the AFNestedArray. We also handle nested arrays when reshaping the response from the DC agent.

## Limitations

- Support for limit, offset, filter (where) and order_by is not yet fully implemented, although it should not be hard to add this
- Support for aggregations on nested arrays is not yet fully implemented
- Permissions involving nested arrays (and objects) not yet implemented
- This should be integrated with Logical Model types, but that will happen in a separate PR

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9149
GitOrigin-RevId: 0e7b71a994fc1d2ca1ef73bfe7b96e95b5328531
2023-05-24 08:02:43 +00:00
Daniel Harvey
a73a009031 chore(server): more expressive logical models
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9197
GitOrigin-RevId: 3471c68d4e59310bdb62ecb3694ab30a2094916e
2023-05-19 16:14:20 +00:00
Daniel Harvey
8f4692d871 chore(server): move table related things to Hasura.Table.*
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9174
GitOrigin-RevId: d440647ac04b9c1717ecf22a2dbfb8c5f22b7c7a
2023-05-17 08:55:32 +00:00
Tom Harding
7617355aa9 Remove feature flag on logical models
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8998
GitOrigin-RevId: 2cde88c5d595860aa97a5c8480442a1ff64a4360
2023-05-04 12:09:39 +00:00
Daniel Harvey
6178a1fd82 chore(server): split Logical Model lenses into files
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8989
GitOrigin-RevId: f0f6e75732408f21ebe5fdc5af3f680cd96ae789
2023-04-28 18:47:38 +00:00
Tom Harding
912a03ec23 Remove reference to custom types
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9005
GitOrigin-RevId: 8fa120187b6e351fbf10f4b80adf4d01c291fc30
2023-04-28 17:54:49 +00:00
Daniel Harvey
cb00535693 chore(server): add link-type to Logical Model references
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9004
GitOrigin-RevId: f361ca5f3b82995096f9289f8e90c7c20920a744
2023-04-28 16:48:19 +00:00
Gil Mizrahi
7aef17863a refactor(cleanup): extract nullablescalartype
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9001
GitOrigin-RevId: 5053e4c881f0d037b9170b434bcf533284a827a6
2023-04-28 16:16:08 +00:00
Tom Harding
b6799f0882 Import InsOrdHashMap, not OMap, OM, Map, HM, ...
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8946
GitOrigin-RevId: 434e7c335bc69119020dd35761c7d4539bc51ff8
2023-04-27 07:43:22 +00:00
Tom Harding
4885a3fd9a Import J, not Aeson, A, JSON, Yaml...
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8948
GitOrigin-RevId: d70c4a50b94ffe7d42a1fb1017051d351f236acc
2023-04-26 17:30:24 +00:00
Tom Harding
7e334e08a4 Import HashMap, not HM, Map, M...
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8947
GitOrigin-RevId: 18e52c928e1df535579e2077b4af6c2ce92bdcef
2023-04-26 15:43:44 +00:00
Daniel Harvey
15ce4818b2 chore(server): fix Logical Model permissions for nested fields
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8889
GitOrigin-RevId: c86f5328170aaa40cc5bf469f5cbb98e01ac521d
2023-04-25 11:59:48 +00:00
Tom Harding
6a53470728 Break Metadata.DTO.Utils into Autodocodec.Extended and RQL.Types.BackendTag
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8874
GitOrigin-RevId: 77a8f61e1f5a5bb84908b5afd743a575e723d87f
2023-04-25 09:01:12 +00:00
Daniel Harvey
ea5c92acae chore(server): move Hasura.SQL.Backend to Hasura.RQL.Types.BackendType
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8876
GitOrigin-RevId: abfc18eeef96a1f3593bfe823adab4d161161333
2023-04-24 18:37:33 +00:00
Tom Harding
1698f9dd91 Extract RoleName from Hasura.Session, move it into Hasura.RQL.Types.Roles
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8856
Co-authored-by: Daniel Harvey <4729125+danieljharvey@users.noreply.github.com>
GitOrigin-RevId: 38ad67de9b3d765c4eb50943dd52b8fc32317540
2023-04-24 08:51:58 +00:00
Daniel Harvey
59244eac85 feature(server): basic array relationships on Native Queries
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8752
GitOrigin-RevId: adea2941e01c4037b74f6e8c9150ff0819729fae
2023-04-21 11:57:42 +00:00
Philip Lykke Carlsen
983fc2ad47 Rename "Custom Return Types" → "Logical Models"
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8800
GitOrigin-RevId: e5e10f31c6cc8953a8ee947441a7f80b0e9b5e5e
2023-04-19 09:05:25 +00:00
Philip Lykke Carlsen
0346224444 Rename "Logical Models" → "Native Queries"
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8769
GitOrigin-RevId: 66f2cbfb620d641e672a4074554d9d324a18c591
2023-04-13 16:12:20 +00:00
Tom Harding
af0b56332d De-duplicate prepared logical model arguments
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8723
GitOrigin-RevId: 5df1a05c47852d7371ef323bb0df2ac9d1749243
2023-04-12 09:05:48 +00:00
Antoine Leblanc
306162f477 Remove ServerConfigCtx.
### Description

This PR removes `ServerConfigCtx` and `HasServerConfigCtx`. Instead, it favours different approaches:
- when the code was only using one field, it passes that field explicitly (usually `SQLGenCtx` or `CheckFeatureFlag`)
- when the code was using several fields, but in only one function, it inlines
- for the cache build, it introduces `CacheStaticConfig` and `CacheDynamicConfig`, which are subsets of `AppEnv` and `AppContext` respectively

The main goal of this is to help with the modularization of the engine: as `ServerConfigCtx` had fields whose types were imported from several unrelated parts of the engine, using it tied together parts of the engine that should not be aware of one another (such as tying together `Hasura.LogicalModel` and `Hasura.GraphQL.Schema`).

The bulk of this PR is a change to the cache build, as a follow up to #8509: instead of giving the entire `ServerConfigCtx` as a incremental rule argument, we only give the new `CacheDynamicConfig` struct, which has fewer fields. The other required fields, that were coming from the `AppEnv`, are now given via the `HasCacheStaticConfig` constraint, which is a "subset" of `HasAppEnv`.

(Some further work could include moving `StringifyNumbers` out of `GraphQL.Schema.Options`, given how it is used all across the codebase, including in `RQL.DML`.)

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8513
GitOrigin-RevId: 818cbcd71494e3cd946b06adbb02ca328a8a298e
2023-04-04 16:01:42 +00:00
Gil Mizrahi
352d8ff09c validate logical models custom return type against postgres
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8563
GitOrigin-RevId: 462a608e0e90d1923bc1d735257f4506825f5db1
2023-04-04 14:02:59 +00:00
Daniel Harvey
9c99bcb6f8 chore(server): move perms to custom return types
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8604
GitOrigin-RevId: ff024429b3f06e4867334665f35d4bd404a85cba
2023-04-04 12:46:51 +00:00
Daniel Harvey
79682e0598 chore(server): move custom types out of logical models
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8565
Co-authored-by: Tom Harding <6302310+i-am-tom@users.noreply.github.com>
GitOrigin-RevId: 38bf56cc420a6c818a9ca7d6f846f5018535c808
2023-03-31 15:35:13 +00:00
Daniel Harvey
2d9c8299c2 feature(server): add SQLServer logical models
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8388
GitOrigin-RevId: cbf813d1114cb03816003ba73788d33ac37f1473
2023-03-27 16:56:05 +00:00
Tom Harding
b2f683f56d Logical Models for BigQuery
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8447
Co-authored-by: Daniel Harvey <4729125+danieljharvey@users.noreply.github.com>
Co-authored-by: Nicolas Beaussart <7281023+beaussan@users.noreply.github.com>
Co-authored-by: Antoine Leblanc <1618949+nicuveo@users.noreply.github.com>
Co-authored-by: Varun Choudhary <68095256+Varun-Choudhary@users.noreply.github.com>
Co-authored-by: ananya-2410 <107847554+ananya-2410@users.noreply.github.com>
Co-authored-by: Matthew Goodwin <49927862+m4ttheweric@users.noreply.github.com>
Co-authored-by: Abhijeet Khangarot <26903230+abhi40308@users.noreply.github.com>
Co-authored-by: Puru Gupta <32328846+purugupta99@users.noreply.github.com>
Co-authored-by: Gil Mizrahi <8547573+soupi@users.noreply.github.com>
Co-authored-by: Rob Dominguez <24390149+robertjdominguez@users.noreply.github.com>
GitOrigin-RevId: ddef9d54bfad6b7d5dc51251dbe47eac43995da3
2023-03-24 15:17:03 +00:00
Daniel Harvey
7e437fc32b feature(server): ordered columns in Logical Model return type
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8434
Co-authored-by: Philip Lykke Carlsen <358550+plcplc@users.noreply.github.com>
GitOrigin-RevId: 4ebd569bef868e01b15583e4af90d583d6713da7
2023-03-22 16:35:56 +00:00
Philip Lykke Carlsen
34e40e6caf refactor: newtype alias for action checking feature flags
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8429
GitOrigin-RevId: e543b608a91e0c39c39f06b772a7d43f360d5dc3
2023-03-22 10:48:22 +00:00
Daniel Harvey
c441fa4a7f feature(server): allow untracking Logical Model when feature is off
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8339
GitOrigin-RevId: 20d4bfa465fa1ad6d1b2c630973e9c59a9d6178e
2023-03-15 18:20:58 +00:00
Gil Mizrahi
413d8d2bb4 name conflicts for logical models
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8236
GitOrigin-RevId: e8edc914b34f362ee3391f0a70bfcbea6d6fa11f
2023-03-09 07:02:41 +00:00
Daniel Harvey
e93d3d2735 feature(server): allow nullability in Logical Model arguments
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8214
GitOrigin-RevId: 1ecf4c9c362aad9eabad2134a70266ff1170577b
2023-03-07 10:04:58 +00:00
Daniel Harvey
ba5753e0cb feature(server): select permissions for Logical Models
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8049
Co-authored-by: Tom Harding <6302310+i-am-tom@users.noreply.github.com>
GitOrigin-RevId: 0e51ebfbf01e408f9a7a343edb5b3d9a7183140a
2023-03-06 16:40:48 +00:00
Tom Harding
df11036367 Resolve LogicalModelMetadata permissions into LogicalModelInfo
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8191
GitOrigin-RevId: e7969b7dcbe70381fb227a5008eb75e4cdcbda51
2023-03-06 15:08:08 +00:00
Tom Harding
769c25c7f3 Drop a logical model from the metadata
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8189
GitOrigin-RevId: f82dbeaef8bd88ac2065e43661bb1480b340fea1
2023-03-03 17:59:57 +00:00
Tom Harding
16dac48f0c chore(server): Factor out logical model metadata existence check
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8187
GitOrigin-RevId: c18b593c8dec68b655af369e83756c37a36f53f1
2023-03-03 16:46:07 +00:00
Tom Harding
6385b4b968 feat(server): Add metadata command to create logical model permissions in metadata
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8184
GitOrigin-RevId: b38a39812acd4a0a5ced93945b476acf8480c792
2023-03-03 15:29:16 +00:00
Tom Harding
1574125f10 Separate the metadata and cache representations of logical models
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8176
GitOrigin-RevId: a1ead98ea9d07b30ee09298e7f27a139d87711fa
2023-03-02 16:04:18 +00:00
Gil Mizrahi
7872be0e82 feature(server): support subscriptions in logical models
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8076
GitOrigin-RevId: 84a3e89d97bdb81c02803b644f417dfe51834405
2023-02-28 11:18:43 +00:00
Gil Mizrahi
625e41cd77 rename naqi to logimo part 3 - data types
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8068
GitOrigin-RevId: 435527a98e645ed69c9be484ff0bd21af8181d69
2023-02-22 13:46:54 +00:00
Gil Mizrahi
2b0e9ea14c rename NativeQuery module hierarchy to LogicalModel
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8063
GitOrigin-RevId: 0ed0cee7fb1d77f166770caae21cc05d5dd30b75
2023-02-22 09:23:54 +00:00