Commit Graph

588 Commits

Author SHA1 Message Date
Rakesh Emmadi
fbfdf9a04d server/mssql: restrict "count" aggregate query on multiple columns
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3354
GitOrigin-RevId: d9890782ff8e3ea40ec52c0da82e43ecf5c36d2b
2022-01-18 14:54:46 +00:00
Kirill Zaborsky
47b9321ba4 BigQuery operators: like/nlike, geography
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2924
GitOrigin-RevId: 3748411cb4419a21a58283836adb5cb39d351d19
2022-01-18 13:37:12 +00:00
Rakesh Emmadi
f45130bc39 server/mssql: move mssql_run_sql test cases from v1/run_sql to v2/mssql/run_sql
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3370
GitOrigin-RevId: dfeb6e2dfda3fbe6ec2d318909dc793042b86d04
2022-01-18 02:21:04 +00:00
Kirill Zaborsky
7beb15b4a3 distinct_on for BigQuery
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3191
GitOrigin-RevId: e9f1c814b2caf09946389c4bcb30a0c42277abaf
2022-01-17 10:02:17 +00:00
Vamshi Surabhi
2e1be1d2c5 bump python test suite dependencies
This PR upgrades some of the pinned dependencies do not build with python 3.10 - cffi, ruamel, py. Further, it upgrades other packages where the effort is minimal.

For the reviewers: Please review it commit by commit.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3367
GitOrigin-RevId: c5401fe289d3185a79c4d382297f86fbde139825
2022-01-17 07:40:56 +00:00
Rakesh Emmadi
08f1725698 server/mssql: expand transactions to GraphQL queries and mssql_run_sql API
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3286
GitOrigin-RevId: 0b37767e271dfa43d36fa7f7cc9928ba6a22964d
2022-01-14 14:09:22 +00:00
Kirill Zaborsky
560daa63a8 BigQuery: fix support for joins in nodes of aggregate queries
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3233
GitOrigin-RevId: a3a4624d5cd0c4c562e27d1e3605882e7f5a3d0d
2022-01-13 15:09:52 +00:00
Evie Ciobanu
db22401e4f server: document python integration test suite
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3350
GitOrigin-RevId: 47dcebbfa84ed3681da40b3ea52e9b849b2fe8e4
2022-01-13 14:29:10 +00:00
Rakesh Emmadi
42a2787290 server/mssql: update odbc git reference to the commit which has error message fix
## Description

I come across a flaky test due to inconsistent error messages from the odbc lib we use for MSSQL database interactions.
```
cabal new-run -- test:graphql-engine-tests mssql
Up to date

Database.MSSQL.TransactionSpec
  runTx
    runs command in a transaction
    commits a successful transaction, returning a single field
    commits a successful transaction, returning multiple fields
    an unsuccesful transaction, expecting Int
    a successfull query expecting multiple rows
    an unsuccesful transaction; expecting single row
    displays the SQL Server error on an unsuccessful transaction FAILED [1]
    rolls back an unsuccessful transaction

Failures:

  src-test/Database/MSSQL/TransactionSpec.hs:60:15:
  1) Database.MSSQL.TransactionSpec.runTx displays the SQL Server error on an unsuccessful transaction
       expected: UnsuccessfulReturnCode "odbc_SQLExecDirectW" (-1) "[Microsoft][ODBC Driver 17 for SQL Server][SQL Server]The definition for column 'INVALID_SYNTAX' must include a data type.[Microsoft][ODBC Driver 17 for SQL Server][SQL Server]The definition for column 'INVALID_SYNTAX' must include a data type."
        but got: UnsuccessfulReturnCode "odbc_SQLExecDirectW" (-1) "[Microsoft][ODBC Driver 17 for SQL Server][SQL Server]The definition for column 'INVALID_SYNTAX' must include a data type.[Microsoft][ODBC Driver 17 for SQL Server][SQL Server]The definition for column 'INVALID_SYNTAX' must include a data type.\DEL"

  To rerun use: --match "/Database.MSSQL.TransactionSpec/runTx/displays the SQL Server error on an unsuccessful transaction/"

Randomized with seed 1101559172

Finished in 0.2140 seconds
8 examples, 1 failure
```
From above, we got a error message with `\DEL` appended. It is also driving the tests to fail in the CI on random PRs.

