Commit Graph

4207 Commits

Author SHA1 Message Date
Anon Ray
e87433c2bb server: remove hdb_lib and add tests for read-only source
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3634
Co-authored-by: Philip Lykke Carlsen <358550+plcplc@users.noreply.github.com>
GitOrigin-RevId: 2db62a279496cd7e5dd57bdf02c3efa7b70042c8
2022-02-21 10:00:00 +00:00
Philip Lykke Carlsen
109a0beca8 (Fix #3456) Guard calls to JSON_QUERY on null arguments
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3655
GitOrigin-RevId: 6e0aed6e96b2995af11366676fa9c453bb44a7aa
2022-02-21 08:53:06 +00:00
Divya Bhushan
78c856cc02 docs: update the hasura sample apps links
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3693
Co-authored-by: Rikin Kachhia <54616969+rikinsk@users.noreply.github.com>
GitOrigin-RevId: e27ae1727496acb1077433d5715df39edc438b06
2022-02-18 17:06:46 +00:00
Auke Booij
557a3d4b6e Derive a few Semigroup+Monoid instances
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3717
GitOrigin-RevId: 9bc7f64754a8461a006d9b633a712124f828166e
2022-02-18 14:58:04 +00:00
Antoine Leblanc
5541ec011e Add remote relationships hspec tests
## Description

This PR adds the possibility for hspec tests to start a remote server with a custom schema, using the _morpheus_ library. In addition, it adds:
- X-to-DB object relationships tests
- X-to-DB array relationships tests
- X-to-RS relationships tests

For now, all those X are only postgres, but the tests are written in a way that will allow for it to easily be any other DB, or even remote schemas. The actual tests were taken mostly from #3069.

To achieve this, this PR heavily refactors the test harness. Most importantly: it generalizes the notion of a `Backend` to a notion of generic `Context`, allowing for contexts that are the unions of two backends, or of a backend and a remote schema.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3567
Co-authored-by: jkachmar <8461423+jkachmar@users.noreply.github.com>
GitOrigin-RevId: 623f700ba482743f94d3eaf659e6cfa22cd0dbc9
2022-02-18 13:36:31 +00:00
Auke Booij
9bb6575d60 Metadata code cleanups
There are three minor cleanups here:

- The first argument to the `setMetadataInCatalog` method is always `Just`. It is thus important to avoid `Maybe`, because this means that a crucial piece of code (saving metadata) is completely untested.
- Rather than spelling them out, we can derive the `Semigroup`/`Monoid` instances for `MetadataModifier` through the `Endo` type.
- I've renamed the name of the getter of the `MetadataModifier` newtype to **r**unMetadataModifier. Using record puns, this allows us to write:

```diff
-  putMetadata $ unMetadataModifier metadataModifier metadata
+  putMetadata $ runMetadataModifier metadata
```
which is nicer to read.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3703
GitOrigin-RevId: fd36b3c5202017f5afc943c01dfdd7c82c099bdd
2022-02-18 12:47:56 +00:00
Sooraj
9144d979d4 console: support for mssql read replicas
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3630
Co-authored-by: Varun Choudhary <68095256+Varun-Choudhary@users.noreply.github.com>
GitOrigin-RevId: 9660a5d9cdec8aff17cf20fcad3f309bdb3d182e
2022-02-18 09:10:28 +00:00
jkachmar
d50aae87a5 Updates cabal freeze file
#### TODO

- [x] fix `hashable >= 1.3.1` serialization ordering issue [^1]
  - `test_graphql_mutations.py::TestGraphQLMutateEnums` was failing
- [x] fix `unordered-containers` serialization ordering issue [^2]
  - `test_graphql_queries.py` was failing on Citus
- [ ] verify that no new failures have been introduced
- [ ] open issues to fix the above
  - identify test cases that "leak" implementation details by depending on `hashable` instance ordering
  - bump `hashable >= 1.3.1` and update test cases with new ordering OR modify them so that ordering is stable
  - bump `unordered-containers >= 0.2.15.0` and update test cases with new ordering OR modify them so that ordering is stable
    - one of the test cases was failing on string equality comparison for a generated Citus query
    - we probably don't want to _actually_ do this unless there are _very specific_ guarantees we want to make about generated query structure
---

Just what it says on the tin.

https://github.com/hasura/graphql-engine-mono/pull/3538 updated the freeze file a few weeks ago, but it looks like the index state hadn't been updated since December so a lot of stuff that had newer versions didn't get updated.

---

EDIT: I should add, the motivation for doing this in the first place is that `hspec > 2.8.4` now supports specifying filtering spec trees based on patterns provided by the `HSPEC_MATCH` environment variable.

For example, one could have a script that executes the following:
```
HSPEC_MATCH="PostgreSQL" \
  ghcid \
    --command \
      'cabal repl graphql-engine:test:tests-hspec \
         --repl-option -O0 \
         --repl-option -fobject-code' \
    --test "main"
```
...which will loop on typechecking the `tests-hspec` component, and then as soon as it passes (i.e. no warnings or errors) will run _only_ the `PostgreSQL` sub-components.

[^1]: `hashable >= 1.3.1.0` [updated its default salts](https://github.com/haskell-unordered-containers/hashable/pull/196), which [broke serialization ordering](https://github.com/haskell/aeson/issues/837)
[^2]: `unordered-containers >= 0.2.16.0` [introduced changes to some of its internal functions](https://hackage.haskell.org/package/unordered-containers-0.2.16.0/changelog) which seem like they could have affected serialization stability

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3672
GitOrigin-RevId: bbd1d48c73db4021913f0b5345b7315a8d6525d3
2022-02-18 05:32:08 +00:00
Vijay Prasanna
bd4b643cba console: Add minimal version of metadata migration hook
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3629
Co-authored-by: Varun Choudhary <68095256+Varun-Choudhary@users.noreply.github.com>
GitOrigin-RevId: 715aab88b7d6a1b1526899f17b167394c60e9574
2022-02-17 16:19:14 +00:00
Gil Mizrahi
69fd7449be server/mssql: Add max precision to nvarchar and varchar session variables
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3668
GitOrigin-RevId: 04de036eec00297e79d15d0b0429f9994378735a
2022-02-17 14:12:45 +00:00
Abhijeet Khangarot
cd219daae9 console: update know more link for remote_db relationships
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3691
GitOrigin-RevId: 05ab7e0b3899f3106d5e4b664c6877e608a49fa8
2022-02-17 09:24:12 +00:00
Auke Booij
f026d44438 Role-invariant schema constructors
We build the GraphQL schema by combining building blocks such as `tableSelectionSet` and `columnParser`. These building blocks individually build `{InputFields,Field,}Parser` objects. Those object specify the valid GraphQL schema.

Since the GraphQL schema is role-dependent, at some point we need to know what fragment of the GraphQL schema a specific role is allowed to access, and this is stored in `{Sel,Upd,Ins,Del}PermInfo` objects.

We have passed around these permission objects as function arguments to the schema building blocks since we first started dealing with permissions during the PDV refactor - see hasura/graphql-engine@5168b99e46 in hasura/graphql-engine#4111. This means that, for instance, `tableSelectionSet` has as its type:
```haskell
tableSelectionSet ::
  forall b r m n.
  MonadBuildSchema b r m n =>
  SourceName ->
  TableInfo b ->
  SelPermInfo b ->
  m (Parser 'Output n (AnnotatedFields b))
```

There are three reasons to change this.

1. We often pass a `Maybe (xPermInfo b)` instead of a proper `xPermInfo b`, and it's not clear what the intended semantics of this is. Some potential improvements on the data types involved are discussed in issue hasura/graphql-engine-mono#3125.
2. In most cases we also already pass a `TableInfo b`, and together with the `MonadRole` that is usually also in scope, this means that we could look up the required permissions regardless: so passing the permissions explicitly undermines the "single source of truth" principle. Breaking this principle also makes the code more difficult to read.
3. We are working towards role-based parsers (see hasura/graphql-engine-mono#2711), where the `{InputFields,Field,}Parser` objects are constructed in a role-invariant way, so that we have a single object that can be used for all roles. In particular, this means that the schema building blocks _need_ to be constructed in a role-invariant way. While this PR doesn't accomplish that, it does reduce the amount of role-specific arguments being passed, thus fixing hasura/graphql-engine-mono#3068.

Concretely, this PR simply drops the `xPermInfo b` argument from almost all schema building blocks. Instead these objects are looked up from the `TableInfo b` as-needed. The resulting code is considerably simpler and shorter.

One way to interpret this change is as follows. Before this PR, we figured out permissions at the top-level in `Hasura.GraphQL.Schema`, passing down the obtained `xPermInfo` objects as required. After this PR, we have a bottom-up approach where the schema building blocks themselves decide whether they want to be included for a particular role.

So this moves some permission logic out of `Hasura.GraphQL.Schema`, which is very complex.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3608
GitOrigin-RevId: 51a744f34ec7d57bc8077667ae7f9cb9c4f6c962
2022-02-17 08:17:17 +00:00
Solomon
d1ba271c3d Feature/removable request transform body and modified request transform API
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3475
GitOrigin-RevId: bc847b18d491fe4957a190f5d0fe2ae6e6719791
2022-02-17 04:37:18 +00:00
hasura-bot
972caf65f3 docs: move metadata api deprecation notes + update changelog + nitpicks
GITHUB_PR_NUMBER: 8186
GITHUB_PR_URL: https://github.com/hasura/graphql-engine/pull/8186

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3684
Co-authored-by: Rikin Kachhia <54616969+rikinsk@users.noreply.github.com>
GitOrigin-RevId: 6d08a9c76c008c62f70a2285afcfdde141ae68c3
2022-02-16 18:34:04 +00:00
Rikin Kachhia
c655fadc35 console: remove discord link from error page
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3682
GitOrigin-RevId: 85f47a92ea6a503f65c241346f4813e9c455f495
2022-02-16 16:46:24 +00:00
Vishnu Bharathi
0cd4bd1bff ci: tag release v2.3.0-beta.1 and v2.3.0-beta.1-pro.1
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3678
Co-authored-by: Rikin Kachhia <54616969+rikinsk@users.noreply.github.com>
GitOrigin-RevId: b5ffb38ec015773cffe6ec49fa1b2133f7bc4118
2022-02-16 11:09:47 +00:00
Divi
9e56d69599 ci: fix bugs faced during v2.2.0 release
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3659
Co-authored-by: Vishnu Bharathi <4211715+scriptnull@users.noreply.github.com>
GitOrigin-RevId: 8ddc98a2c06f64ae86f3a011f79f93e7c15161a0
2022-02-16 08:21:35 +00:00
Naveen Naidu
2e823234f9 server/remote-schema: Include OperationName in the request sent to remote schemas
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3581
Co-authored-by: Puru Gupta <32328846+purugupta99@users.noreply.github.com>
GitOrigin-RevId: 2db21d0df158a5a3229b883ee426b2f38f864f80
2022-02-16 07:55:19 +00:00
Robert
1ff3723ed8 server: assorted minor clean-up around HTTP managers
- consistent qualified imports
- less convoluted initialization of pro logging HTTP manager
- pass pro HTTP manager directly instead of via Has
- remove some dead healthcheck code

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3639
GitOrigin-RevId: dfa7b9c62d1842a07a8514cdb77f1ed86064fb06
2022-02-16 07:09:47 +00:00
Daniel Chambers
2c7a4e3a16 Customization of computed field GraphQL schema descriptions
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3615
GitOrigin-RevId: f51590d4cfc0412be9baa371353f9b9f3b908f84
2022-02-15 23:17:27 +00:00
Solomon
6c7820caa0 Bumps Kriti Version
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3625
GitOrigin-RevId: a453254ac89b470a56189e6178b2a00cf628fe63
2022-02-15 22:32:38 +00:00
Robert
ef64590985 server: remove an unused type and export
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3671
GitOrigin-RevId: 2d31c0131519be77366a7f1b761b8a07cfd36003
2022-02-15 19:56:13 +00:00
pranshi06
582d78110f server: Support returning scalar types in actions
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3453
GitOrigin-RevId: 59fee1460c5571322988b1f558a91ebeb2d55d22
2022-02-15 14:40:34 +00:00
Antoine Leblanc
dc4a286c64 Prepare test suite for remote servers tests
## Description

This PR adds all the scaffolding for tests that require remote servers. It is mostly a refactor of `Feature`; where we listed for each test a list of individual backends, we now provide a list of `Context`s, that allows for tests to specify not only how it should be setup, but also what state needs to be carried around throughout the test. This will be useful when launching custom remote servers.

Additionally, this PR:
- cleans the way we generate logs in the engine as part of the tests
- cleans the cabal file
- introduce a few more helpers for sending commands to the engine (such as `postMetadata_`)
- allows for headers in queries sent to the engine (to support permissions tests)
- adds basic code to start / stop a "remote" server

This PR is a pre-requisite of #3567.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3573
Co-authored-by: jkachmar <8461423+jkachmar@users.noreply.github.com>
GitOrigin-RevId: 05f808c6b85729dbb3ea6648c3e10a3c16b641ef
2022-02-14 17:25:28 +00:00
Matt Hardman
d2724878d3 Matt/console/permissions form
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2893
Co-authored-by: Ikechukwu Eze <22247592+iykekings@users.noreply.github.com>
GitOrigin-RevId: e6c8dedf8369df887fdc376c606b9b2e9b3d5ddd
2022-02-14 15:37:00 +00:00
Gil Mizrahi
476eb5fe2b update odbc to 0.2.6
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3647
GitOrigin-RevId: 82fb189c2bff9dce1c1b2e8e9dd2be4d9bc7f527
2022-02-14 10:43:08 +00:00
Kirill Zaborsky
2d9387e791 Add backoff for BigQuery calls
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3344
GitOrigin-RevId: ea5bdd02522e9a89c70501d4680e8741c3c6b6fc
2022-02-14 09:46:38 +00:00
Kirill Zaborsky
960cf2d954 Use 'hasura' as dataset in python test to unify it with hspec
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3636
GitOrigin-RevId: f4114fded09cbdd9875488610c635537478e4ab5
2022-02-14 06:23:07 +00:00
David Overton
8d0eb6b812 Use 429 error code when rate limit exceeded
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3628
GitOrigin-RevId: f5ae470b4036961e906125ef1a8446f0d48b39b1
2022-02-14 05:13:46 +00:00
Lyndon Maydwell
ff6aac31b8 Adding multiple jwt secrets (incorporating provenance requirements)
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3173
Co-authored-by: Solomon <24038+solomon-b@users.noreply.github.com>
Co-authored-by: Daniel Chambers <1214352+daniel-chambers@users.noreply.github.com>
GitOrigin-RevId: 395a5d5854896f866b612895d6f41e29376c2caa
2022-02-13 23:34:39 +00:00
Auke Booij
47315b78d6 Add Note explaining type collection
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3588
GitOrigin-RevId: f46d06e9476b22fe7abc699a5236ffefd23c1935
2022-02-10 18:14:01 +00:00
jkachmar
89714a85f6 Fixes 'Harness.Quoter' link typo
Just what it says on the tin.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3640
GitOrigin-RevId: 021f76720846f82ab893b206293681f1e0bfcacf
2022-02-10 16:09:35 +00:00
Daniel Chambers
dd403f92e2 Customization of table GraphQL schema descriptions
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3570
GitOrigin-RevId: f642a4d9efdd26a344951fcab6c1bbbc1253dfa3
2022-02-10 06:32:44 +00:00
Kirill Zaborsky
773870f443 BigQuery hspec tests
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3435
Co-authored-by: Vishnu Bharathi <4211715+scriptnull@users.noreply.github.com>
GitOrigin-RevId: 78f698becb83bd9732eddbe419361aff2799dd2c
2022-02-09 15:30:13 +00:00
paritosh-08
4d2a5dba51 server: fix multiple calls to database on startup
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3569
GitOrigin-RevId: 820d56a7af7faa05292ef65734d5d40fe3dd4641
2022-02-09 05:14:29 +00:00
Gil Mizrahi
efec0bf9ca server/postgres: LIMIT 1 on object relationships
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3489
Co-authored-by: Abby Sassel <3883855+sassela@users.noreply.github.com>
GitOrigin-RevId: f09a75508545cdbc34cf8728fad95bbb00bde018
2022-02-08 17:40:24 +00:00
Swann Moreau
8bd34b4a51 server, pro: add support for per-role allowlists
spec: https://github.com/hasura/graphql-engine-mono/pull/2278

Briefly:
- extend metadata so that allowlist entries get a new scope field
- update `add_collection_to_allowlist` to accept this new scope field,
  and adds `update_scope_of_collection_in_allowlist` to change the scope
- scope can be global or role-based; a collection is available for every
  role if it is global, and available to every listed role if it is role-based
- graphql-engine-oss is aware of role-based allowlist metadata; collections
  with non-global scope are treated as if they weren't in the allowlist

To run the tests:
- `cabal run graphql-engine-tests -- unit --match Allowlist`
- py-tests against pro:
  - launch `graphql-engine-pro` with `HASURA_GRAPHQL_ADMIN_SECRET` and `HASURA_GRAPHQL_ENABLE_ALLOWLIST`
  - `pytest test_allowlist_queries.py --hge-urls=... --pg-urls=... --hge-key=... --test-allowlist-queries --pro-tests`

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2477
Co-authored-by: Anon Ray <616387+ecthiender@users.noreply.github.com>
Co-authored-by: Robert <132113+robx@users.noreply.github.com>
GitOrigin-RevId: 01f8026fbe59d8701e2de30986511a452fce1a99
2022-02-08 16:54:49 +00:00
hasura-bot
195c05f14d cli: improve handling of wrapped errors in migrate operations
GITHUB_PR_NUMBER: 7992
GITHUB_PR_URL: https://github.com/hasura/graphql-engine/pull/7992

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3259
Co-authored-by: Shoki Hata <37888628+sho-hata@users.noreply.github.com>
GitOrigin-RevId: f93f251fb6de56212f7024eef06e965f85a9182a
2022-02-08 14:30:35 +00:00
Evie Ciobanu
111750e98f docs/mssql: add update and update index
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3477
Co-authored-by: Rikin Kachhia <54616969+rikinsk@users.noreply.github.com>
GitOrigin-RevId: 7e2d705baa98ceebf7a77dcd774756467e69a0b5
2022-02-08 13:19:46 +00:00
Varun Choudhary
b91cbe2903 console: enable support for update permissions for mssql
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3591
GitOrigin-RevId: 668505d81cb647a4cd7766b957f8676062ecde49
2022-02-08 10:50:11 +00:00
Evie Ciobanu
9337edf096 Evie/postgres/module docs
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3563
GitOrigin-RevId: e35aafbd210d526ed53db7088e1a47f89f0b9c44
2022-02-08 09:25:35 +00:00
Gil Mizrahi
8432407156 Add a tip on how to benchmark a query on postgres
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3593
GitOrigin-RevId: ebc3d05f788f45fd0b1cdebc40c090c7163824ad
2022-02-08 08:29:22 +00:00
Karthikeyan Chinnakonda
8d2acc833d server: add a note about experimental features
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3598
GitOrigin-RevId: e7f8d2f8d1b9490f0e28e59073f7b6a62447c04c
2022-02-08 07:52:24 +00:00
paritosh-08
b75706dd12 server: validate REST endpoint queries after metadata change
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2338
Co-authored-by: Sameer Kolhar <6604943+kolharsam@users.noreply.github.com>
GitOrigin-RevId: 9cd6bb940ba74fe41bdf2db3c4f35e89c4fb0577
2022-02-08 04:47:52 +00:00
Auke Booij
c4ef2d21f8 Make optimize_permission_filters an --experimental-features flag
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3589
GitOrigin-RevId: 5e102e5dd348e170ebe10f04ff9598fdc4167522
2022-02-07 18:05:39 +00:00
hasura-bot
73ddb0be91 docs: update Azure doc with JWT set up steps (fix #5413)
GITHUB_PR_NUMBER: 5885
GITHUB_PR_URL: https://github.com/hasura/graphql-engine/pull/5885

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3226
Co-authored-by: jay <30862819+fr8in@users.noreply.github.com>
Co-authored-by: Divya Bhushan <11659160+divyabhushan@users.noreply.github.com>
Co-authored-by: Rikin Kachhia <54616969+rikinsk@users.noreply.github.com>
GitOrigin-RevId: 7202ff2c3666138056d6d06e3a270b3c300dde02
2022-02-07 15:02:51 +00:00
Rakesh Emmadi
793aede022 server/mssql: improve database exception handling and better API errors
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3487
GitOrigin-RevId: d3f696072e8290b45c2f81509ce31cb5c13a4aef
2022-02-07 14:12:55 +00:00
Sooraj
a1eced3180 console: Implement a relationship table component
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3486
Co-authored-by: Alberto Francesco Motta <36401353+afmotta@users.noreply.github.com>
Co-authored-by: Martin Mark <74692114+martin-hasura@users.noreply.github.com>
GitOrigin-RevId: 730fe024d86d46de1b53bfbc7e171294527a407e
2022-02-07 11:08:26 +00:00
Ikechukwu Eze
0e9805ee07 console: tests for hooks
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3467
GitOrigin-RevId: ebf04a379a88b47996f908a062a894fe22f7c6ab
2022-02-07 10:08:53 +00:00
Daniel Chambers
ba5b7fedd4 Try to make JWK refresh integration tests more reliable in CI
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3577
GitOrigin-RevId: a5f8f6e3dc373e8f2b44fcfdcb6b97696d8c62b5
2022-02-07 09:13:09 +00:00