We brought this into notice of "fpco", the authors of the library and they got us a [quick fix](https://github.com/fpco/odbc/pull/43), which also improves the errors by removing the redundancy of the error message.

In this PR
- We update the `odbc` library git reference to fc5b592a60
- Update the error messages in tests to conform with improved error messages from `odbc`

## Related issues
Closes https://github.com/hasura/graphql-engine-mono/issues/3340

## Changelog

-  `CHANGELOG.md` is updated with user-facing content relevant to this PR.

## Affected components
-  server
-  tests

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3345
GitOrigin-RevId: a5694e8afb58b5ad71b9c9635a80dea1ec449f51
2022-01-13 11:15:01 +00:00
Evie Ciobanu
e30d51ee38 server: bump pytest version
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3348
GitOrigin-RevId: b1fd23da3c8af59e28575438ebffe75f6fb79428
2022-01-13 10:30:55 +00:00
Gil Mizrahi
fe41fbabbd mssql: Test upserts with permissions
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3280
GitOrigin-RevId: 861d4db59f75c83daef975fb3471b3c07889c9bc
2022-01-11 13:36:56 +00:00
Rakesh Emmadi
f49bb2b180 server/mssql: rollback a transaction based on the transaction state
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3247
GitOrigin-RevId: 70307d8723a63b9314b6ff4d897dcac6e8e93fb9
2022-01-05 08:03:59 +00:00
Gil Mizrahi
a5f2161e1c server/mssql: upsert - sql generation and execution
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3207
Co-authored-by: Rakesh Emmadi <12475069+rakeshkky@users.noreply.github.com>
GitOrigin-RevId: 92a4aa3cf802bc76858c4be4273a2f6a7d4aa395
2021-12-31 10:56:58 +00:00
Kirill Zaborsky
a2bf2fdc8f Fix aggregates for comparable types in BigQuery
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3211
GitOrigin-RevId: 1a63b0835fc5af687f6caca187968edc9efbb821
2021-12-30 10:00:47 +00:00
Rakesh Emmadi
549a5a31f0 server/mssql: fix pytest class names for update mutations
**TLDR**: Rename the pytest class names for update mutations by suffixing with `MSSQL` instead of `Mssql`.

We run the pytest in the CI using option `-k "MSSQL or Common"` which runs the test classes having `Common` or `MSSQL` in their name. Assuming the option `-k` to be case insensitive I named the update mutation test classes ending with `Mssql`. To confirm whether the CI is running the update mutation tests, I opened this PR with a commit making a test to fail and it is not reflected in the CI (all tests are passing!). I renamed the test classes with `MSSQL` as suffix. Now, the CI is able to capture the failing test as expected. Finally, the failing test is fixed.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3227
GitOrigin-RevId: 65b2b2bfbaca64c44ff7607148c32eb0c15e4956
2021-12-29 18:03:46 +00:00
Kirill Zaborsky
234a5385cd Fix support for FLOAT64 in BigQuery
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3209
GitOrigin-RevId: e7e981bcd043f0daab4b70344afb684484361758
2021-12-29 17:16:44 +00:00
Rakesh Emmadi
60183df1ea server/mssql: use temporary tables for insert mutation execution
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3205
GitOrigin-RevId: ff889ce43ed613c283edefa68992eab7c36db18c
2021-12-22 11:05:29 +00:00
David Overton
02aef27a75 Add request body to OpenAPI
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2632
Co-authored-by: Lyndon Maydwell <92299+sordina@users.noreply.github.com>
Co-authored-by: paritosh-08 <85472423+paritosh-08@users.noreply.github.com>
GitOrigin-RevId: 067e182effaed255ff047abeee309d65a9fb191c
2021-12-22 08:31:14 +00:00
Vamshi Surabhi
cca3831180 simplified schema cache representation of remote relationships
This PR pretty much does the same thing to remote relationship types in schemacache as what #2979 did to remote relationship types in the IR. On main remote relationships are represented by types of form `T from to`.  This PR changes it to `T from` which makes it a lot more reusable.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3037
GitOrigin-RevId: 90a5c9e2346c8dc2da6ec5b8c970d6c863d2afb8
2021-12-21 23:15:50 +00:00
Brandon Simmons
175391bb88 pytest: fix nondeterminism in bigquery/nested_array_relationships.yaml
Noticed this triggered in https://buildkite.com/hasura/graphql-engine-mono/builds/2770#93c45308-2178-479b-ba61-a81488b77ce5

closes https://github.com/hasura/graphql-engine-mono/issues/3168

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3160
Co-authored-by: Abby Sassel <3883855+sassela@users.noreply.github.com>
GitOrigin-RevId: e2146ca249264aa5c089d1cd7805e401167e22b2
2021-12-17 14:31:17 +00:00
paritosh-08
40678855d0 server: add support for nested object type in action
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2788
Co-authored-by: David Overton <7734777+dmoverton@users.noreply.github.com>
GitOrigin-RevId: f8ed9741e95b6864a48af7db338f3f619617483a
2021-12-15 23:52:43 +00:00
Kirill Zaborsky
279f22ed08 Fix support for multiple array relationships in BigQuery
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3003
GitOrigin-RevId: 7a9bf10be6436da2d87d5555f589e23c40c76dd6
2021-12-15 15:19:49 +00:00
Rakesh Emmadi
f00404e0f6 server/mssql: update mutation, SQL generation and execution
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3059
GitOrigin-RevId: 4ed0cbf54ac2a7103cb2b7adc97b2dfdf9994c4f
2021-12-15 13:56:34 +00:00
Evie Ciobanu
aff1ebb060 server: add more MSSQL tests to CI
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3129
Co-authored-by: Gil Mizrahi <8547573+soupi@users.noreply.github.com>
GitOrigin-RevId: 1e8fc7ed2426fc07f64ca042c9a0be005cc9d052
2021-12-15 10:44:09 +00:00
Anon Ray
4121c1dd3d Revert "Feature/multiple jwt secrets"
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3136
Co-authored-by: pranshi06 <85474619+pranshi06@users.noreply.github.com>
GitOrigin-RevId: aa41817e39f932f909067f2effca9d9973a5fb94
2021-12-14 14:29:52 +00:00
Lyndon Maydwell
36a987811e Fix interpreting urls from environment in the TestWebhookTransform endpoint
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3127
GitOrigin-RevId: 0e5ceaa01f3f27275accd828647ae8587216c80f
2021-12-14 03:25:13 +00:00
pranshi06
dee86453ea server: fallback to unauthorised role when JWT is not found in cookie
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2882
GitOrigin-RevId: ad03fbd0572e00ffe7abea106388a4df4d12af2c
2021-12-08 18:29:29 +00:00
Lyndon Maydwell
87426fdef4 Fixing REST Enpoints list variable bug
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3034
GitOrigin-RevId: af1c182879754359b253e630f1393d97d8bcfa2a
2021-12-03 21:57:25 +00:00
Rakesh Emmadi
7194dc691c server/mssql: fix SQL generation for aggregation queries in sql server (fixes #7773 & #7871)
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3024
GitOrigin-RevId: 30c0e7d713375d0c54ff7145d00985e3ade4f1a9
2021-12-02 14:22:42 +00:00
Solomon
f243760398 Feature/multiple jwt secrets
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2765
Co-authored-by: Philip Lykke Carlsen <358550+plcplc@users.noreply.github.com>
Co-authored-by: Chris Done <11019+chrisdone@users.noreply.github.com>
Co-authored-by: Aishwarya Rao <59638722+aishwaryarao712@users.noreply.github.com>
Co-authored-by: Tirumarai Selvan <8663570+tirumaraiselvan@users.noreply.github.com>
Co-authored-by: Karthikeyan Chinnakonda <15602904+codingkarthik@users.noreply.github.com>
Co-authored-by: Ikechukwu Eze <22247592+iykekings@users.noreply.github.com>
Co-authored-by: Brandon Simmons <210815+jberryman@users.noreply.github.com>
Co-authored-by: awjchen <13142944+awjchen@users.noreply.github.com>
Co-authored-by: Martin Mark <74692114+martin-hasura@users.noreply.github.com>
Co-authored-by: Abby Sassel <3883855+sassela@users.noreply.github.com>
Co-authored-by: Sooraj <8408875+soorajshankar@users.noreply.github.com>
Co-authored-by: Sameer Kolhar <6604943+kolharsam@users.noreply.github.com>
Co-authored-by: Vijay Prasanna <11921040+vijayprasanna13@users.noreply.github.com>
Co-authored-by: hasura-bot <30118761+hasura-bot@users.noreply.github.com>
Co-authored-by: Rakesh Emmadi <12475069+rakeshkky@users.noreply.github.com>
Co-authored-by: Sibi Prabakaran <737477+psibi@users.noreply.github.com>
Co-authored-by: Robert <132113+robx@users.noreply.github.com>
Co-authored-by: Vishnu Bharathi <4211715+scriptnull@users.noreply.github.com>
Co-authored-by: Praveen Durairaju <14110316+praveenweb@users.noreply.github.com>
Co-authored-by: Abhijeet Khangarot <26903230+abhi40308@users.noreply.github.com>
GitOrigin-RevId: b3b07c3b42da9f3daa450d6d9e5fbf0bf506c651
2021-12-02 05:36:46 +00:00
Antoine Leblanc
90d3192df2 Unified remote relationship metadata
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2903
Co-authored-by: Vamshi Surabhi <6562944+0x777@users.noreply.github.com>
GitOrigin-RevId: 11fd6efe8cea246471e525cfb5bad66fa53ccaf9
2021-12-01 04:54:30 +00:00
David Overton
5bfce057c6 Refactor remote schema customization
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2771
GitOrigin-RevId: 0c90136f956df3f4552140e6ca3d2f4766f8b3f5
2021-11-30 00:38:27 +00:00
Abby Sassel
3fc34aa028 server: deduplicate some pytests
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2988
GitOrigin-RevId: 018903d81c6025da2d9eb78aad4762a78f1f6c69
2021-11-26 19:38:17 +00:00
Antoine Leblanc
e3d5c0217f Rename tables in metadata tests to avoid conflicts.
### Description

Tests are not run the same way locally and on CI, which means that tests that work on CI can fail locally. In this case, the setup for each test is creating and dropping a table named `author`; a lot of the tests were also creating a table named `author` in source `pg1`. If `pg1` is the same as the default source, which is the case locally, then all of those tests fail, while the tests that use a default `pg1` such as CI would succeed.

This PR fixes this by renaming `author` to `author_local` where appropriate.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2982
GitOrigin-RevId: 5bc0149bc5f6cb27de9864afaded8af071ade454
2021-11-26 11:40:23 +00:00
Kirill Zaborsky
a2afe4116b BigQuery remote joins
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2874
Co-authored-by: Abby Sassel <3883855+sassela@users.noreply.github.com>
GitOrigin-RevId: 24b0304716795a28038629775238996c28b312a3
2021-11-24 16:22:55 +00:00
Gil Mizrahi
39002bc572 Parse session variables to their correct type in mssql
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2908
GitOrigin-RevId: d9d8811e0d0658f6396a7c94bce9b7d2deb5245e
2021-11-20 09:03:44 +00:00
Gil Mizrahi
0e65932355 server/mssql support delete mutations (close hasura/graphql-engine#7626)
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2691
Co-authored-by: Abby Sassel <3883855+sassela@users.noreply.github.com>
Co-authored-by: Rakesh Emmadi <12475069+rakeshkky@users.noreply.github.com>
GitOrigin-RevId: 8b66cc30e8e036ee56a5267c1d2f308155951ae9
2021-11-19 17:06:01 +00:00
Philip Lykke Carlsen
84027dad04 Breaking up the Postgres implementation of the update-schema into reusable components
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2889
GitOrigin-RevId: 49c5d59a6f817832f11b1773b078aa24cc650ab5
2021-11-18 18:03:57 +00:00
David Overton
f7e13cb7c9 Skip test if databases are not distinct
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2890
GitOrigin-RevId: 3728c6c5d3e1e12bcff2726a9ee5238dcd3b004b
2021-11-17 23:59:28 +00:00
Rakesh Emmadi
95be515a60 server/mssql: fix table_by_pk query returning empty array
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2810
GitOrigin-RevId: ed8e694d491d7bd28da0b39da2b1f1150d2e3735
2021-11-10 05:32:41 +00:00
David Overton
ec60386f9c Allow "extensions" field in remote schema response
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2818
GitOrigin-RevId: 505e8bae6d3e11199c229bd2b86af09161eb8b66
2021-11-10 02:34:56 +00:00
Puru Gupta
504f13725f server: forward auth webhook set-cookies header on response
>

High-Level TODO:

* [x] Code Changes
* [x] Tests
* [x] Check that pro/multitenant build ok
* [x] Documentation Changes
* [x] Updating this PR with full details
* [ ] Reviews
* [ ] Ensure code has all FIXMEs and TODOs addressed
* [x] Ensure no files are checked in mistakenly
* [x] Consider impact on console, cli, etc.

### Description
>
This PR adds support for adding set-cookie header on the response from the auth webhook. If the set-cookie header is sent by the webhook, it will be forwarded in the graphQL engine response.

Fixes a bug in test-server.sh: testing of get-webhook tests was done by POST method and vice versa. To fix, the parameters were swapped.

### Changelog

- [x] `CHANGELOG.md` is updated with user-facing content relevant to this PR.

### Affected components

- [x] Server
- [ ] Console
- [ ] CLI
- [x] Docs
- [ ] Community Content
- [ ] Build System
- [x] Tests
- [ ] Other (list it)

### Related Issues
->
Closes [#2269](https://github.com/hasura/graphql-engine/issues/2269)

### Solution and Design
>

### Steps to test and verify
>
Please refer to the docs to see how to send the set-cookie header from webhook.

### Limitations, known bugs & workarounds
>
- Support for only set-cookie header forwarding is added
- the value forwarded in the set-cookie header cannot be validated completely, the [Cookie](https://hackage.haskell.org/package/cookie) package has been used to parse the header value and any unnecessary information is stripped off before forwarding the header. The standard given in [RFC6265](https://datatracker.ietf.org/doc/html/rfc6265) has been followed for the Set-Cookie format.

### Server checklist

#### Catalog upgrade

Does this PR change Hasura Catalog version?
- [x] No
- [ ] Yes
  - [ ] Updated docs with SQL for downgrading the catalog

#### Metadata

Does this PR add a new Metadata feature?
- [x] No

#### GraphQL
- [x] No new GraphQL schema is generated
- [ ] New GraphQL schema is being generated:
   - [ ] New types and typenames are correlated

#### Breaking changes

- [x] No Breaking changes

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2538
Co-authored-by: Robert <132113+robx@users.noreply.github.com>
GitOrigin-RevId: d9047e997dd221b7ce4fef51911c3694037e7c3f
2021-11-09 12:01:31 +00:00
hasura-bot
a886da2f21 server: address recent graphql-ws related bugs
GITHUB_PR_NUMBER: 7730
GITHUB_PR_URL: https://github.com/hasura/graphql-engine/pull/7730

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2685
Co-authored-by: Sameer Kolhar <6604943+kolharsam@users.noreply.github.com>
GitOrigin-RevId: 55bafd4eb1576e95803350f3ba9c7920a21de037
2021-11-04 12:40:02 +00:00
David Overton
aac64f2c81 Source typename customization (close graphql-engine#6974)
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/1616
GitOrigin-RevId: f7eefd2367929209aa77895ea585e96a99a78d47
2021-10-29 14:43:14 +00:00
Solomon Bothwell
ce052f0b1b Move Request Transform into the Action Definition
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2717
GitOrigin-RevId: 7c17fa41e5df2cfbc49e0ce2a1f78b3627de7051
2021-10-29 04:13:29 +00:00
Swann Moreau
33d242779f server: call auth webhook even if the request fails to parse
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2604
Co-authored-by: Anon Ray <616387+ecthiender@users.noreply.github.com>
GitOrigin-RevId: fbecc77a519212e00c766c82e6efd5338661de49
2021-10-28 18:43:47 +00:00
Sibi Prabakaran
9f35e660c0 server/mysql: Implement MySQL explain API
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2367
Co-authored-by: Chris Done <11019+chrisdone@users.noreply.github.com>
Co-authored-by: Aniket Deshpande <922486+aniketd@users.noreply.github.com>
Co-authored-by: Abby Sassel <3883855+sassela@users.noreply.github.com>
GitOrigin-RevId: 701c84a1ca5e4ab73a229a804381a7f5281090f1
2021-10-23 11:43:25 +00:00
Rakesh Emmadi
8e88e73a52 server/mssql: add cascade to mssql_run_sql
<!-- Thank you for ss in the Title above ^ -->

## Description
<!-- Please fill thier. -->
<!-- Describe the changes from a user's perspective -->
We don't have dependency reporting mechanism for `mssql_run_sql` API i.e when a database object (table, column etc.) is dropped through the API we should raise an exception if any dependencies (relationships, permissions etc.) with the database object exists in the metadata.

This PR addresses the above mentioned problem by
-> Integrating transaction to the API to rollback the SQL query execution if dependencies exists and exception is thrown
-> Accepting `cascade` optional field in the API payload to drop the dependencies, if any
-> Accepting `check_metadata_consistency` optional field to bypass (if value set to `false`) the dependency check

### Related Issues
<!-- Please make surt title -->
<!-- Add the issue number below (e.g. #234) -->
Close #1853

### Solution and Design
<!-- How is this iss -->
<!-- It's better if we elaborate -->
The design/solution follows the `run_sql` API implementation for Postgres backend.

### Steps to test and verify
<!-- If this is a fehis is a bug-fix, how do we verify the fix? -->
- Create author - article tables and track them
- Defined object and array relationships
- Try to drop the article table without cascade or cascade set to `false`
- The server should raise the relationship dependency exists exception

## Changelog

-  `CHANGELOG.md` is updated with user-facing content relevant to this PR.
  If no changelog is required, then add the `no-changelog-required` label.

## Affected components
<!-- Remove non-affected components from the list -->

-  Server
-  Console
-  CLI
-  Docs
-  Community Content
-  Build System
-  Tests
-  Other (list it)

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2636
GitOrigin-RevId: 0ab152295394056c4ca6f02923142a1658ad25dc
2021-10-22 14:50:13 +00:00
Sameer Kolhar
631f39cadf server: fix flaky test_check_events_statuses test
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2467
Co-authored-by: paritosh-08 <85472423+paritosh-08@users.noreply.github.com>
GitOrigin-RevId: a6388397dae11e38962321915c06496cc57ffd64
2021-10-22 05:55:59 +00:00
Chris Done
459a7adbfb Add Types/FromIr changes for MySQL to work with the DataLoader
While it looks like a lot of work in FromIr.hs, you can rather review the type changes in `Hasura.Backends.MySQL.Types.Internal` and the changes to FromIr are only to reflect that. Essentially we're simplifying the FromIr code to not think about SQL-based joins: instead, FromIr produces fields necessary for the dataloader Plan/Execute to do their job properly.

I've done my best to ensure that all the hunks in the diff in this PR are minimal for slightly easier perusing.

I think future PRs will be more intentionally well structured, rather than created retroactively.

**Preceding PR:** #2549

**Next PR**: #2367

The tests have been run like this on my machine. I don't know more beyond that.

```
docker run -i -e "PYTEST_ADDOPTS=--color=yes" -e "TERM=xterm-256color" --net=host -v`pwd`:`pwd` -w`pwd`/server/tests-py chrisdone/hasura-pytest:b0f26f615 pytest  --hge-urls="http://localhost:8080"  --pg-urls="postgres://chinook:chinook@localhost:5432/chinook"  --backend mysql -k MySQL
```

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2608
Co-authored-by: Abby Sassel <3883855+sassela@users.noreply.github.com>
GitOrigin-RevId: a6483335c3036963360dde7d7d7eaf10859351cb
2021-10-21 23:51:17 +00:00
Solomon Bothwell
03aff6e82e Wrap string interpolations with double quotes on the backend
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2601
GitOrigin-RevId: 53c27dddd30968dd28325e3336721aa1a238815f
2021-10-21 13:32:49 +00:00
Philip Lykke Carlsen
c4536e801c Correctly translate permissions on functions to SQL, and simplify Bool Exp IR
Prior to this change, the SQL expression that resulted from translating permissions on functions would refer to the table of the function's return type, rather than the set of rows selected from the function being called.

Now the SQL that results from translating permissions correctly refer to the selected rows.

This PR also contains the suggested additions of https://github.com/hasura/graphql-engine-mono/pull/2563#discussion_r726116863, which simplifies the Boolean Expression IR, but in turn makes the Schema Dependency Discovery algorithm work a bit harder.

We are changing the definition of `data OpExpG`, but the format accepted by its JSON parser remains unchanged. While there does exist a generically derived `instance ToJSON OpExpG` this is only used in the (unpublished) `/v1/metadata/dump_internal_state` API.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2609
Co-authored-by: Gil Mizrahi <8547573+soupi@users.noreply.github.com>
GitOrigin-RevId: bb9a0b4addbc239499dd2268909220196984df72
2021-10-18 09:17:42 +00:00
David Overton
63291f6de8 fix OpenAPI for mutiple methods on same REST endpoint path
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2603
GitOrigin-RevId: 32b3133f0bb1a9bf50e4db492bab1eabf5a9430c
2021-10-14 10:32:18 +00:00
Abby Sassel
ef2e1ae935 server: skip flaky test to unblock PRs
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2592
GitOrigin-RevId: d56bb4d83b75010d39ffab997766fa5778d547ee
2021-10-13 18:18:57 +00:00
Lyndon Maydwell
788e5cb0c2 Include transformed request in errors
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2543
Co-authored-by: Solomon Bothwell <24038+ssbothwell@users.noreply.github.com>
GitOrigin-RevId: 1432a215cfc2c3e8345941b8072925f115f9259f
2021-10-13 00:29:49 +00:00
Abby Sassel
a9e3a1b4bd server/bigquery: improve test setup and documentation (close #2345)
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2495
GitOrigin-RevId: ef250a0796200be6b75363b4275eb8a7ae780154
2021-10-12 17:59:44 +00:00
pranshi06
be1395de31 [server] Allow Nullable action response
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2379
GitOrigin-RevId: eae2b0b401737ceb4e4885ba47c342e26f2026a1
2021-10-11 06:56:01 +00:00
Solomon Bothwell
f86378efb7 Fixes Aeson instances for UpdateAction
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2500
GitOrigin-RevId: 50d174d81dba0af18bc519110bef920ae64912cb
2021-10-07 23:35:36 +00:00
Gil Mizrahi
42cd2e69c0 Add support for customising function root field names
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2468
Co-authored-by: Philip Lykke Carlsen <358550+plcplc@users.noreply.github.com>
GitOrigin-RevId: 5ff85bb02e4e651376a40914b7ae0aabc8524a05
2021-10-07 13:03:22 +00:00
Puru Gupta
8b60122b9e [server] add openapi support
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/1935
Co-authored-by: paritosh-08 <85472423+paritosh-08@users.noreply.github.com>
Co-authored-by: pranshi06 <85474619+pranshi06@users.noreply.github.com>
Co-authored-by: Lyndon Maydwell <92299+sordina@users.noreply.github.com>
GitOrigin-RevId: 3e43b84d4e9e181b405855704112b49467dafdf9
2021-10-06 07:16:13 +00:00
Abby Sassel
ddb1b09f45 server/tests: improve pytest error message where execute_query responds with 500
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2506
GitOrigin-RevId: 45b55fd20cc5fae6a3f55b24d6736a1a606684ae
2021-10-05 17:26:42 +00:00
Karthikeyan Chinnakonda
64e2201179 server: enable inherited roles by default
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2325
Co-authored-by: Nicolas Beaussart <7281023+beaussan@users.noreply.github.com>
GitOrigin-RevId: 8ad6fe25a3788892128c1d56b8fa0e8feed2caca
2021-10-05 12:29:32 +00:00
Abby Sassel
3a6f4e1737 server/bigquery: allow empty tables in replace_metadata. Default BigQueryField mode to Nullable
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2466
GitOrigin-RevId: 1f3599d1317235a31c98d7ed1ece2db92d82e916
2021-10-01 18:30:01 +00:00
Rakesh Emmadi
09ae6af337 server/mssql: insert SQL generation and execution
>

### Description
>
Insert mutations for MSSQL backend. This PR implements execution logic.

### Changelog

- [x] `CHANGELOG.md` is updated with user-facing content relevant to this PR. If no changelog is required, then add the `no-changelog-required` label.

### Affected components

- [x] Server
- [x] Tests

### Related Issues
->
Close https://github.com/hasura/graphql-engine-mono/issues/2114

### Steps to test and verify
>
Track a MSSQL table and perform the generated insert mutation to test.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2248
Co-authored-by: Abby Sassel <3883855+sassela@users.noreply.github.com>
Co-authored-by: Philip Lykke Carlsen <358550+plcplc@users.noreply.github.com>
GitOrigin-RevId: 936f138c80d7a928180e6e7b0c4da64ecc1f7ebc
2021-10-01 12:53:15 +00:00
Rakesh Emmadi
6724b62719 server/postgres: add test case to test computed field with session argument in where expression
>

### Description
>
Add a simple test case to test behavior of computed fields with session argument in filter expression (`where`) of a graphql query.

### Changelog

- [ ] `CHANGELOG.md` is updated with user-facing content relevant to this PR. If no changelog is required, then add the `no-changelog-required` label.

### Affected components

- [x] Tests

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2465
GitOrigin-RevId: 25e287c7e7826350e93f2bebacd5d877568c9934
2021-09-30 11:27:37 +00:00
Sameer Kolhar
2a5d3a9432 server: skip TestScheduledEvent due to flakiness
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2473
GitOrigin-RevId: 2edf923f97aadf621cd9fc08163094c357f3beaa
2021-09-30 10:03:49 +00:00
Lyndon Maydwell
22bc0e09df Ignore unexpected fields in action responses
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2459
GitOrigin-RevId: 9269fa6e71770cb31183d917595b704c5dee9713
2021-09-29 09:54:36 +00:00
Solomon Bothwell
4e05bdcaec Feature/request transform string interpolation
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2443
Co-authored-by: Tirumarai Selvan <8663570+tirumaraiselvan@users.noreply.github.com>
GitOrigin-RevId: d7d68984d0ae1403bb414572e9704c01ed27deab
2021-09-29 08:14:29 +00:00
Solomon Bothwell
a7cc5df95d Fixes update_action transform bug and updates Kriti pin
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2399
GitOrigin-RevId: 009ee6ec2a3834951e464c232eb517d636ab940a
2021-09-28 01:38:24 +00:00
Sameer Kolhar
4ca2c7554c server: support user comments for trackable functions
https://github.com/hasura/graphql-engine-mono/pull/2290

GitOrigin-RevId: 3d7cf89b7e1d545475bad44ccc233b6f11145a01
2021-09-24 09:19:40 +00:00
awjchen
f1daabab04 docs, tests: update Explain API docs
https://github.com/hasura/graphql-engine-mono/pull/2352

Co-authored-by: Rikin Kachhia <54616969+rikinsk@users.noreply.github.com>
GitOrigin-RevId: f9f5d1157524afbe418ba0ca3e3e1d6258eaf9e3
2021-09-23 20:00:07 +00:00
Evie Ciobanu
1843ee7b0b [server] fix LIMIT optimization not respecting ORDER BY
https://github.com/hasura/graphql-engine-mono/pull/2239

Co-authored-by: Gil Mizrahi <8547573+soupi@users.noreply.github.com>
Co-authored-by: Rakesh Emmadi <12475069+rakeshkky@users.noreply.github.com>
GitOrigin-RevId: fabc825239950b11d673cfd33e8075a01409bcf6
2021-09-21 10:40:24 +00:00
Antoine Leblanc
21254256a1 Improve error messages of Metadata API.
### Description

This PR improves error messages in our metadata API by displaying a message with the name of the failing command and a link to our documentation. Furthermore, it harmonizes our internal uses of `withObject`, to respect the convention of using the Haskell type name, now that the Aeson error message is displayed as an "internal error message".

https://github.com/hasura/graphql-engine-mono/pull/1905

GitOrigin-RevId: e4064ba3290306437aa7e45faa316c60e51bc6b6
2021-09-20 19:50:22 +00:00
pranshi06
e77b79ae02 [server] Add GraphQL query in the payload for Synchronous Actions
https://github.com/hasura/graphql-engine-mono/pull/2224

GitOrigin-RevId: 9eb1ab612f1a6cc8fe8490272be3d5a997b5b097
2021-09-20 18:20:33 +00:00
Karthikeyan Chinnakonda
ccf97ab6b0 server: improve event trigger logging
https://github.com/hasura/graphql-engine-mono/pull/2286

GitOrigin-RevId: b3232a08dd7ec2aa0c9e7a2fada0e05e34a1897b
2021-09-20 14:32:31 +00:00
Aniket Deshpande
d358d06e68 MSSQL: custom-check based permissions _exists uses wrong table graphql-engine#7429
https://github.com/hasura/graphql-engine-mono/pull/2317

GitOrigin-RevId: 2ea6c69811d06676c6ea7cf5371c28f021037d72
2021-09-20 10:27:14 +00:00
Rakesh Emmadi
9ca0bc1e5c server: remove identity notion from table columns
>

### Description
>
While adding [insert mutation schema parser for MSSQL backend](https://github.com/hasura/graphql-engine-mono/pull/2141) I also included [identity](https://en.wikipedia.org/wiki/Identity_column) notion to table columns across all backends. In MSSQL we cannot insert any value (even `DEFAULT` expression) into Identity columns. This behavior of identity columns is not same in Postgres as we can insert values. This PR drops the notion of identity in the column info. The context of identity columns for MSSQL is carried in `ExtraTableMetadata` type.

### Changelog

- [x] `CHANGELOG.md` is updated with user-facing content relevant to this PR. If no changelog is required, then add the `no-changelog-required` label.

### Affected components

- [x] Server
- [ ] Console
- [ ] CLI
- [ ] Docs
- [ ] Community Content
- [ ] Build System
- [x] Tests
- [ ] Other (list it)

### Related Issues
->
Fix https://github.com/hasura/graphql-engine/issues/7557

https://github.com/hasura/graphql-engine-mono/pull/2378

GitOrigin-RevId: c18b5708e2e6107423a0a95a7fc2e9721e8a21a1
2021-09-17 09:03:06 +00:00
Swann Moreau
8bfcd9a55c server: add "extensions" field to action webhook error schema
https://github.com/hasura/graphql-engine-mono/pull/1698

GitOrigin-RevId: c3b6f1048b6702a53ebe6c49f23dedc0f1d88090
2021-09-17 07:44:37 +00:00
Solomon Bothwell
af5ff07614 Request Transformations
https://github.com/hasura/graphql-engine-mono/pull/1984

Co-authored-by: jkachmar <8461423+jkachmar@users.noreply.github.com>
GitOrigin-RevId: 1767d6bdde48c156fe171b5a9b7e44d7f2eb4869
2021-09-16 11:03:57 +00:00
Antoine Leblanc
e2ce1972f6 Prevent empty subscription roots (fix hasura/graphql-engine#6898)
### Description

We always build a subscription root, even when there was no possible fields. This breaks some third party clients, as the spec does not allow empty types in the schema. This PR fixes this by changing the `buildSubscriptionParser` helper to return a `Maybe` value, and harmonizes / cleans places where we build the subscription root.

https://github.com/hasura/graphql-engine-mono/pull/2357

GitOrigin-RevId: 1aeae25e321eee957e7645c436d17e69207309fd
2021-09-16 07:42:46 +00:00
Antoine Leblanc
9bae641ac4 Always enable inherited roles tests
### Description

The inherited roles integration tests were behind a flag, and its corresponding fixture, presumably to avoid enabling the option globally. However, #2288 introduced a new test using inherited roles that was not gated behind the flag, which fails when run with `dev.sh`. However, that test works on CI... because inherited roles are globally enabled there.

Consequently, this PR:
- globally enables inherited roles in dev.sh
- removes the flag and the associated fixture

https://github.com/hasura/graphql-engine-mono/pull/2358

Co-authored-by: Vishnu Bharathi <4211715+scriptnull@users.noreply.github.com>
GitOrigin-RevId: ebfa6754873324bed15b2cc5e37ec2d8008e8f8d
2021-09-16 06:24:54 +00:00
Abby Sassel
9b7234b861 server/bigquery: add explicit order_by argument to fix non-deterministic test failures
https://github.com/hasura/graphql-engine-mono/pull/2355

GitOrigin-RevId: d2e088e1f1edd3c4bb2912b285fde8feeb3889ed
2021-09-15 15:44:45 +00:00
Antoine Leblanc
a5589c185b Fix nullability of nested objrel inserts (fix hasura/graphql-engine#7484)
### Description

During the PDV refactor that led to 2.0, we broke an undocumented and untested semantic of inserts: accepting _explicit_ null values in nested object inserts.

In short: in the schema, we often distinguish between _explicit_ null values `{id: 3, author: null}` and _implicit_ null values that correspond to the field being omitted `{id: 3}`. In this particular case, we forgot to accept explicit null values. Since the field is optional (meaning we accept implicit null values), it was nullable in the schema, like it was in pre-PDV times. But in practice we would reject explicit nulls.

This PR fixes this, and adds a test. Furthermore, it does a bit of a cleanup of the Mutation part of the schema, and more specifically of all insertion code.

https://github.com/hasura/graphql-engine-mono/pull/2341

GitOrigin-RevId: 895cfeecef7e8e49903a3fb37987707150446eb0
2021-09-15 13:11:48 +00:00
Karthikeyan Chinnakonda
a268a3dc2f server: fix bug which allowed metadata to be inconsistent in the replace_metadata API call
https://github.com/hasura/graphql-engine-mono/pull/2288

GitOrigin-RevId: 93b181c957a5c38748c419a5146f0590605957ce
2021-09-14 12:03:06 +00:00
Antoine Leblanc
e93ddc1b53 Disable test_pg_add_source_with_source_parameters locally.
### Description

Our python test suite has several major problems; one of them being that the tests themselves are not responsible for their own setup. We are therefore using environment variables for all matters of configuration, such as _where the postgres instance is_. This is something that should be changed, but in the meantime, it is the test implementer's responsibility to ensure that tests have a consistent setup in CI and locally, or to to add the proper "skip" annotations.

The recently added `test_pg_add_source_with_source_parameters` fails to do so: as it tests adding a postgres source from hardcoded parameters, rather than relying on environment variables, it only works if the postgres instance is at the matching address, which happens to be the one set in the circle ci config. This is undesirable for two reasons:
- it breaks local tests: running tests locally with `dev.sh` sets postgres up differently, and the test fails;
- a change to the circle config would result in failures in that test.

Sadly, there's no good solution here: our tests do not currently support expanding environment variables in the queries' yaml files, meaning it's not possible to set the values of all those parameters differently in each environment. And we haven't yet started working towards having a unified testing environment setup.

As a result, this PR disables the offending test UNLESS the postgres instance happens to be exactly where the test expects it. This is also very inelegant and adds more tech debt to the pile, but I do not see how to fix this with our current test infrastructure. :(

https://github.com/hasura/graphql-engine-mono/pull/2336

GitOrigin-RevId: 8bc9142075d14acaa48e9c4b20de2527185bc75c
2021-09-14 04:11:09 +00:00
Sameer Kolhar
bafefac73d server: update create_scheduled_event API to respond with event_id
https://github.com/hasura/graphql-engine-mono/pull/2313

GitOrigin-RevId: a72880734074105d55bb387fdb5d1a9f5fac1d72
2021-09-13 18:01:55 +00:00
Sameer Kolhar
f6af579619 server,docs,tests: add support for connection_parameters to pg_add_source API
https://github.com/hasura/graphql-engine-mono/pull/1690

GitOrigin-RevId: a7be66c9af3143b34133d197f7858ba22f442a41
2021-09-06 17:00:12 +00:00
Anon Ray
dc1ac69dac server: add parameterized query hash for websocket logs
https://github.com/hasura/graphql-engine-mono/pull/2061

Co-authored-by: Naveen Naidu <30195193+Naveenaidu@users.noreply.github.com>
GitOrigin-RevId: bf26b804d93b19ef7fc15c71fec80fb6d6632e64
2021-09-06 12:27:48 +00:00
paritosh-08
8c05efb6d9 server: disable mutation for materialised views
The materialized views cannot be mutated, so this commit removes the option to run mutation on the materialized views via graphql endpoint. Before this, users could have tried running mutation for the materialized views using the graphql endpoint (or from HGE console), which would have resulted in the following error:
``` JSON
{
  "errors": [
    {
      "extensions": {
        "internal": {
          "statement": "WITH \"articles_mat_view__mutation_result_alias\" AS (DELETE FROM \"public\".\"articles_mat_view\"  WHERE (('true') AND (((((\"public\".\"articles_mat_view\".\"id\") = (('20155721-961c-4d8b-a5c4-873ed62c7a61')::uuid)) AND ('true')) AND ('true')) AND ('true'))) RETURNING * ), \"articles_mat_view__all_columns_alias\" AS (SELECT  \"id\" , \"author_id\" , \"content\" , \"test_col\" , \"test_col2\"  FROM \"articles_mat_view__mutation_result_alias\"      ) SELECT  json_build_object('affected_rows', (SELECT  COUNT(*)  FROM \"articles_mat_view__all_columns_alias\"      ) )        ",
          "prepared": false,
          "error": {
            "exec_status": "FatalError",
            "hint": null,
            "message": "cannot change materialized view \"articles_mat_view\"",
            "status_code": "42809",
            "description": null
          },
          "arguments": []
        },
        "path": "$",
        "code": "unexpected"
      },
      "message": "database query error"
    }
  ]
}
```
So, we don't want to generate the mutation fields for the materialized views altogether.

https://github.com/hasura/graphql-engine-mono/pull/2226

GitOrigin-RevId: 4ef441764035a8039e1c780d454569ee1f2febc3
2021-09-06 10:10:35 +00:00
Swann Moreau
4887f70caa [server] revert #2078 "server/postgres: optimize SQL query generation with LIMITs"
Fixes https://github.com/hasura/graphql-engine/issues/7453, by reverting #2078 (commit 47eaccdbfb3499efd2c9f733f3312ad31c77916f).

https://hasurahq.slack.com/archives/CKFUG6RCH/p1629900718181700

https://github.com/hasura/graphql-engine-mono/pull/2204

GitOrigin-RevId: 53d5fee9c6008b26bc14213e5a16f6aba6d9c6b1
2021-08-30 11:54:53 +00:00
Abby Sassel
1e7ab8665d server/bigquery: fix data source references & pytest filter in CI
https://github.com/hasura/graphql-engine-mono/pull/2169

GitOrigin-RevId: a0a7190a404ee558a965e06fe1a022953f6f5a10
2021-08-26 18:12:05 +00:00
Auke Booij
fe8eabff19 server: fix the nullability of object relationships (fix hasura/graphql-engine#7201)
When adding object relationships, we set the nullability of the generated GraphQL field based on whether the database backend enforces that the referenced data always exists. For manual relationships (corresponding to `manual_configuration`), the database backend is unaware of any relationship between data, and hence such fields are always set to be nullable.

For relationships generated from foreign key constraints (corresponding to `foreign_key_constraint_on`), we distinguish between two cases:

1. The "forward" object relationship from a referencing table (i.e. which has the foreign key constraint) to a referenced table. This should be set to be non-nullable when all referencing columns are non-nullable. But in fact, it used to set it to be non-nullable if *any* referencing column is non-nullable, which is only correct in Postgres when `MATCH FULL` is set (a flag we don't consider). This fixes that by changing a boolean conjunction to a disjunction.
2. The "reverse" object relationship from a referenced table to a referencing table which has the foreign key constraint. This should always be set to be nullable. But in fact, it used to always be set to non-nullable, as was reported in hasura/graphql-engine#7201. This fixes that.

Moreover, we have moved the computation of the nullability from `Hasura.RQL.DDL.Relationship` to `Hasura.GraphQL.Schema.Select`: this nullability used to be passed through the `riIsNullable` field of `RelInfo`, but for array relationships this information is not actually used, and moreover the remaining fields of `RelInfo` are already enough to deduce the nullability.

This also adds regression tests for both (1) and (2) above.

https://github.com/hasura/graphql-engine-mono/pull/2159

GitOrigin-RevId: 617f12765614f49746d18d3368f41dfae2f3e6ca
2021-08-26 15:27:34 +00:00
Auke Booij
88aa42a986 server: Add regression tests for hasura/graphql-engine#7172
In hasura/graphql-engine#7172, an issue was found where under certain conditions a JSON field from Postgres would be parsed as a GraphQL input object, which is not possible in general, and also unnecessary. Luckily, this was already fixed by the time `v2.0.6` got around, presumably thanks to 4a83bb1834. This adds a regression test.

https://github.com/hasura/graphql-engine-mono/pull/2158

GitOrigin-RevId: 1ded1456f6b89726e08f77cf3383ad88c04de451
2021-08-25 21:06:09 +00:00
Sameer Kolhar
edeb8c98fd server: support for graphql-ws protocol
https://github.com/hasura/graphql-engine-mono/pull/1655

Co-authored-by: Rakesh Emmadi <12475069+rakeshkky@users.noreply.github.com>
Co-authored-by: Vijay Prasanna <11921040+vijayprasanna13@users.noreply.github.com>
Co-authored-by: hasura-bot <30118761+hasura-bot@users.noreply.github.com>
Co-authored-by: Brandon Simmons <210815+jberryman@users.noreply.github.com>
Co-authored-by: Varun Choudhary <68095256+Varun-Choudhary@users.noreply.github.com>
Co-authored-by: Divi <32202683+imperfect-fourth@users.noreply.github.com>
GitOrigin-RevId: 9db3902388fef06b94f9513255e2b5333bd23c3e
2021-08-24 16:26:12 +00:00
Auke Booij
3fb7d9bc3d server: remove unused bahnql test
This removes the file `bahnql_query.yaml`, which is no longer being used.

a509a86eaa (hasura/graphql-engine#1117) changed the way we test the remote schema feature from using external GraphQL services to running our own mini GraphQL server for testing purposes. This gives us a lot of in-codebase flexibility on the behavior of "remote" GraphQL servers.

During this work, the `bahnql_query.yaml` test was swapped out for the `simple2_query.yaml` test. The former essentially tests if a field from a remote schema can be fetched, whereas the latter tests whether an entry can be fetched from the (non-remote!) database.

It's not clear to me why `bahnql_query.yaml` was no longer used. In any case, the relevant setup code was removed, and this test can no longer be run. Presumably we test such basic functionality already in many other ways.

https://github.com/hasura/graphql-engine-mono/pull/2102

GitOrigin-RevId: c01b7f7ec5c767c874bca2ddad991eb81a0e2809
2021-08-19 18:35:56 +00:00
David Overton
20f7a6e726 server: fix untrack_function for non-default source
https://github.com/hasura/graphql-engine-mono/pull/2152

GitOrigin-RevId: 339b365044443cec6a83e1a6b3ec06677dc51e1d
2021-08-19 10:28:49 +00:00
Aniket Deshpande
2700554412 bq: test table customization features
https://github.com/hasura/graphql-engine-mono/pull/2062

Co-authored-by: Rikin Kachhia <54616969+rikinsk@users.noreply.github.com>
GitOrigin-RevId: 5573efd1b28e088d5730c7d22e16889dc852b5fe
2021-08-18 13:00:58 +00:00
Rakesh Emmadi
fa152d842d server/postgres: optimize SQL query generation with LIMITs
>

### Description
>
This PR supersedes https://github.com/hasura/graphql-engine-mono/pull/1484. Apply `limit` to the table selection before joining relationship rows to improve query performance.

### Changelog

- [x] `CHANGELOG.md` is updated with user-facing content relevant to this PR. If no changelog is required, then add the `no-changelog-required` label.

### Affected components

- [x] Server

### Related Issues
->
Fix https://github.com/hasura/graphql-engine/issues/5745

### Solution and Design
>
Prior to this change, we apply `LIMIT` and `OFFSET` to the outer selection from sub-query which includes joins for relationships. Now, we move `LIMIT` and `OFFSET` (if present) to inner selection of base table. But, this isn't done always! If there are order by relationships' columns we apply at the outer selection. To know more, please refer to [source code note](https://github.com/hasura/graphql-engine-mono/pull/2078/files#diff-46d868ee45d3eaac667cebb34731f573c77d5c9c8097bb9ccf1115fc07f65bfdR652).

```graphql
query {
  article(limit: 2){
    id
    title
    content
    author{
      name
    }
  }
}
```
Before:
```sql
SELECT
  coalesce(json_agg("root"), '[]') AS "root"
FROM
  (
    SELECT
      row_to_json(
        (
          SELECT
            "_4_e"
          FROM
            (
              SELECT
                "_0_root.base"."id" AS "id",
                "_0_root.base"."title" AS "title",
                "_0_root.base"."content" AS "content",
                "_3_root.or.author"."author" AS "author"
            ) AS "_4_e"
        )
      ) AS "root"
    FROM
      (
        SELECT
          *
        FROM
          "public"."article"
        WHERE
          ('true')
      ) AS "_0_root.base"
      LEFT OUTER JOIN LATERAL (
        SELECT
          row_to_json(
            (
              SELECT
                "_2_e"
              FROM
                (
                  SELECT
                    "_1_root.or.author.base"."name" AS "name"
                ) AS "_2_e"
            )
          ) AS "author"
        FROM
          (
            SELECT
              *
            FROM
              "public"."author"
            WHERE
              (("_0_root.base"."author_id") = ("id"))
          ) AS "_1_root.or.author.base"
      ) AS "_3_root.or.author" ON ('true')
    LIMIT
      2
  ) AS "_5_root"
```
cost
```
Aggregate  (cost=0.73..0.74 rows=1 width=32)
  ->  Limit  (cost=0.15..0.71 rows=2 width=32)
        ->  Nested Loop Left Join  (cost=0.15..223.96 rows=810 width=32)
              ->  Seq Scan on article  (cost=0.00..18.10 rows=810 width=72)
              ->  Index Scan using author_pkey on author  (cost=0.15..0.24 rows=1 width=36)
                    Index Cond: (article.author_id = id)
                    SubPlan 1
                      ->  Result  (cost=0.00..0.01 rows=1 width=32)
              SubPlan 2
                ->  Result  (cost=0.00..0.01 rows=1 width=32)
```

After:
```sql
SELECT
  coalesce(json_agg("root"), '[]') AS "root"
FROM
  (
    SELECT
      row_to_json(
        (
          SELECT
            "_4_e"
          FROM
            (
              SELECT
                "_0_root.base"."id" AS "id",
                "_0_root.base"."title" AS "title",
                "_0_root.base"."content" AS "content",
                "_3_root.or.author"."author" AS "author"
            ) AS "_4_e"
        )
      ) AS "root"
    FROM
      (
        SELECT
          *
        FROM
          "public"."article"
        WHERE
          ('true')
        LIMIT
          2
      ) AS "_0_root.base"
      LEFT OUTER JOIN LATERAL (
        SELECT
          row_to_json(
            (
              SELECT
                "_2_e"
              FROM
                (
                  SELECT
                    "_1_root.or.author.base"."name" AS "name"
                ) AS "_2_e"
            )
          ) AS "author"
        FROM
          (
            SELECT
              *
            FROM
              "public"."author"
            WHERE
              (("_0_root.base"."author_id") = ("id"))
          ) AS "_1_root.or.author.base"
      ) AS "_3_root.or.author" ON ('true')
  ) AS "_5_root"
```
cost:
```
Aggregate  (cost=16.47..16.48 rows=1 width=32)
  ->  Nested Loop Left Join  (cost=0.15..16.44 rows=2 width=100)
        ->  Limit  (cost=0.00..0.04 rows=2 width=72)
              ->  Seq Scan on article  (cost=0.00..18.10 rows=810 width=72)
        ->  Index Scan using author_pkey on author  (cost=0.15..8.18 rows=1 width=36)
              Index Cond: (article.author_id = id)
              SubPlan 1
                ->  Result  (cost=0.00..0.01 rows=1 width=32)
  SubPlan 2
    ->  Result  (cost=0.00..0.01 rows=1 width=32)
```

https://github.com/hasura/graphql-engine-mono/pull/2078

Co-authored-by: Evie Ciobanu <1017953+eviefp@users.noreply.github.com>
GitOrigin-RevId: 47eaccdbfb3499efd2c9f733f3312ad31c77916f
2021-08-17 17:03:08 +00:00
Sameer Kolhar
1243da1d54 server: fix regressions on invoking manual trigger
https://github.com/hasura/graphql-engine-mono/pull/2029

GitOrigin-RevId: d1a445cca8106835735c5e10cab045ea6a2e1635
2021-08-17 10:22:50 +00:00
Abby Sassel
6b3db83737 server/bigquery: run tests in CI
server/bigquery: run tests in CI #1525

[Example of successful BigQuery test job](https://app.circleci.com/pipelines/github/hasura/graphql-engine-mono/15951/workflows/86deb614-ddbc-4df5-9af3-288eeff6504a/jobs/283568)

TODO:
- [ ] I'll make corresponding changes in the OSS repo once this is merged
- [ ] @scriptnull or anyone with permissions: to require in CI

https://github.com/hasura/graphql-engine-mono/pull/1741

GitOrigin-RevId: d4ba446e9b13d213de135c73bb72973478575a29
2021-08-12 16:48:29 +00:00