Commit Graph

744 Commits

Author SHA1 Message Date
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
Rakesh Emmadi
c2f667a06d server: correctly generate remote relationship field type
>

### Description
>
From HGE version 2.0 onwards, all remote relationship fields are generated as plain types without non-nullable and lists. This PR fixes the same.

### 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
->
fix https://github.com/hasura/graphql-engine/issues/7284

### Steps to test and verify
>
- Create a remote relationship to a field in remote schema with non-nullable or list type
- The HGE introspection should give the remote relationship field type correctly as like in the remote schema

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

GitOrigin-RevId: e113f5d17b62bfa0a25028c20260ae1782ae224b
2021-08-12 12:17:52 +00:00
pranshi06
d179a6f2ec server: support EdDSA keys for JWT
https://github.com/hasura/graphql-engine-mono/pull/1818

Co-authored-by: paritosh-08 <85472423+paritosh-08@users.noreply.github.com>
Co-authored-by: Puru Gupta <32328846+purugupta99@users.noreply.github.com>
Co-authored-by: Rikin Kachhia <54616969+rikinsk@users.noreply.github.com>
GitOrigin-RevId: aae87d34cd19c97e66721a2bd7602d907aeb90b3
2021-08-12 01:54:06 +00:00
Evie Ciobanu
11b3e1573d [server] generate the correct type for single-row returning functions
https://github.com/hasura/graphql-engine-mono/pull/2055

GitOrigin-RevId: 94c1cc32028054c7ec11d6ada2fc57f0820a4d5e
2021-08-11 12:42:30 +00:00
Karthikeyan Chinnakonda
06f5e4fb77 server: inherited roles for mutations, remote schemas, actions and custom functions
https://github.com/hasura/graphql-engine-mono/pull/1715

GitOrigin-RevId: 4818292cff8c3a5b264968e7032887a1e98b6f79
2021-08-09 10:21:05 +00:00
Aniket Deshpande
a9fb2710db server/bigquery: implement _in and _nin operators. (close #7343)
https://github.com/hasura/graphql-engine-mono/pull/2033

GitOrigin-RevId: 58d4de268b62c6d7cb6106bec38214e651926816
2021-08-06 19:58:33 +00:00
jkachmar
4a83bb1834 Remote schema execution logic
https://github.com/hasura/graphql-engine-mono/pull/1995

Co-authored-by: David Overton <7734777+dmoverton@users.noreply.github.com>
GitOrigin-RevId: 178669089ec5e63b1f3da1d3ba0a9f8debbc108d
2021-08-06 13:40:37 +00:00
David Overton
1000df2e0a Fix/remote nested field customization
https://github.com/hasura/graphql-engine-mono/pull/2009

GitOrigin-RevId: bec59d2173afd6f392997f6bd953775f4a42dd48
2021-08-05 14:59:55 +00:00
Sibi Prabakaran
c93996d06c Mysql: Simple graphql queries along with offset/limits
https://github.com/hasura/graphql-engine-mono/pull/1851

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: 4b4ba6dd86c302d873bb5f8e6dbc9412e77a8bfe
2021-08-04 11:43:19 +00:00
Karthikeyan Chinnakonda
0a3fd16c35 server: revert the relaxing of unique name constraint in allow-lists
https://github.com/hasura/graphql-engine-mono/pull/1972

GitOrigin-RevId: cb062df7a1ba1c99705f811409e2e4ad42f4b581
2021-08-03 09:23:20 +00:00
David Overton
3e1e0773fe Test customization with update_remote_schema
https://github.com/hasura/graphql-engine-mono/pull/1971

GitOrigin-RevId: 617f15193e1149d08327d3a7eb0b21e11e280561
2021-08-02 05:50:49 +00:00
Evie Ciobanu
e48ccd7fab server: Check session variables for subscriptions
https://github.com/hasura/graphql-engine-mono/pull/1879

GitOrigin-RevId: 78d3384cb21a36e8b8c85c17ae7578ce0b4230f8
2021-07-30 21:42:52 +00:00
David Overton
1abb1dee69 Remote Schema Customization take 2 using parser tranformations
https://github.com/hasura/graphql-engine-mono/pull/1740

GitOrigin-RevId: e807952058243a97f67cd9969fa434933a08652f
2021-07-30 11:33:59 +00:00
Aniket Deshpande
61663ec901 MSSQL: __typename error and json based aggregates (graphql-engine#7130)
https://github.com/hasura/graphql-engine-mono/pull/1930

GitOrigin-RevId: f14df470ffa298c18e006c522d6355298041ae8e
2021-07-30 09:03:57 +00:00
Rakesh Emmadi
a63fa18d9c server/postgres: Support computed fields in permission check/filter
https://github.com/hasura/graphql-engine-mono/pull/1697

GitOrigin-RevId: 6cdf8acc90d3fd97d20a3ee68c84306c3f589370
2021-07-28 08:10:25 +00:00
Rakesh Emmadi
5cfac6ea87 server/postgres: support computed fields in order by
https://github.com/hasura/graphql-engine-mono/pull/1793

GitOrigin-RevId: e0396c0d4d96fc8f9bdbd7567193933db5b295a6
2021-07-27 16:28:23 +00:00
Sameer Kolhar
454e6afd1d server: fix pg_invoke_event_trigger regression
https://github.com/hasura/graphql-engine-mono/pull/1785

GitOrigin-RevId: 0addb457c3790f886b4d708ffc08588aebfc6aca
2021-07-27 08:06:25 +00:00
Abby Sassel
1cd9fc376d server/mysql: integrate MySQL tests into dev.sh workflow
https://github.com/hasura/graphql-engine-mono/pull/1848

GitOrigin-RevId: 2bd7c0a18448f042a1e35d21aaf42232acf48a46
2021-07-21 17:22:56 +00:00
Karthikeyan Chinnakonda
892e56ca6e server: fix failing citus test
https://github.com/hasura/graphql-engine-mono/pull/1862

Co-authored-by: David Overton <7734777+dmoverton@users.noreply.github.com>
GitOrigin-RevId: 05e1912d49a40eaffcfc249ff2d7fb7ac70b8f6f
2021-07-21 15:28:32 +00:00
Karthikeyan Chinnakonda
34ccca305d server: relax unique operation name constraint in a query collection
https://github.com/hasura/graphql-engine-mono/pull/1849

GitOrigin-RevId: 56c1737b69511c3f2c4480d22f84828f51d3b543
2021-07-21 12:05:50 +00:00
Sibi Prabakaran
0e6e9deac9 mysql: runSql implementation and python tests leveraging it to enhance the metadata test
https://github.com/hasura/graphql-engine-mono/pull/1606

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: 2ed37c48c5d1e82e23d691f30a6e870303787388
2021-07-21 10:22:54 +00:00
Antoine Leblanc
83045a4459 server: fix erroneous Eq instance on Metadata Object
During the "generalization" of the code, we removed the [generated instances](9d63187803 (diff-7b8382ab20e441fa214586be491eb6f7ca904d8b20ed97894c16a339be45219aL72)) of `Eq` and `Hashable` in favour of manually written ones, because for a time we were struggling with `AnyBackend`.

In the process, we lost one constructor, `MOEndpoint`. It's unlikely to have ever been an issue, since duplicate endpoints are unlikely, but it is nonetheless wrong.

This PR simply goes back to default derived instances, now that we can, fixing the problem and making the code simpler.

---

However, after filing this PR, I realized **it broke rest endpoint tests**. Upon closer inspection, it turns out that while we had proper checks in place, because of this bug we were actually failing _differently_ during metadata checks. This PR actually improves error messages for invalid endpoint configurations?! 🙀

This is a tiny bit scary. ^^'

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

GitOrigin-RevId: c4897d1f3ae92d18c44c87d2f58258c66f716686
2021-07-20 14:24:45 +00:00
Karthikeyan Chinnakonda
6bddaa7564 server: inherited roles improvements for select permissions only
https://github.com/hasura/graphql-engine-mono/pull/1539

GitOrigin-RevId: 7444973e9cc7e0598eeb1bd7951ad45dd37ec550
2021-07-16 21:19:58 +00:00
Solomon Bothwell
d88e2bbcce server: add tests ensuring the correct functioning of all endpoints based on user roles
https://github.com/hasura/graphql-engine-mono/pull/1625

Co-authored-by: Sameer Kolhar <6604943+kolharsam@users.noreply.github.com>
GitOrigin-RevId: 6b56efc838d2ed1acc44b2847161fde22d6aee17
2021-07-16 16:09:25 +00:00
Sibi Prabakaran
385d27449e mysql: Metadata awareness
https://github.com/hasura/graphql-engine-mono/pull/1599

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: 4df4a8ff00fa8ef311a85199d66abe4cc10adc8c
2021-07-15 12:45:51 +00:00
Abby Sassel
745ff91dcd server/docs: Add reference in test to its related issue
I got sad that I didn't write a line of code (or...comments) today, so here we are 😅 also [I said I would](https://github.com/hasura/graphql-engine/issues/7181#issuecomment-877143240).

FYI @aniketd this is our convention for linking bug fixes to issues

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

GitOrigin-RevId: 11ee6cc52903c074dc3b6fa8b8c3636cca94174d
2021-07-12 18:59:50 +00:00
Rakesh Emmadi
a375f8c105 server/postgres: Support scalar computed fields in remote joins
https://github.com/hasura/graphql-engine-mono/pull/1692

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
GitOrigin-RevId: fcef85910899859f7421cad554c022f8023965ea
2021-07-12 16:04:37 +00:00
Aniket Deshpande
66f09eeaab MSSQL nodes aggregates & inherited roles
https://github.com/hasura/graphql-engine-mono/pull/1293

Co-authored-by: Chris Done <11019+chrisdone@users.noreply.github.com>
Co-authored-by: Abby Sassel <3883855+sassela@users.noreply.github.com>
GitOrigin-RevId: 776402dbbaf3d8166a62b1aaaf6abc7e584b3eb2
2021-07-08 20:50:09 +00:00
Philip Lykke Carlsen
7784c72d70 Pytest: Pretty-print JSON payloads in failing assertions
I finally got fed up trying to decipher the messages from failing assertions in integration tests and was thus spurred into action :-)

Instead of using the `repr(..)` format for the `OrderedDict`s of query responses we now deliberately format them as JSON with indentation.

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

GitOrigin-RevId: 1ca0d03ff52950095b89b447d9625d6481bc7177
2021-07-08 19:29:40 +00:00
Rakesh Emmadi
e567a096e6 server/postgres: support computed fields in query filters ('where' expression)
https://github.com/hasura/graphql-engine-mono/pull/1677

GitOrigin-RevId: 30175a442237f6ac4b112c652f448a635ad90dc6
2021-07-07 11:59:32 +00:00
Robert
ae6d624441 server: improve handling of HTTP client errors for remote schema calls
https://github.com/hasura/graphql-engine-mono/pull/1719

GitOrigin-RevId: 5ff671bcff5f0559b9821f8359ebee4129f4b664
2021-07-07 10:15:05 +00:00
Abby Sassel
76c322589c server/bigquery: Document BigQuery integration tests
This PR documents & streamlines how we run BigQuery integration tests locally as a first step to [running them in CI](https://github.com/hasura/graphql-engine-mono/issues/1525).

I've also created a hasura service account for internal use. [Internal docs here](https://github.com/hasura/graphql-engine-mono/wiki/Testing-BigQuery).

Thanks to FP Complete team for [the guidance here](https://docs.google.com/document/d/1dGDK0touUtsDxRQPonMxSoPbIfzBoSYo02tAjQEO7qA/edit?ts=60c0cf24#), which I've reused parts of.

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

GitOrigin-RevId: 303819d212aa073fbef685d077b1cfa583cd15fc
2021-07-06 11:13:06 +00:00
Chris Done
614c0dab80 Bigquery/fix limit offset for array aggregates
Blocked on https://github.com/hasura/graphql-engine-mono/pull/1640.

While fiddling with BigQuery I noticed a severe issue with offset/limit for array-aggregates. I've fixed it now.

The basic problem was that I was using a query like this:

```graphql
query MyQuery {
  hasura_Artist(order_by: {artist_self_id: asc}) {
    artist_self_id
    albums_aggregate(order_by: {album_self_id: asc}, limit: 2) {
      nodes {
        album_self_id
      }
      aggregate {
        count
      }
    }
  }
}
```

Producing this SQL:

```sql
SELECT `t_Artist1`.`artist_self_id` AS `artist_self_id`,
       STRUCT(IFNULL(`aa_albums1`.`nodes`, NULL) AS `nodes`, IFNULL(`aa_albums1`.`aggregate`, STRUCT(0 AS `count`)) AS `aggregate`) AS `albums_aggregate`
FROM `hasura`.`Artist` AS `t_Artist1`
LEFT OUTER JOIN (SELECT ARRAY_AGG(STRUCT(`t_Album1`.`album_self_id` AS `album_self_id`) ORDER BY (`t_Album1`.`album_self_id`) ASC) AS `nodes`,
                        STRUCT(COUNT(*) AS `count`) AS `aggregate`,
                        `t_Album1`.`artist_other_id` AS `artist_other_id`
                 FROM (SELECT *
                       FROM `hasura`.`Album` AS `t_Album1`
                       ORDER BY (`t_Album1`.`album_self_id`) ASC NULLS FIRST
                       -- PROBLEM HERE
                       LIMIT @param0) AS `t_Album1`
                 GROUP BY `t_Album1`.`artist_other_id`)
AS `aa_albums1`
ON (`aa_albums1`.`artist_other_id` = `t_Artist1`.`artist_self_id`)
ORDER BY (`t_Artist1`.`artist_self_id`) ASC NULLS FIRST
```

Note the `LIMIT @param0` -- that is incorrect because we want to limit
per artist. Instead, we want:

```sql
SELECT `t_Artist1`.`artist_self_id` AS `artist_self_id`,
       STRUCT(IFNULL(`aa_albums1`.`nodes`, NULL) AS `nodes`, IFNULL(`aa_albums1`.`aggregate`, STRUCT(0 AS `count`)) AS `aggregate`) AS `albums_aggregate`
FROM `hasura`.`Artist` AS `t_Artist1`
LEFT OUTER JOIN (SELECT ARRAY_AGG(STRUCT(`t_Album1`.`album_self_id` AS `album_self_id`) ORDER BY (`t_Album1`.`album_self_id`) ASC) AS `nodes`,
                        STRUCT(COUNT(*) AS `count`) AS `aggregate`,
                        `t_Album1`.`artist_other_id` AS `artist_other_id`
                 FROM (SELECT *,
                            -- ADDED
                            ROW_NUMBER() OVER(PARTITION BY artist_other_id) artist_album_index
                       FROM `hasura`.`Album` AS `t_Album1`
                       ORDER BY (`t_Album1`.`album_self_id`) ASC NULLS FIRST
                       ) AS `t_Album1`
                 -- CHANGED
                 WHERE artist_album_index <= @param
                 GROUP BY `t_Album1`.`artist_other_id`)
AS `aa_albums1`
ON (`aa_albums1`.`artist_other_id` = `t_Artist1`.`artist_self_id`)
ORDER BY (`t_Artist1`.`artist_self_id`) ASC NULLS FIRST
```

That serves both the LIMIT/OFFSET function in the where clause. Then,
both the ARRAY_AGG and the COUNT are correct per artist.

I've updated my Haskell test suite to add regression tests for this. I'll push a commit for Python tests shortly. The tests still pass there.

This just fixes a case that we hadn't noticed.

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

GitOrigin-RevId: 49933fa5e09a9306c89565743ecccf2cb54eaa80
2021-07-06 08:29:39 +00:00
Anon Ray
f263af31a0 server: add query field to http-log and websocket-log
https://github.com/hasura/graphql-engine-mono/pull/1683

GitOrigin-RevId: 6f46e31bb14f135d528b20ae9513e393c06c3c8a
2021-07-02 13:05:57 +00:00
Karthikeyan Chinnakonda
43973f80cf server tests: refactor the per_class_tests_db_state fixture
https://github.com/hasura/graphql-engine-mono/pull/1701

GitOrigin-RevId: 278b9e226cc7719f4c44bf9c9a802146a8a004f4
2021-07-01 09:21:45 +00:00
Chris Done
6dc555f9eb Bigquery/global limit
This resolves https://github.com/hasura/graphql-engine/issues/6947.

A new [`global_select_limit`](b0ab5deefe/server/tests-py/queries/graphql_query/bigquery/replace_metadata.yaml (L17)) field is supported in the BigQuery configuration.

To test global limits, we have two sources defined,  the normal one (limited to 1million) and one with a limit of 1.

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

GitOrigin-RevId: 6ebcc7c1a16bc26ec36e53ae3694d36b7ce5c6e1
2021-06-25 13:36:35 +00:00
Rakesh Emmadi
13bedf5821 server/postgres: fix resetting the metadata catalog version to 43 while initializing postgres source with 1.0 catalog (#1645)
* fix resetting the catalog version to 43 on migration from 1.0 to 2.0

* ci: remove applying patch in test_oss_server_upgrade job

* make the 43 to 46th migrations idempotent

* Set missing HASURA_GRAPHQL_EVENTS_HTTP_POOL_SIZE=8 in upgrade_test

It's not clear why this wasn't caught in CI.

* ci: disable one component of event backpressure test

Co-authored-by: Vishnu Bharathi P <vishnubharathi04@gmail.com>
Co-authored-by: Karthikeyan Chinnakonda <karthikeyan@hasura.io>
Co-authored-by: Brandon Simmons <brandon@hasura.io>
GitOrigin-RevId: c74c6425266a99165c6beecc3e4f7c34e6884d4d
2021-06-23 18:01:09 +00:00
Solomon Bothwell
6c48babc95 Adds integration test for caching remote schema queries
https://github.com/hasura/graphql-engine-mono/pull/1613

GitOrigin-RevId: 54eb9dec54ed00079f10d057d41bb29e73d9f68e
2021-06-22 21:11:02 +00:00
Sameer Kolhar
608e4fbb20 server, console, docs: add update_remote_schema API
https://github.com/hasura/graphql-engine-mono/pull/1546

GitOrigin-RevId: 142b0d0e0ffc35b2679c91c411868c45a8b8e221
2021-06-21 17:42:40 +00:00
Philip Lykke Carlsen
73e5c6ce47 Generalize set_table_customization to other backends (close #1501)
https://github.com/hasura/graphql-engine-mono/pull/1591

GitOrigin-RevId: 42332798160a3a3b18404345390b235db1dd81a1
2021-06-17 13:22:54 +00:00
Chris Done
67a9045328 Bigquery/cleanups
A pull request for cleaning up small issues, bugs, redundancies and missing things in the BigQuery backend.

Summary:

1. Remove duplicate projection fields - BigQuery rejects these.
2. Add order_by to the test suite cases, as it was returning inconsistent results.
3. Add lots of in FromIr about how the dataloader approach is given support.
4. Produce the correct output structure for aggregates:
   a. Should be a singleton object for a top-level aggregate query.
   b. Should have appropriate aggregate{} and nodes{} labels.
   c. **Support for nodes** (via array_agg).
5. Smooth over support of array aggregates by removing the fields used for joining with an explicit projection of each wanted field.

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

Co-authored-by: Vamshi Surabhi <6562944+0x777@users.noreply.github.com>
GitOrigin-RevId: cd3899f4667770a27055f94988ef2a6d5808f1f5
2021-06-15 08:59:11 +00:00
Vamshi Surabhi
e8e4f30dd6 server: support remote relationships on SQL Server and BigQuery (#1497)
Remote relationships are now supported on SQL Server and BigQuery. The major change though is the re-architecture of remote join execution logic. Prior to this PR, each backend is responsible for processing the remote relationships that are part of their AST.

This is not ideal as there is nothing specific about a remote join's execution that ties it to a backend. The only backend specific part is whether or not the specification of the remote relationship is valid (i.e, we'll need to validate whether the scalars are compatible).

The approach now changes to this:

1. Before delegating the AST to the backend, we traverse the AST, collect all the remote joins while modifying the AST to add necessary join fields where needed.

1. Once the remote joins are collected from the AST, the database call is made to fetch the response. The necessary data for the remote join(s) is collected from the database's response and one or more remote schema calls are constructed as necessary.

1. The remote schema calls are then executed and the data from the database and from the remote schemas is joined to produce the final response.

### Known issues

1. Ideally the traversal of the IR to collect remote joins should return an AST which does not include remote join fields. This operation can be type safe but isn't taken up as part of the PR.

1. There is a lot of code duplication between `Transport/HTTP.hs` and `Transport/Websocket.hs` which needs to be fixed ASAP. This too hasn't been taken up by this PR.

1. The type which represents the execution plan is only modified to handle our current remote joins and as such it will have to be changed to accommodate general remote joins.

1. Use of lenses would have reduced the boilerplate code to collect remote joins from the base AST.

1. The current remote join logic assumes that the join columns of a remote relationship appear with their names in the database response. This however is incorrect as they could be aliased. This can be taken up by anyone, I've left a comment in the code.

### Notes to the reviewers

I think it is best reviewed commit by commit.

1. The first one is very straight forward.

1. The second one refactors the remote join execution logic but other than moving things around, it doesn't change the user facing functionality.  This moves Postgres specific parts to `Backends/Postgres` module from `Execute`. Some IR related code to `Hasura.RQL.IR` module.  Simplifies various type class function signatures as a backend doesn't have to handle remote joins anymore

1. The third one fixes partial case matches that for some weird reason weren't shown as warnings before this refactor

1. The fourth one generalizes the validation logic of remote relationships and implements `scalarTypeGraphQLName` function on SQL Server and BigQuery which is used by the validation logic. This enables remote relationships on BigQuery and SQL Server.

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

GitOrigin-RevId: 77dd8eed326602b16e9a8496f52f46d22b795598
2021-06-11 03:27:39 +00:00
Antoine Leblanc
2d8ac777b3 server: introduce new custom scalars and remove offsetParser
GitOrigin-RevId: 5db058a7ae8f57bdc7e9844fcdd94e31ce11d961
2021-06-10 16:14:21 +00:00
Vamshi Surabhi
96104ec1a8 Revert "remote schema typename customisation"
This reverts the remote schema type customisation and namespacing feature temporarily as we test for certain conditions.

GitOrigin-RevId: f8ee97233da4597f703970c3998664c03582d8e7
2021-06-10 09:57:16 +00:00
David Overton
4a69fdeb01 Dmoverton/5863 prefix namespacing
GitOrigin-RevId: 108e8b25e745cb4f74d143d316262049cef62b70
2021-06-09 22:42:05 +00:00
Sameer Kolhar
b83ba51fa3 server: add logs for version and healthz endpoints
GitOrigin-RevId: 9fdd953173643f88a64f44efc345a3a7da061ec1
2021-06-08 14:28:52 +00:00
Philip Lykke Carlsen
fc17132930 Revert splitting-out of variables in MSSQL
GitOrigin-RevId: 720c0e0c775c9418aea569d3f87875236fdcebfe
2021-06-01 10:05:26 +00:00
Rakesh Emmadi
e43d0273e0 server: mssql: apply schema changes by mssql_run_sql DDL on metadata (fix #779)
Co-authored-by: Antoine Leblanc <1618949+nicuveo@users.noreply.github.com>
GitOrigin-RevId: 6905d5914c8a698445c0ef03d6a8303747701e1c
2021-05-27 15:07:10 +00:00
Antoine Leblanc
00ca310d21 server: do not do a "successful" noop when tracking a function in the wrong source
GitOrigin-RevId: 9eb78899acd0c60081b2a999a75c11b32f394ba7
2021-05-27 12:09:19 +00:00
Karthikeyan Chinnakonda
72c24eea69 server: fix cron trigger bug of new events not getting generated when cron trigger is imported via metadata
Co-authored-by: Rakesh Emmadi <12475069+rakeshkky@users.noreply.github.com>
GitOrigin-RevId: 1a9076e039ba2c8da898683c64ef988fb8512eae
2021-05-26 16:20:19 +00:00
Abby Sassel
06bfe650f0 server/mssql: subscription test cleanup post-fix
GitOrigin-RevId: b67e577b15be3c54f869bb3497b30fb0bb53ddf0
2021-05-26 09:06:57 +00:00
Antoine Leblanc
1674325eb2 server/mssql: fix order of clause in reselect query generation
GitOrigin-RevId: fb7a258059b767a275a5b337e1549f6b3be45499
2021-05-25 14:58:51 +00:00
Abby Sassel
41908936cf server: improve backend-specific test setup
GitOrigin-RevId: c40393bcdd78feaba7e9490ce4ed78de19b5bfc5
2021-05-25 13:55:11 +00:00
Vladimir Ciobanu
5ad01a4bac server: Add test file to suite
GitOrigin-RevId: 6522f776c9b267d5c94be484d55f879e79d30c96
2021-05-25 11:37:14 +00:00
Antoine Leblanc
6e95f761f5 server: rewrite remote input parsers to deal with partial variable expansion (fix hasura/graphql-engine#6656)
GitOrigin-RevId: e0b197a0fd1e259d43e6152b726b350c4d527a4b
2021-05-24 20:13:47 +00:00
Vladimir Ciobanu
0f8f4764c7 server: rename source
GitOrigin-RevId: 5f4a17941bfd447deb9663a4c250f149238c5f53
2021-05-24 13:15:02 +00:00
Abby Sassel
c9e7e10eaa server/bugfix: Include permission filter in the exists clause. Fixes #6931
GitOrigin-RevId: d3080dfa00c96afcf1254d83757a5e50a0726381
2021-05-24 09:09:50 +00:00
Anon Ray
63594e1828 server: fix referenced session vars for live queries when UDF has specified session argument
GitOrigin-RevId: 23efdf4d3b3902b5ce7ec14061faa53b18258e86
2021-05-24 07:34:33 +00:00
Chris Done
feb08d8998 Various MSSQL bugfixes/cleanups
GitOrigin-RevId: 673df70de7b7f9130482b7a28f860bbaffad44a4
2021-05-21 12:28:52 +00:00
Philip Lykke Carlsen
8cc358b023 Plc/feature/mssql logging variables
GitOrigin-RevId: b67a09cbc5bb8b21857c25a0827800ca1826fa1c
2021-05-21 11:38:23 +00:00
Abby Sassel
1afa4ac3cc server/citus: feature branch
Co-authored-by: Vladimir Ciobanu <1017953+vladciobanu@users.noreply.github.com>
Co-authored-by: Antoine Leblanc <1618949+nicuveo@users.noreply.github.com>
Co-authored-by: Ikechukwu Eze <22247592+iykekings@users.noreply.github.com>
Co-authored-by: Philip Lykke Carlsen <358550+plcplc@users.noreply.github.com>
Co-authored-by: Phil Freeman <630306+paf31@users.noreply.github.com>
GitOrigin-RevId: 1b964fe5f5f50380172cb702b6a328fed782b6b7
2021-05-21 02:47:51 +00:00
Naveen Naidu
44f6f06e89 server: Add tests for the event trigger big int and geojson format payload bug fix
GitOrigin-RevId: 1e796b16dca54849334381e855b17b19609c8b7a
2021-05-20 12:27:35 +00:00
Antoine Leblanc
5238bb8011 server: support for custom directives
Co-authored-by: Aravind K P <8335904+scriptonist@users.noreply.github.com>
GitOrigin-RevId: f11b3b2e964af4860c3bb0fd9efec6be54c2e88b
2021-05-20 10:03:50 +00:00
Karthikeyan Chinnakonda
9a99923fef server: support adding a tracked function as a computed field and vice versa
GitOrigin-RevId: 2f4db0b716d493ce245d9fa7e37e11382f18cd67
2021-05-20 06:29:24 +00:00
Antoine Leblanc
03c70c7b7d tests: skip test_pg_multisource_table_name_conflict if the setup isn't correct
GitOrigin-RevId: 4e658812eaac6534e6b6606f03e893449ad4b975
2021-05-19 21:06:54 +00:00
Antoine Leblanc
dfbdfca144 server: fix order of fields in introspection output
GitOrigin-RevId: edd6af755d46c3d13c8b7b5504f8d89701a3250f
2021-05-19 16:38:54 +00:00
Abby Sassel
3ba5d1e540 server: include more detail in inconsistent metadata error messages (fix #6684)
GitOrigin-RevId: 1a0d8fa2b465320e9ab4ea43259d0e8d92364473
2021-05-19 05:02:53 +00:00
David Overton
ddad668f07 Fix/custom table name
GitOrigin-RevId: 5004717ac7d9e848ca186a1cdf52e375547034bf
2021-05-18 13:37:27 +00:00
Antoine Leblanc
ecb90c47a1 server: fix action output fields return type (fix hasura/graphql-engine#6631)
GitOrigin-RevId: 9be5ac87fe69c55aafb6b5af918eb4deb97e27d5
2021-05-18 09:32:43 +00:00
Antoine Leblanc
27e68517e7 server: unify parsing Postgres scalars
GitOrigin-RevId: f2a938758cb82b432ec209b0fb453a1d8b206bee
2021-05-13 20:13:49 +00:00
Antoine Leblanc
4c8753afca server: fix single char SQL generation (fixes hasura/graphql-engine#6814)
GitOrigin-RevId: cbbec459cf7b214d50a14e5ef09f2567356e6481
2021-05-11 23:28:30 +00:00
Chris Done
56c094b299 Support query explain for MSSQL (fixes #1024)
Co-authored-by: Abby Sassel <3883855+sassela@users.noreply.github.com>
Co-authored-by: Vamshi Surabhi <6562944+0x777@users.noreply.github.com>
GitOrigin-RevId: 5a57d7570884a5469a947742e4ab9290a0cff55f
2021-05-11 10:05:39 +00:00
Abby Sassel
1e45580e7c server/mssql: fix subscriptions (fixes #6887)
GitOrigin-RevId: 0d0184bd910400ea3a48a650fc61391fa8fd5518
2021-05-10 10:18:45 +00:00
Karthikeyan Chinnakonda
d7ccf81526 server: fix bug when executing a custom function with a row type argument
GitOrigin-RevId: d3a1fa8c9f6b420f4c88eb60c92019c8d0fdc58d
2021-05-06 09:19:49 +00:00
Lyndon Maydwell
3fad5f6678 REST endpoint uuid param bugfix
GitOrigin-RevId: 56066b145576c1f536c420be3e537e8313e61099
2021-05-06 06:44:17 +00:00
Karthikeyan Chinnakonda
4702ba514a pro server: disable GraphQL schema introspection for specified roles
GitOrigin-RevId: 36ceb1852bc7779092cfb59c92035dd9635b2e3f
2021-05-05 12:26:23 +00:00
Antoine Leblanc
34fc92ea8c server: fix validation of query variables (fixes hasura/graphql-engine#6867)
GitOrigin-RevId: 395bf986e0b823f9f18fb9f204e2056b2d2fd682
2021-05-04 17:58:43 +00:00
Brandon Simmons
9c9bb43a53 server: restore proper batching behavior in event trigger processing (#1237)
This essentially restores the original code from c425b554b8
(https://github.com/hasura/graphql-engine/pull/4013). Prior to this
commit we would slurp messages as fast as possible from the database
(one thing c425b55 fixed).

Another thing broken as a consequence of the same logic was the
removeEventFromLockedEvents logic which unlocks in-flight events
(breaking at-least-once delivery)

Some archeology, post-c425b55:

- cc8e2ccc erroneously attempted to refactor using `bracket`, resulting
  in the same slurp-all-events behavior (since we don't ever wait for
  processEvent to complete)
- at some point event processing within a batch is made serial, this
  reported as a bug. See: https://github.com/hasura/graphql-engine/issues/5189
- in 0ef52292b5 (which I approved...) an `async` is added, again
  causing the same issue...

GitOrigin-RevId: d8cbaab385267a4c3f1f173e268a385265980fb1
2021-04-29 04:02:05 +00:00
Vladimir Ciobanu
f50f61ab6a server: fix one-to-one relationships
GitOrigin-RevId: e19f4dec04abbdcf4589d24031705e5c57ea1fbb
2021-04-27 13:45:45 +00:00
kodiakhq[bot]
a935746e17 Integration test improvements (for speed/clarity), also increase polling interval for scheduled events
This claws back ~7min from integration tests (run serially, as with `dev.sh test --integration`
Further improvements would do well to focus on optimizing metadata operations, as `setup` dominates

GitOrigin-RevId: 76637d6fa953c2404627c4391447a05bf09355fa
2021-04-27 05:35:26 +00:00
Chris Done
53fc5617cf Feature/bigquery python tests
Co-authored-by: Aniket Deshpande <922486+aniketd@users.noreply.github.com>
GitOrigin-RevId: c425f84f1c9b8e38ebbfa509b6fa9298e023f386
2021-04-22 11:32:55 +00:00
Antoine Leblanc
5283eebf75 server: fix on_conflict missing when no column update permissions
GitOrigin-RevId: 34dd9f648ca1e268274b6244c48c9e9710c4477d
2021-04-22 10:27:35 +00:00
Karthikeyan Chinnakonda
7be8003a4b server: limit of an inherited role will be the max of the limit of the limits of the roles
GitOrigin-RevId: 1373f80a691047a9c69b3705e3aafa9244f673b0
2021-04-21 09:13:15 +00:00
Antoine Leblanc
84ed74aba1 server: fix empty remote input objects (fixes #6029, #6703)
GitOrigin-RevId: 3c474ee85b5d1271abfc8848e29ae1d3be28ff63
2021-04-21 01:17:01 +00:00
Abby Sassel
703928de9f mssql: support query multiplexing in subscriptions
GitOrigin-RevId: 757ceba2c1cdb1107ce0b0e41d2e70ac795d0d73
2021-04-20 16:58:13 +00:00
Karthikeyan Chinnakonda
58cf521c62 server: support relationship column comparison with root table columns
GitOrigin-RevId: 9d9bcb82a997c1f060df5ba0726c29d934e70d71
2021-04-19 12:17:07 +00:00
Philip Carlsen
4cb224afd8 Adding support for ST_3DDWithin and ST_3DIntersects
Co-authored-by: Rikin Kachhia <54616969+rikinsk@users.noreply.github.com>
GitOrigin-RevId: de31fa68fd7dc8ffa0c4e4b89b727a5e14b0525e
2021-04-14 13:03:11 +00:00
kodiakhq[bot]
1b378ae6e8 Add a new /dev/rts_stats endpoint, enabled when '+RTS -T'
GitOrigin-RevId: e347bc2f66bad814516662e34bbd8322c214be25
2021-04-13 17:33:38 +00:00
Sameer Kolhar
b274a2d240 server: disable caching for actions with forward client headers enabled
Co-authored-by: Lyndon Maydwell <92299+sordina@users.noreply.github.com>
Co-authored-by: Antoine Leblanc <1618949+nicuveo@users.noreply.github.com>
Co-authored-by: Abby Sassel <3883855+sassela@users.noreply.github.com>
Co-authored-by: hasura-bot <30118761+hasura-bot@users.noreply.github.com>
Co-authored-by: Rikin Kachhia <54616969+rikinsk@users.noreply.github.com>
Co-authored-by: Ikechukwu Eze <22247592+iykekings@users.noreply.github.com>
Co-authored-by: Aleksandra Sikora <9019397+beerose@users.noreply.github.com>
Co-authored-by: Rishichandra Wawhal <27274869+wawhal@users.noreply.github.com>
Co-authored-by: Naveen Naidu <30195193+Naveenaidu@users.noreply.github.com>
Co-authored-by: Vishnu Bharathi <4211715+scriptnull@users.noreply.github.com>
GitOrigin-RevId: c9a8be3cb607f7767e9d6791717106adf123e3a8
2021-04-13 07:01:34 +00:00
Antoine Leblanc
71ae144aa6 server: implement transaction workaround
GitOrigin-RevId: 404f8bbdefb8a99b31fac75e4253daad81c8af90
2021-04-01 20:41:41 +00:00
Rikin Kachhia
e3d8a721ee server: add "SET check_function_bodies=false" in pg_dump clean output
GitOrigin-RevId: f0526f9666c3986d8e3b374556859043f10dbe8d
2021-03-31 14:49:38 +00:00
Antoine Leblanc
60da76ed89 server/mssql: fix foreign keys being wrongfully coalesced
GitOrigin-RevId: 0cfef7176e751d17ea709814ae912574511ca79a
2021-03-31 13:49:31 +00:00
Rakesh Emmadi
362230e8d0 server: async action query subscription
Multi source support had limited the availability of async action queries in subscriptions. This PR
adds support for async action query subscriptions with new implementation. Also addresses https://github.com/hasura/graphql-engine/issues/6460.

GitOrigin-RevId: 5ddc321073d224f287dc4b86ce2239ff55190b36
2021-03-31 10:40:15 +00:00
Vladimir Ciobanu
c08e6d108b server: allow GeoJSON to be passed for Geometry/Geography operators
GitOrigin-RevId: 51ca927b55d3d717da07447f67fd4d3c068a8357
2021-03-26 17:00:18 +00:00
Abby Sassel
9f0bcabf23 server/mssql: better support for spatial data operators (fixes #789)
GitOrigin-RevId: b3d59a5c351e747370b82d086fe13d5d8d178d05
2021-03-24 13:44:44 +00:00
David Overton
ad8df00c48 Tests/multisource
GitOrigin-RevId: 603d51d65dc4ff8a64c8d1abd19845bf6a316bde
2021-03-24 06:45:33 +00:00
Karthikeyan Chinnakonda
d236391af8 server: remove restriction of tracking only base function argument types
GitOrigin-RevId: 48feb18f1075bb8fe6a1b27a950198127eaaf3da
2021-03-23 16:04:11 +00:00
Rakesh Emmadi
97549ccc8e server: fix action output type generation (#850)
* fix action output type generation

* update CHANGELOG.md

GitOrigin-RevId: 558ff640f5fe5dd5ebf15a3c063f1b989a5fb28a
2021-03-22 10:57:46 +00:00
Abby Sassel
7a75a08dfa server/mssql: belatedly address code review feedback
GitOrigin-RevId: faf3a646fd1067f2e0ed417b97871cd5173ca02e
2021-03-19 16:40:44 +00:00
Antoine Leblanc
f1183b8ae3 server: memoize recursive action input arguments
GitOrigin-RevId: 0dc11f95953f6ad8dfcd82a11f105442042291f8
2021-03-19 14:47:58 +00:00
Abby Sassel
6436ac06e0 server/mssql: support N/IN and N/LIKE operators
GitOrigin-RevId: 6f897b384a4469425d46b1bedf015ecbd1600fcc
2021-03-19 12:43:14 +00:00
Karthikeyan Chinnakonda
395de58c42 server: fix inherited_roles issue when some of the underlying roles don't have permissions configured
GitOrigin-RevId: 771491ec0cf6c0d860ef374ed67b426220fa2b96
2021-03-18 15:29:25 +00:00
Karthikeyan Chinnakonda
478c01ab9b server: support tracking functions having only base type arguments
GitOrigin-RevId: e8939ad25212fc0965e0912fc88721a0cdff844e
2021-03-18 12:50:52 +00:00
Abby Sassel
89d838b85a server: split BoolExpBasic tests into common and backend-specific classes
GitOrigin-RevId: 9e62260881de63e5f89007bb1d6607254625cda7
2021-03-17 10:57:06 +00:00
Abby Sassel
881cc55e0e server: split TestGraphQLQueryBasic into common and backend-specific test classes
GitOrigin-RevId: 9e99047f7ab83f06c94c4741c7c0591eb2ca35e8
2021-03-16 16:42:20 +00:00
Karthikeyan Chinnakonda
6093010a6e server: fix issue of parsing input objects in remote schema queries
GitOrigin-RevId: 98c62cab836aff2778dbfedd6535450989090a30
2021-03-15 06:32:07 +00:00
Abby Sassel
64d52f5fa3 server: generalize integration tests
Co-authored-by: Antoine Leblanc <1618949+nicuveo@users.noreply.github.com>
GitOrigin-RevId: 647edb8d293bf783c504b7e15ce02c56858b3b72
2021-03-11 18:18:41 +00:00
Anon Ray
d16bc4fe46 server: fix handling of nullable object relationships
GitOrigin-RevId: 3214e77ed06a07b6c1293d59daa088649a881e78
2021-03-10 08:56:03 +00:00
Lyndon Maydwell
0c1016e065 Inconsistent metadata support for REST endpoints
Previously invalid REST endpoints would throw errors during schema cache build.

This PR changes the validation to instead add to the inconsistent metadata objects in order to allow use of `allow_inconsistent_metadata` with inconsistent REST endpoints.

All non-fatal endpoint definition errors are returned as inconsistent metadata warnings/errors depending on the use of `allow_inconsistent_metadata`. The endpoints with issues are then created and return informational runtime errors when they are called.

Console impact when creating endpoints is that error messages now refer to metadata inconsistencies rather than REST feature at the top level:

![image](https://user-images.githubusercontent.com/92299/109911843-ede9ec00-7cfe-11eb-9c55-7cf924d662a6.png)

<img width="969" alt="image" src="https://user-images.githubusercontent.com/92299/110258597-8336fa00-7ff7-11eb-872c-bfca945aa0e8.png">

Note: Conflicting endpoints generate one error per conflicting set of endpoints due to the implementation of `groupInconsistentMetadataById` and `imObjectIds`. This is done to ensure that error messages are terse, but may pose errors if there are some assumptions made surrounding `imObjectIds`.

Related to https://github.com/hasura/graphql-engine-mono/pull/473 (Allow Inconsistent Metadata (v2) #473 (Merged))

---

### Kodiak commit message

Changes the validation to use inconsistent metadata objects for REST endpoint issues.

#### Commit title

Inconsistent metadata for REST endpoints

GitOrigin-RevId: b9de971208e9bb0a319c57df8dace44cb115ff66
2021-03-10 05:26:10 +00:00
Karthikeyan Chinnakonda
0a7d634326 server: fix issue when remote relationship col has a custom GQL name
GitOrigin-RevId: ca45383020d0e8f80afb445ab8bb240cc1505ea9
2021-03-09 09:25:29 +00:00
Karthikeyan Chinnakonda
92026b769f [Preview] Inherited roles for postgres read queries
fixes #3868

docker image - `hasura/graphql-engine:inherited-roles-preview-48b73a2de`

Note:

To be able to use the inherited roles feature, the graphql-engine should be started with the env variable `HASURA_GRAPHQL_EXPERIMENTAL_FEATURES` set to `inherited_roles`.

Introduction
------------

This PR implements the idea of multiple roles as presented in this [paper](https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/FGALanguageICDE07.pdf). The multiple roles feature in this PR can be used via inherited roles. An inherited role is a role which can be created by combining multiple singular roles. For example, if there are two roles `author` and `editor` configured in the graphql-engine, then we can create a inherited role with the name of `combined_author_editor` role which will combine the select permissions of the `author` and `editor` roles and then make GraphQL queries using the `combined_author_editor`.

How are select permissions of different roles are combined?
------------------------------------------------------------

A select permission includes 5 things:

1. Columns accessible to the role
2. Row selection filter
3. Limit
4. Allow aggregation
5. Scalar computed fields accessible to the role

 Suppose there are two roles, `role1` gives access to the `address` column with row filter `P1` and `role2` gives access to both the `address` and the `phone` column with row filter `P2` and we create a new role `combined_roles` which combines `role1` and `role2`.

Let's say the following GraphQL query is queried with the `combined_roles` role.

```graphql
query {
   employees {
     address
     phone
   }
}
```

This will translate to the following SQL query:

```sql

 select
    (case when (P1 or P2) then address else null end) as address,
    (case when P2 then phone else null end) as phone
 from employee
 where (P1 or P2)
```

The other parameters of the select permission will be combined in the following manner:

1. Limit - Minimum of the limits will be the limit of the inherited role
2. Allow aggregations - If any of the role allows aggregation, then the inherited role will allow aggregation
3. Scalar computed fields - same as table column fields, as in the above example

APIs for inherited roles:
----------------------

1. `add_inherited_role`

`add_inherited_role` is the [metadata API](https://hasura.io/docs/1.0/graphql/core/api-reference/index.html#schema-metadata-api) to create a new inherited role. It accepts two arguments

`role_name`: the name of the inherited role to be added (String)
`role_set`: list of roles that need to be combined (Array of Strings)

Example:

```json
{
  "type": "add_inherited_role",
  "args": {
      "role_name":"combined_user",
      "role_set":[
          "user",
          "user1"
      ]
  }
}
```

After adding the inherited role, the inherited role can be used like single roles like earlier

Note:

An inherited role can only be created with non-inherited/singular roles.

2. `drop_inherited_role`

The `drop_inherited_role` API accepts the name of the inherited role and drops it from the metadata. It accepts a single argument:

`role_name`: name of the inherited role to be dropped

Example:

```json

{
  "type": "drop_inherited_role",
  "args": {
      "role_name":"combined_user"
  }
}
```

Metadata
---------

The derived roles metadata will be included under the `experimental_features` key while exporting the metadata.

```json
{
  "experimental_features": {
    "derived_roles": [
      {
        "role_name": "manager_is_employee_too",
        "role_set": [
          "employee",
          "manager"
        ]
      }
    ]
  }
}
```

Scope
------

Only postgres queries and subscriptions are supported in this PR.

Important points:
-----------------

1. All columns exposed to an inherited role will be marked as `nullable`, this is done so that cell value nullification can be done.

TODOs
-------

- [ ] Tests
   - [ ] Test a GraphQL query running with a inherited role without enabling inherited roles in experimental features
   - [] Tests for aggregate queries, limit, computed fields, functions, subscriptions (?)
   - [ ] Introspection test with a inherited role (nullability changes in a inherited role)
- [ ] Docs
- [ ] Changelog

Co-authored-by: Vamshi Surabhi <6562944+0x777@users.noreply.github.com>
GitOrigin-RevId: 3b8ee1e11f5ceca80fe294f8c074d42fbccfec63
2021-03-08 11:15:10 +00:00
Rakesh Emmadi
edf5a0661e server: support mssql views
GitOrigin-RevId: 50e2fc1d64a67a9284ae62d2401ca6f9627ebdab
2021-03-05 10:53:38 +00:00
hasura-bot
da3c9f2c53 minor typo fixes (#165)
Co-authored-by: Colby Thomas <coloradocolby@gmail.com>
GITHUB_PR_NUMBER: 6311
GITHUB_PR_URL: https://github.com/hasura/graphql-engine/pull/6311

Co-authored-by: Colby Thomas <coloradocolby@gmail.com>
Co-authored-by: Vamshi Surabhi <0x777@users.noreply.github.com>
GitOrigin-RevId: 946665878fb9199d067ad1bd981de9525e86a0ae
2021-03-04 06:36:15 +00:00
Vladimir Ciobanu
d5ff1acf2d better handling for one-to-one relationships
Co-authored-by: Rikin Kachhia <54616969+rikinsk@users.noreply.github.com>
GitOrigin-RevId: 1bb5bc0c4ac8109ee1d20563d23cf98e0906a483
2021-03-03 13:02:59 +00:00
David Overton
456b6d5664 Tests for metadata resource version
GitOrigin-RevId: c1db1355ef8c6617db8179c8c50ba2bd91f7062f
2021-03-03 04:41:02 +00:00
Karthikeyan Chinnakonda
d2418383bf server: add https remote schema tests
GitOrigin-RevId: 9e9e66248f956174dc8197adeb7a48da12e53dac
2021-03-02 16:52:47 +00:00
Abby Sassel
fb1a0d286d server: support ltree operators (close #625)
GitOrigin-RevId: fb6a3eb8cbe4604789938bcbc78916fbcd1af515
2021-02-25 11:06:49 +00:00
Karthikeyan Chinnakonda
4211d27272 server: support reading JWT from Cookie header
GitOrigin-RevId: 1de90242d3c000361f87256c2dddce1677863231
2021-02-25 09:03:46 +00:00
Lyndon Maydwell
08da0c63b6 REST Endpoints - Prohibit Invalid slashes, duplicate variables, non-singular query definitions, subscriptions
Resolves Issues:

* https://github.com/hasura/graphql-engine-mono/issues/658 - Invalid Slashes
* https://github.com/hasura/graphql-engine-mono/issues/628 - Subscriptions

Implementation:

* Moved some logic from Endpoint.hs to allow reuse of splitting url into PathSegments.
* Additional validation steps alongside checking for overlapping routes
* Logging potential misuse of GET for mutations

Future Work:

* [ ] GET is allowed for mutations (Ignore/Log warning for Now)
* [ ] Add to scInconsistentObjs rather than throwing error
  * Add information to scInconsistentObjs instead of raising errors directly.

TODO:

* [x] Duplicate variable segments with the same name in the location should not be allowed
* [x] We should throw an error on trailing and leading slashes and URLs which contain empty segments
* [x] Endpoints can be created using subscriptions. But the error only shows at the time of the query
* [x] Tests

---

### Kodiak commit message

Prohibit Invalid slashes, duplicate variables, subscriptions for REST endpoints.

GitOrigin-RevId: 86c0d4af97984c8afd02699e6071e9c1658710b8
2021-02-24 04:31:05 +00:00
Abby Sassel
b00009f4bb server: fix issue with queries on character column types (close #6217)
GitOrigin-RevId: 81eaa0db63656b1d37b9b71736d4309af902cc47
2021-02-22 10:21:21 +00:00
Lyndon Maydwell
59c01786fe Optimistic Metadata Locking
Add optimistic concurrency control to the ‘replace_metadata’ call.

Prevents users from submitting out-of-date metadata to metadata-mutating APIs.

See https://github.com/hasura/graphql-engine-mono/issues/472 for details.

GitOrigin-RevId: 5f220f347a3eba288a9098b01e9913ffd7e38166
2021-02-19 02:40:23 +00:00
Karthikeyan Chinnakonda
77b3bb5a20 server: run function permissions tests in CI
GitOrigin-RevId: 750b44d0f30df506eb8f0a8eec42fcd1a7d51599
2021-02-18 08:27:00 +00:00
Lyndon Maydwell
0d67b5cb53 Allow Inconsistent Metadata (v2) (#473)
Allow Inconsistent Metadata

GitOrigin-RevId: 7b7e1fdccbeaa1b7dccf66ff22c4b40f8cf5bb27
2021-02-16 08:10:21 +00:00
Phil Freeman
7fffc11077 Caching, Rate Limiting, Metrics & Session Variable Improvements (#376)
* server: use a leaky bucket algorithm for bytes-per-second cache rate limiting

* Use evalsha properly

* Adds redis cache limit parameters to PoliciesConfig

* Loads Leaky Bucket Script On Server Start

* Adds more redis logging and moves cache update into lua script

* reverts setex in lua and adds notes

* Refactors cacheStore and adds max TTL and cache size limits

* Filter session vars in cache key

* WIP

* parens

* cache-clear-hander POC implementation

* cache-clear-hander POC implementation

* Pro projectId used as cache key

* POC working!

* prefixing query-response keys in redis

* Add cacheClearer to RedisScripts

* Partial implementation of cacheClearer from scripts record

* updating tests

* [automated] stylish-haskell commit

* Adds query look with up with metrics script

* Adds missing module and lua script from last commit

* Changes redis script module structure to match cache clearing branch

* minor change to lua script

* cleaning up cache clearing

* generalising JsonLog

* [automated] stylish-haskell commit

* Draft Cache Metrics Endpoint

* Adds Cache Metrics Handler

* Adds hook handler module

* Missed HandlerHook module in last commit

* glob

* Fixes redis mget bug

* Removes cache totals and changes dashes to colons in metric cache keys

* Adds query param to clear clear endpoint for deleting specific keys

* Adds query param to clear clear endpoint for deleting specific keys

* Cache Metrics on query families rather then queries

* Replace Set with nub

* Base16 Redis Hashes

* Query Family Redis Keys With Roles

* response headers for cache keys

* fixing bug in family key by excluding operation name; using hash for response header instead of entire key

* Adds query family to redis cache keys and cache clear endpoint

* Fixes queryfamily hash bug

* Moves cache endpoints to /pro

* Moved cache clear to POST

* Refactors cache clear function

* Fixes query family format bug

* Adds query cache tests and optional --redis-url flag to python test suite

* Adds session variable cache test

* Update pro changelog

* adding documentation for additional caching features

* more docs

* clearing up units of leaky bucket params

* Adds comments to leaky bucket script

* removes old todo

* Fixes session variable filtering to work with new query rootfield

* more advanced defaulting behaviour for bucket rate and capacity.

* Updates Docs

* Moves Role into QueryFamily hash

* Use Aeson for Cache Clear endpoint response

* Moves trace to bracket the leaky bucket script

* Misc review tweaks

* Adds sum type for cache clear query params

* Hardcodes RegisReplyLog log level

* Update docs/graphql/cloud/response-caching.rst

Co-authored-by: Phil Freeman <phil@hasura.io>

* new prose for rate limiting docs

* [automated] stylish-haskell commit

* make rootToSessVarPreds total

* [automated] stylish-haskell commit

* Fixes out of scope error

* Renamed _acRedis to _acCacheStore

Co-authored-by: Solomon Bothwell <ssbothwell@gmail.com>
Co-authored-by: Lyndon Maydwell <lyndon@sordina.net>
Co-authored-by: David Overton <david@hasura.io>
Co-authored-by: Stylish Haskell Bot <stylish-haskell@users.noreply.github.com>
Co-authored-by: Lyndon Maydwell <lyndon@hasura.io>
GitOrigin-RevId: dda5c1a3f902967b3d78310f950541a55fabb1b0
2021-02-13 00:06:18 +00:00
Karthikeyan Chinnakonda
312e56dfa6 server: support tracking of custom functions which return single row
GitOrigin-RevId: fbf99816a70e666bb9b02fca92a0ee7d419cdff8
2021-02-03 14:07:30 +00:00
Swann Moreau
c14dcd5792 pass gql requests into auth webhook POST body (#149)
* fix arg order in UserAuthentication instance [force ci]

* change the constructor name to AHGraphQLRequest

Co-authored-by: Stylish Haskell Bot <stylish-haskell@users.noreply.github.com>
Co-authored-by: Karthikeyan Chinnakonda <karthikeyan@hasura.io>
GitOrigin-RevId: fb3258f4a84efc6c730b0c6222ebd8cea1b91081
2021-02-03 07:11:39 +00:00
Karthikeyan Chinnakonda
10a3f9960d server: new function permissions layer
Co-authored-by: Rikin Kachhia <54616969+rikinsk@users.noreply.github.com>
Co-authored-by: Rakesh Emmadi <12475069+rakeshkky@users.noreply.github.com>
GitOrigin-RevId: 35645121242294cb6bb500ea598e9a1f2ca67fa1
2021-01-29 05:49:09 +00:00
Lyndon Maydwell
0767333597 server: support restified versions of graphql queries (#303)
Restified GraphQL Endpoints feature.

GitOrigin-RevId: 3d6e589426ec21a60a915b47f579f0ac4934af45
2021-01-29 01:03:35 +00:00
Swann Moreau
d4b474061f server: split server test suite to run in parallel on circleci (#309)
Co-authored-by: rakeshkky <12475069+rakeshkky@users.noreply.github.com>
Co-authored-by: Vishnu Bharathi P <vishnubharathi04@gmail.com>
Co-authored-by: Vamshi Surabhi <0x777@users.noreply.github.com>
Co-authored-by: Nizar Malangadan <nizar-m@users.noreply.github.com>
Co-authored-by: nizar-m <19857260+nizar-m@users.noreply.github.com>
GitOrigin-RevId: b8a1e9c3ba4797bad8dbb2daa75d23d4ad163546
2021-01-25 08:24:13 +00:00
hasura-bot
98ccd81704 Server: Remote relationships permissions
GITHUB_PR_NUMBER: 6125
GITHUB_PR_URL: https://github.com/hasura/graphql-engine/pull/6125

Co-authored-by: Karthikeyan Chinnakonda <15602904+codingkarthik@users.noreply.github.com>
GitOrigin-RevId: 53d0671e6335dad1af7cb00e3e05e7021a910673
2021-01-19 20:57:58 +00:00
Vladimir Ciobanu
6e752a7876 server: add type information to aggregates and stringify them (closes #5704)
Fixes https://github.com/hasura/graphql-engine/issues/5704 by checking, for aggregate fields whether we are handling a numeric aggregation.

This PR also adds type information to `ColFld` such that we know the type of the field.

This is the second attempt. See #319 for a less invasive approach. @nicuveo suggested type information might be useful, and since it wasn't hard to add, I think this version is better as well.

GitOrigin-RevId: aa6a259fd5debe9466df6302839ddbbd0ea659b5
2021-01-18 13:52:51 +00:00
Karthikeyan Chinnakonda
6c22132061 server: move remote schema permissions APIs to /v1/metadata
Earlier (pre catalog separation), the remote schema permissions were in `/v1/query`. This PR moves it to `/v1/metadata`.

GitOrigin-RevId: cb39d9df4cc2288f67231504e3a7909f2f8df4da
2021-01-18 10:39:29 +00:00
hasura-bot
513a3d0c19 Fix action relationship type and input arguments (closes #6402) (#284)
Co-authored-by: Antoine Leblanc <antoine@hasura.io>
GITHUB_PR_NUMBER: 6417
GITHUB_PR_URL: https://github.com/hasura/graphql-engine/pull/6417
GitOrigin-RevId: 37b67a4d04e0ed3b16fc5fc9bf025b24b1f1bf6e
2021-01-18 06:57:24 +00:00
Karthikeyan Chinnakonda
c14bcb6967 server: accept new config allowed_skew in JWT config to provide leeway in JWT expiry
fixes https://github.com/hasura/graphql-engine/issues/2109

This PR accepts a new config `allowed_skew` in the JWT config to provide for some leeway while comparing the JWT expiry time.

GitOrigin-RevId: ef50cf77d8e2780478685096ed13794b5c4c9de4
2021-01-13 08:39:18 +00:00
Karthikeyan Chinnakonda
f967a4b22e Server: fix query actions issue used with relationship and configured with permissions
Fixes https://github.com/hasura/graphql-engine/issues/6385

In the v1.3.4-beta.2 version, the SQL generated for a query action containing relationship and configured with permissions parsed the `x-hasura-user-id` session variable value through the `hasura.user` postgres setting instead of passing the session variables as an JSON object to the query as it was in v1.3.3.

This PR fixes the SQL generation to that of v1.3.3

Co-authored-by: Rakesh Emmadi <12475069+rakeshkky@users.noreply.github.com>
GitOrigin-RevId: 838ba812f89b51df7fcead81b9d3c2885dfa39b4
2021-01-12 12:04:21 +00:00
Karthikeyan Chinnakonda
7b83018c39 Server: fix issue of not being able to track tables with non-compliant GraphQL names (#313)
* server: use only the valid tables in the node parser

* add test

GitOrigin-RevId: 90edf001220c7d78eaab86ff565ee4311844b5d3
2021-01-12 08:13:58 +00:00
Karthikeyan Chinnakonda
44347d2d74 server: template the schema and table names in the event trigger PG functions
Earlier, while creating the event trigger's internal postgres trigger, we used to get the name of the table from the `TG_TABLE_NAME` special trigger variable. Using this with normal tables works fine, but it breaks when the parent table is partitioned because we associate the ET configuration in the schema only with the original table (as it should be).

In this PR, we supply the table name and schema name through template variables instead of using `TG_TABLE_NAME` and `TG_TABLE_SCHEMA`, so that event triggers work with a partitioned table as well.

TODO:

- [x] Changelog
- [x] unit test (ET on partition table)

GitOrigin-RevId: 556376881a85525300dcf64da0611ee9ad387eb0
2021-01-06 20:22:34 +00:00
Swann Moreau
5bc0355bdd [server] coalesce multiple run_sql calls in tests (#270)
GitOrigin-RevId: abd7303aaf8e7a8739fd10574249aec450082ef8
2021-01-06 16:07:22 +00:00
Rakesh Emmadi
29f2ddc289 server: support separate metadata database and server code setup for multi sources (#197)
This is an incremental PR towards https://github.com/hasura/graphql-engine/pull/5797

Co-authored-by: Anon Ray <ecthiender@users.noreply.github.com>
GitOrigin-RevId: a6cb8c239b2ff840a0095e78845f682af0e588a9
2020-12-28 12:56:55 +00:00
Karthikeyan Chinnakonda
ef33a61266 server: fix handling of empty array values in relationships of set_custom_types API (#219)
* server: fix handling of empty array values in relationships of set_custom_types

* add a test for dropping the relationship

GitOrigin-RevId: abff138b0021647a1cb6c6c041c2ba53c1ff9b77
2020-12-24 10:11:58 +00:00
Auke Booij
4bbd2fd4dc server: allow fragments to use variables (fix hasura/graphql-engine#6303) (#225)
GitOrigin-RevId: a60b6816212b749836d5d88f296e229e581ab452
2020-12-22 10:42:34 +00:00
Karthikeyan Chinnakonda
39a4352569 Merge pull request #113 from hasura/karthikeyan/remote-schema-permissions
server: remote schema permissions
GitOrigin-RevId: 63b9717e30351676c9474bdfddd3ad1ee1409eea
2020-12-21 09:12:35 +00:00
Tirumarai Selvan
b544b87b9b Merge pull request #223 from hasura/jberryman/5863-prep-refactoring
GitOrigin-RevId: 71b1453edf4b93ffc16a15ea3c6057bb865b6606
2020-12-20 06:53:38 +00:00
Rakesh Emmadi
a2cf9a53c2 server: move to storing metadata as a json blob (#115)
GitOrigin-RevId: 3d1a7618a4ec086c2d255549a6c15087201e9ab0
2020-12-08 14:23:28 +00:00
Antoine Leblanc
3537e2acdc server: fix primary key mutations issue (closes #6255) (#129)
* Add update_by_pk test with more interesting permissions.

* Add new delete test with more interesting permissions.

* Fix byPk operations not providing all columns.

* Empty commit to unlock ci.

GitOrigin-RevId: eb1ca2cc4c59f421bc5fedf49bef91aa4bbdca94
2020-12-02 14:13:00 +00:00
hasura-bot
f6bd354b40 server: hasura on PG v13 (#125)
GitOrigin-RevId: 00fd91c250bcf3dc7ee638e3b152e0dab7281de7
2020-12-01 12:22:42 +00:00
hasura-bot
7b31ff99d1 Support Postgres POSIX regex operators (close #4317) (#119)
Co-authored-by: christophediprima <dipdipdip84@gmail.com>
Co-authored-by: dip <dipdipdip84@gmail.com>
Co-authored-by: Auke Booij <auke@hasura.io>
Co-authored-by: Antoine Leblanc <antoine@hasura.io>
GITHUB_PR_NUMBER: 6172
GITHUB_PR_URL: https://github.com/hasura/graphql-engine/pull/6172
GitOrigin-RevId: 5192d238b527cd21b6efb2f74e279ecc34756c29
2020-11-27 10:54:52 +00:00
hasura-bot
5ca8cd23a0 server: support remote relationship with ID scalar types (#92)
Co-authored-by: Karthikeyan Chinnakonda <karthikeyan@hasura.io>
GITHUB_PR_NUMBER: 6227
GITHUB_PR_URL: https://github.com/hasura/graphql-engine/pull/6227

Co-authored-by: Karthikeyan Chinnakonda <karthikeyan@hasura.io>
GitOrigin-RevId: 666ec37d570e46482e0f27db2c97c9e3f9c1f4d3
2020-11-24 12:20:22 +00:00
hasura-bot
fb902d4209 Support tracking SQL functions as mutations. Closes #1514 (#34)
* Support tracking SQL functions as mutations. Closes #1514

Co-authored-by: Brandon Simmons <brandon.m.simmons@gmail.com>
Co-authored-by: Brandon Simmons <brandon@hasura.io>
GITHUB_PR_NUMBER: 6160
GITHUB_PR_URL: https://github.com/hasura/graphql-engine/pull/6160

* Update docs/graphql/core/api-reference/schema-metadata-api/custom-functions.rst

Co-authored-by: Marion Schleifer <marion@hasura.io>

* Update docs/graphql/core/schema/custom-functions.rst

Co-authored-by: Marion Schleifer <marion@hasura.io>

* Update docs/graphql/core/schema/custom-functions.rst

Co-authored-by: Marion Schleifer <marion@hasura.io>

* Update docs/graphql/core/schema/custom-functions.rst

Co-authored-by: Brandon Simmons <brandon@hasura.io>
Co-authored-by: Brandon Simmons <brandon.m.simmons@gmail.com>
Co-authored-by: Marion Schleifer <marion@hasura.io>
GitOrigin-RevId: 8fd39258641ecace6e3e9930e497b1655ad35080
2020-11-18 18:05:59 +00:00
hasura-bot
8eebcb9bdf server: query remote server in a remote join query iff all arguments are not null (#31)
* server: query remote server in a remote join query iff all arguments are not null

Co-authored-by: Karthikeyan Chinnakonda <karthikeyan@hasura.io>
GITHUB_PR_NUMBER: 6199
GITHUB_PR_URL: https://github.com/hasura/graphql-engine/pull/6199

* Update server/src-lib/Hasura/Backends/Postgres/Execute/RemoteJoin.hs

Co-authored-by: Brandon Simmons <brandon@hasura.io>

* Apply suggestions from code review

Co-authored-by: Brandon Simmons <brandon@hasura.io>

* Update server/tests-py/test_remote_relationships.py

Co-authored-by: Brandon Simmons <brandon@hasura.io>

* Apply suggestions from code review

Co-authored-by: Brandon Simmons <brandon@hasura.io>

* use guard instead of case match

* add comment about the remote relationship joining

* add a comment about the design discussion

* update CHANGELOG

Co-authored-by: Karthikeyan Chinnakonda <karthikeyan@hasura.io>
Co-authored-by: Brandon Simmons <brandon@hasura.io>
GitOrigin-RevId: ce7e8288d37ad7c32705f96cb6363f6ad68f3c0a
2020-11-18 09:00:12 +00:00
Vishnu Bharathi P
58c44f55dd Merge oss/master onto mono/main
GitOrigin-RevId: 1c8c4d60e033c8a0bc8b2beed24c5bceb7d4bcc8
2020-11-12 22:37:19 +05:30
Vishnu Bharathi P
666058ab7f oss: renames dot files and folders
GitOrigin-RevId: 540aeec3be091e1cfb7b05a988f50445534ed663
2020-11-12 22:37:19 +05:30
Alexis King
6787a1b1b0
Fix the way replace_metadata drops event triggers (fix #5461) (#6137)
https://github.com/hasura/graphql-engine/pull/6137
2020-11-10 12:02:38 +00:00
Rakesh Emmadi
ca47c92f50
server: avoid raising mutation check constraint violation in pg procedure (#6123)
https://github.com/hasura/graphql-engine/pull/6123
2020-11-06 13:22:22 +00:00
Karthikeyan Chinnakonda
77a04c7395
Server: Fix flaky action timeout test (#6124)
https://github.com/hasura/graphql-engine/pull/6124
2020-11-04 07:09:53 +00:00
Vamshi Surabhi
98c853f4f7
use only required session variables in multiplexed queries for subscriptions (#4329)
* use only required session variables in multiplexed queries for subscriptions

This will reduce the load on Postgres when the result of a subscription
is not dependent on the session variables of the request

* add DerivingVia to the project wide extension list

* expose a more specific function to filter session variables

* improve documentation of session variables of a cohort

Co-Authored-By: Alexis King <lexi.lambda@gmail.com>

* fix bad rebase

* add test for checking only required session variables are used to make query

Co-authored-by: Alexis King <lexi.lambda@gmail.com>
Co-authored-by: Karthikeyan Chinnakonda <karthikeyan@hasura.io>
2020-11-03 13:45:22 +05:30
Karthikeyan Chinnakonda
2cb08a89cb
server: customize tracking tables with a custom name (#5719)
https://github.com/hasura/graphql-engine/pull/5719
2020-10-29 12:48:45 +00:00
Karthikeyan Chinnakonda
562b6ac43a
Server: support remote relationships to unions, interfaces and enum types (#6080)
* add support for joining to remote interface and union fields

* add test for making a remote relationship with an Union type

* add CHANGELOG

* remove the pretty-simple library

* remove unused imports from Remote.hs

* Apply suggestions from code review

Co-authored-by: Brandon Simmons <brandon.m.simmons@gmail.com>

* support remote relationships against enum fields as well

* update CHANGELOG

Co-authored-by: Brandon Simmons <brandon.m.simmons@gmail.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2020-10-29 17:00:19 +05:30
Karthikeyan Chinnakonda
c63801b573
server: fix bug when renaming table with manual relationships (#5806)
https://github.com/hasura/graphql-engine/pull/5806
2020-10-28 10:21:53 +00:00
Alexis King
bf466e3b63
server: Fix fine-grained incremental cache invalidation (fix #3759) (#6027)
This issue was very tricky to track down, but fortunately easy to fix.
The interaction here is subtle enough that it’s difficult to put into
English what would go wrong in what circumstances, but the new unit test
captures precisely that interaction to ensure it remains fixed.
2020-10-27 14:52:19 -05:00
Sameer Kolhar
b72fc6922a
server: fix issue with tracking custom functions that return SETOF materialized view (close #5294) (#5945)
https://github.com/hasura/graphql-engine/pull/5945
2020-10-22 13:26:42 +00:00
Karthikeyan Chinnakonda
3ea611f9fd
Server: Validate remote schema queries (#5938)
* [skip ci] use the args while making the fieldParser

* modify the execution part of the remote queries

* parse union queries deeply

* add test for remote schema field validation

* add tests for validating remote query arguments


Co-authored-by: Auke Booij <auke@hasura.io>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2020-10-13 14:03:11 +05:30
Auke Booij
84a129c8e4
server: heterogeneous execution of GraphQL queries (#5869)
https://github.com/hasura/graphql-engine/pull/5869
2020-10-07 10:23:17 +00:00
Karthikeyan Chinnakonda
9d047d1726
server: add custom timeouts to actions (#5762)
https://github.com/hasura/graphql-engine/pull/5762
2020-09-16 09:53:17 +00:00
kodiakhq[bot]
e29fa9740e
Merge branch 'master' into scheduled-triggers-created-at-bug-5272 2020-09-16 02:19:28 +00:00
Karthikeyan Chinnakonda
b128222fc9
add additional tests for computed fields permissions (#5753) 2020-09-16 07:48:04 +05:30
Karthikeyan Chinnakonda
6eb7a7dd8a Merge branch 'master' into scheduled-triggers-created-at-bug-5272 2020-09-16 03:33:41 +05:30
Karthikeyan Chinnakonda
92ef504c9e
Server: add URL templating for event triggers and remote schemas (#5760)
* add url templating for event triggers


Co-authored-by: Brandon Simmons <brandon.m.simmons@gmail.com>
2020-09-10 15:00:34 +05:30
Karthikeyan Chinnakonda
3e10eb6694 don't send created_at in the payload in case of cron triggers 2020-09-08 12:18:00 +05:30
Karthikeyan Chinnakonda
5270ca8f09 add a comment about the increased timeout 2020-09-07 22:31:32 +05:30
Karthikeyan Chinnakonda
a8f7766780 increase the timeout for cron trigger test 2020-09-07 19:55:16 +05:30
Karthikeyan Chinnakonda
3a725df4da increase the timeout of the cron trigger test 2020-09-07 16:26:55 +05:30
Karthikeyan Chinnakonda
b548a8e008 add test for checking the value of created_at 2020-09-07 13:50:12 +05:30
Karthikeyan Chinnakonda
ee6797a8d8 refactor StandAloneEvent to OneOffEvents 2020-09-07 11:45:15 +05:30
Karthikeyan Chinnakonda
0f5e2a2605
Merge branch 'master' into fix-schema-duplication 2020-09-03 23:55:33 +05:30
Karthikeyan Chinnakonda
fe0ca00640 add tests 2020-09-01 17:13:42 +05:30
Rakesh Emmadi
4ce6002af2
support customizing JWT claims (close #3485) (#3575)
* improve jsonpath parser to accept special characters and property tests for the same

* make the JWTClaimsMapValueG parametrizable

* add documentation in the JWT file

* modify processAuthZHeader

Co-authored-by: Karthikeyan Chinnakonda <karthikeyan@hasura.io>
Co-authored-by: Marion Schleifer <marion@hasura.io>
2020-08-31 22:10:01 +05:30
Karthikeyan Chinnakonda
95b08086a8 Merge branch 'master' into remote-relationship-validation-bug-5133 2020-08-26 13:19:04 +05:30
Alexis King
7e970177c1
Rewrite GraphQL schema generation and query parsing (close #2801) (#4111)
Aka “the PDV refactor.” History is preserved on the branch 2801-graphql-schema-parser-refactor.

* [skip ci] remove stale benchmark commit from commit_diff

* [skip ci] Check for root field name conflicts between remotes

* [skip ci] Additionally check for conflicts between remotes and DB

* [skip ci] Check for conflicts in schema when tracking a table

* [skip ci] Fix equality checking in GraphQL AST

* server: fix mishandling of GeoJSON inputs in subscriptions (fix #3239) (#4551)

* Add support for multiple top-level fields in a subscription to improve testability of subscriptions

* Add an internal flag to enable multiple subscriptions

* Add missing call to withConstructorFn in live queries (fix #3239)

Co-authored-by: Alexis King <lexi.lambda@gmail.com>

* Scheduled triggers (close #1914) (#3553)

server: add scheduled triggers

Co-authored-by: Alexis King <lexi.lambda@gmail.com>
Co-authored-by: Marion Schleifer <marion@hasura.io>
Co-authored-by: Karthikeyan Chinnakonda <karthikeyan@hasura.io>
Co-authored-by: Aleksandra Sikora <ola.zxcvbnm@gmail.com>

* dev.sh: bump version due to addition of croniter python dependency

* server: fix an introspection query caching issue (fix #4547) (#4661)

Introspection queries accept variables, but we need to make sure to
also touch the variables that we ignore, so that an introspection
query is marked not reusable if we are not able to build a correct
query plan for it.

A better solution here would be to deal with such unused variables
correctly, so that more introspection queries become reusable.

An even better solution would be to type-safely track *how* to reuse
which variables, rather than to split the reusage marking from the
planning.

Co-authored-by: Tirumarai Selvan <tiru@hasura.io>

* flush log buffer on exception in mkWaiApp ( fix #4772 ) (#4801)

* flush log buffer on exception in mkWaiApp

* add comment to explain the introduced change

* add changelog

* allow logging details of a live query polling thread (#4959)

* changes for poller-log

add various multiplexed query info in poller-log

* minor cleanup, also fixes a bug which will return duplicate data

* Live query poller stats can now be logged

This also removes in-memory stats that are collected about batched
query execution as the log lines when piped into an monitoring tool
will give us better insights.

* allow poller-log to be configurable

* log minimal information in the livequery-poller-log

Other information can be retrieved from /dev/subscriptions/extended

* fix few review comments

* avoid marshalling and unmarshalling from ByteString to EncJSON

* separate out SubscriberId and SubscriberMetadata

Co-authored-by: Anon Ray <rayanon004@gmail.com>

* Don't compile in developer APIs by default

* Tighten up handling of admin secret, more docs

Store the admin secret only as a hash to prevent leaking the secret
inadvertently, and to prevent timing attacks on the secret.

NOTE: best practice for stored user passwords is a function with a
tunable cost like bcrypt, but our threat model is quite different (even
if we thought we could reasonably protect the secret from an attacker
who could read arbitrary regions of memory), and bcrypt is far too slow
(by design) to perform on each request. We'd have to rely on our
(technically savvy) users to choose high entropy passwords in any case.

Referencing #4736

* server/docs: add instructions to fix loss of float precision in PostgreSQL <= 11 (#5187)

This adds a server flag, --pg-connection-options, that can be used to set a PostgreSQL connection parameter, extra_float_digits, that needs to be used to avoid loss of data on older versions of PostgreSQL, which have odd default behavior when returning float values. (fixes #5092)

* [skip ci] Add new commits from master to the commit diff

* [skip ci] serve default directives (skip & include) over introspection

* [skip ci] Update non-Haskell assets with the version on master

* server: refactor GQL execution check and config API (#5094)

Co-authored-by: Vamshi Surabhi <vamshi@hasura.io>
Co-authored-by: Vamshi Surabhi <0x777@users.noreply.github.com>

* [skip ci] fix js issues in tests by pinning dependencies version

* [skip ci] bump graphql version

* [skip ci] Add note about memory usage

* generalize query execution logic on Postgres (#5110)

* generalize PGExecCtx to support specialized functions for various operations

* fix tests compilation

* allow customising PGExecCtx when starting the web server

* server: changes catalog initialization and logging for pro customization (#5139)

* new typeclass to abstract the logic of QueryLog-ing

* abstract the logic of logging websocket-server logs

  introduce a MonadWSLog typeclass

* move catalog initialization to init step

  expose a helper function to migrate catalog
  create schema cache in initialiseCtx

* expose various modules and functions for pro

* [skip ci] cosmetic change

* [skip ci] fix test calling a mutation that does not exist

* [skip ci] minor text change

* [skip ci] refactored input values

* [skip ci] remove VString Origin

* server: fix updating of headers behaviour in the update cron trigger API and create future events immediately (#5151)

* server: fix bug to update headers in an existing cron trigger and create future events

Co-authored-by: Tirumarai Selvan <tiru@hasura.io>

* Lower stack chunk size in RTS to reduce thread STACK memory (closes #5190)

This reduces memory consumption for new idle subscriptions significantly
(see linked ticket).

The hypothesis is: we fork a lot of threads per websocket, and some of
these use slightly more than the initial 1K stack size, so the first
overflow balloons to 32K, when significantly less is required.

However: running with `+RTS -K1K -xc` did not seem to show evidence of
any overflows! So it's a mystery why this improves things.

GHC should probably also be doubling the stack buffer at each overflow
or doing something even smarter; the knobs we have aren't so helpful.

* [skip ci] fix todo and schema generation for aggregate fields

* 5087 libpq pool leak (#5089)

Shrink libpq buffers to 1MB before returning connection to pool. Closes #5087

See: https://github.com/hasura/pg-client-hs/pull/19

Also related: #3388 #4077

* bump pg-client-hs version (fixes a build issue on some environments) (#5267)

* do not use prepared statements for mutations

* server: unlock scheduled events on graceful shutdown (#4928)

* Fix buggy parsing of new --conn-lifetime flag in 2b0e3774

* [skip ci] remove cherry-picked commit from commit_diff.txt

* server: include additional fields in scheduled trigger webhook payload (#5262)

* include scheduled triggers metadata in the webhook body

Co-authored-by: Tirumarai Selvan <tiru@hasura.io>

* server: call the webhook asynchronously in event triggers (#5352)

* server: call the webhook asynchronosly in event triggers

* Expose all modules in Cabal file (#5371)

* [skip ci] update commit_diff.txt

* [skip ci] fix cast exp parser & few TODOs

* [skip ci] fix remote fields arguments

* [skip ci] fix few more TODO, no-op refactor, move resolve/action.hs to execute/action.hs

* Pass environment variables around as a data structure, via @sordina (#5374)

* Pass environment variables around as a data structure, via @sordina

* Resolving build error

* Adding Environment passing note to changelog

* Removing references to ILTPollerLog as this seems to have been reintroduced from a bad merge

* removing commented-out imports

* Language pragmas already set by project

* Linking async thread

* Apply suggestions from code review

Use `runQueryTx` instead of `runLazyTx` for queries.

* remove the non-user facing entry in the changelog

Co-authored-by: Phil Freeman <paf31@cantab.net>
Co-authored-by: Phil Freeman <phil@hasura.io>
Co-authored-by: Vamshi Surabhi <0x777@users.noreply.github.com>

* [skip ci] fix: restrict remote relationship field generation for hasura queries

* [skip ci] no-op refactor; move insert execution code from schema parser module

* server: call the webhook asynchronously in event triggers (#5352)

* server: call the webhook asynchronosly in event triggers

* Expose all modules in Cabal file (#5371)

* [skip ci] update commit_diff.txt

* Pass environment variables around as a data structure, via @sordina (#5374)

* Pass environment variables around as a data structure, via @sordina

* Resolving build error

* Adding Environment passing note to changelog

* Removing references to ILTPollerLog as this seems to have been reintroduced from a bad merge

* removing commented-out imports

* Language pragmas already set by project

* Linking async thread

* Apply suggestions from code review

Use `runQueryTx` instead of `runLazyTx` for queries.

* remove the non-user facing entry in the changelog

Co-authored-by: Phil Freeman <paf31@cantab.net>
Co-authored-by: Phil Freeman <phil@hasura.io>
Co-authored-by: Vamshi Surabhi <0x777@users.noreply.github.com>

* [skip ci] implement header checking

Probably closes #14 and #3659.

* server: refactor 'pollQuery' to have a hook to process 'PollDetails' (#5391)

Co-authored-by: Vamshi Surabhi <0x777@users.noreply.github.com>

* update pg-client (#5421)

* [skip ci] update commit_diff

* Fix latency buckets for telemetry data

These must have gotten messed up during a refactor. As a consequence
almost all samples received so far fall into the single erroneous 0 to
1K seconds (originally supposed to be 1ms?) bucket.

I also re-thought what the numbers should be, but these are still
arbitrary and might want adjusting in the future.

* [skip ci] include the latest commit compared against master in commit_diff

* [skip ci] include new commits from master in commit_diff

* [skip ci] improve description generation

* [skip ci] sort all introspect arrays

* [skip ci] allow parsers to specify error codes

* [skip ci] fix integer and float parsing error code

* [skip ci] scalar from json errors are now parse errors

* [skip ci] fixed negative integer error message and code

* [skip ci] Re-fix nullability in relationships

* [skip ci] no-op refactor and removed couple of FIXMEs

* [skip ci] uncomment code in 'deleteMetadataObject'

* [skip ci] Fix re-fix of nullability for relationships

* [skip ci] fix default arguments error code

* [skip ci] updated test error message

!!! WARNING !!!
Since all fields accept `null`, they all are technically optional in
the new schema. Meaning there's no such thing as a missing mandatory
field anymore: a field that doesn't have a default value, and which
therefore isn't labelled as "optional" in the schema, will be assumed
to be null if it's missing, meaning it isn't possible anymore to have
an error for a missing mandatory field. The only possible error is now
when a optional positional argument is omitted but is not the last
positional argument.

* [skip ci] cleanup of int scalar parser

* [skip ci] retro-compatibility of offset as string

* [skip ci] Remove commit from commit_diff.txt

Although strictly speaking we don't know if this will work correctly in PDV
if we would implement query plan caching, the fact is that in the theoretical
case that we would have the same issue in PDV, it would probably apply not just
to introspection, and the fix would be written completely differently.  So this
old commit is of no value to us other than the heads-up "make sure query plan
caching works correctly even in the presence of unused variables", which is
already part of the test suite.

* Add MonadTrace and MonadExecuteQuery abstractions (#5383)

* [skip ci] Fix accumulation of input object types

Just like object types, interface types, and union types, we have to avoid
circularities when collecting input types from the GraphQL AST.

Additionally, this fixes equality checks for input object types (whose fields
are unordered, and hence should be compared as sets) and enum types (ditto).

* [skip ci] fix fragment error path

* [skip ci] fix node error code

* [skip ci] fix paths in insert queries

* [skip ci] fix path in objects

* [skip ci] manually alter node id path for consistency

* [skip ci] more node error fixups

* [skip ci] one last relay error message fix

* [skip ci] update commit_diff

* Propagate the trace context to event triggers (#5409)

* Propagate the trace context to event triggers

* Handle missing trace and span IDs

* Store trace context as one LOCAL

* Add migrations

* Documentation

* changelog

* Fix warnings

* Respond to code review suggestions

* Respond to code review

* Undo changelog

* Update CHANGELOG.md

Co-authored-by: Vamshi Surabhi <0x777@users.noreply.github.com>

* server: log request/response sizes for event triggers (#5463)

* server: log request/response sizes for event triggers

  event triggers (and scheduled triggers) now have request/response size
  in their logs.

* add changelog entry

* Tracing: Simplify HTTP traced request (#5451)

Remove the Inversion of Control (SuspendRequest) and simplify
the tracing of HTTP Requests.

Co-authored-by: Phil Freeman <phil@hasura.io>

* Attach request ID as tracing metadata (#5456)

* Propagate the trace context to event triggers

* Handle missing trace and span IDs

* Store trace context as one LOCAL

* Add migrations

* Documentation

* Include the request ID as trace metadata

* changelog

* Fix warnings

* Respond to code review suggestions

* Respond to code review

* Undo changelog

* Update CHANGELOG.md

* Typo

Co-authored-by: Vamshi Surabhi <0x777@users.noreply.github.com>

* server: add logging for action handlers (#5471)

* server: add logging for action handlers

* add changelog entry

* change action-handler log type from internal to non-internal

* fix action-handler-log name

* server: pass http and websocket request to logging context (#5470)

* pass request body to logging context in all cases

* add message size logging on the websocket API

  this is required by graphql-engine-pro/#416

* message size logging on websocket API

  As we need to log all messages recieved/sent by the websocket server,
  it makes sense to log them as part of the websocket server event logs.
  Previously message recieved were logged inside the onMessage handler,
  and messages sent were logged only for "data" messages (as a server event log)

* fix review comments

Co-authored-by: Phil Freeman <phil@hasura.io>

* server: stop eventing subsystem threads when shutting down (#5479)

* server: stop eventing subsystem threads when shutting down

* Apply suggestions from code review

Co-authored-by: Karthikeyan Chinnakonda <chkarthikeyan95@gmail.com>

Co-authored-by: Phil Freeman <phil@hasura.io>
Co-authored-by: Phil Freeman <paf31@cantab.net>
Co-authored-by: Karthikeyan Chinnakonda <chkarthikeyan95@gmail.com>

* [skip ci] update commit_diff with new commits added in master

* Bugfix to support 0-size HASURA_GRAPHQL_QUERY_PLAN_CACHE_SIZE

Also some minor refactoring of bounded cache module:
 - the maxBound check in `trim` was confusing and unnecessary
 - consequently trim was unnecessary for lookupPure

Also add some basic tests

* Support only the bounded cache, with default HASURA_GRAPHQL_QUERY_PLAN_CACHE_SIZE of 4000. Closes #5363

* [skip ci] remove merge commit from commit_diff

* server: Fix compiler warning caused by GHC upgrade (#5489)

Co-authored-by: Vamshi Surabhi <0x777@users.noreply.github.com>

* [skip ci] update all non server code from master

* [skip ci] aligned object field error message with master

* [skip ci] fix remaining undefined?

* [skip ci] remove unused import

* [skip ci] revert to previous error message, fix tests

* Move nullableType/nonNullableType to Schema.hs

These are functions on Types, not on Parsers.

* [skip ci] fix setup to fix backend only test

the order in which permission checks are performed on the branch is
slightly different than on master, resulting in a slightly different
error if there are no other mutations the user has access to. By
adding update permissions, we go back to the expected case.

* [skip ci] fix insert geojson tests to reflect new paths

* [skip ci] fix enum test for better error message

* [skip ci] fix header test for better error message

* [skip ci] fix fragment cycle test for better error message

* [skip ci] fix error message for type mismatch

* [skip ci] fix variable path in test

* [skip ci] adjust tests after bug fix

* [skip ci] more tests fixing

* Add hdb_catalog.current_setting abstraction for reading Hasura settings

As the comment in the function’s definition explains, this is needed to
work around an awkward Postgres behavior.

* [skip ci] Update CONTRIBUTING.md to mention Node setup for Python tests

* [skip ci] Add missing Python tests env var to CONTRIBUTING.md

* [skip ci] fix order of result when subscription is run with multiple nodes

* [skip ci] no-op refactor: fix a warning in Internal/Parser.hs

* [skip ci] throw error when a subscription contains remote joins

* [skip ci] Enable easier profiling by hiding AssertNF behind a flag

In order to compile a profiling build, run:

$ cabal new-build -f profiling --enable-profiling

* [skip ci] Fix two warnings

We used to lookup the objects that implement a given interface by filtering all
objects in the schema document.  However, one of the tests expects us to
generate a warning if the provided `implements` field of an introspection query
specifies an object not implementing some interface.  So we use that field
instead.

* [skip ci] Fix warnings by commenting out query plan caching

* [skip ci] improve masking/commenting query caching related code & few warning fixes

* [skip ci] Fixed compiler warnings in graphql-parser-hs

* Sync non-Haskell assets with master

* [skip ci] add a test inserting invalid GraphQL but valid JSON value in a jsonb column

* [skip ci] Avoid converting to/from Map

* [skip ci] Apply some hlint suggestions

* [skip ci] remove redundant constraints from buildLiveQueryPlan and explainGQLQuery

* [skip ci] add NOTEs about missing Tracing constraints in PDV from master

* Remove -fdefer-typed-holes, fix warnings

* Update cabal.project.freeze

* Limit GHC’s heap size to 8GB in CI to avoid the OOM killer

* Commit package-lock.json for Python tests’ remote schema server

* restrict env variables start with HASURA_GRAPHQL_ for headers configuration in actions, event triggers & remote schemas (#5519)

* restrict env variables start with HASURA_GRAPHQL_ for headers definition in actions & event triggers

* update CHANGELOG.md

* Apply suggestions from code review

Co-authored-by: Vamshi Surabhi <0x777@users.noreply.github.com>

* add test for table_by_pk node when roles doesn't have permission to PK

* [skip ci] fix introspection query if any enum column present in primary key (fix #5200) (#5522)

* [skip ci] test case fix for a6450e126b

* [skip ci] add tests to agg queries when role doesn't have access to any cols

* fix backend test

* Simplify subscription execution

* [skip ci] add test to check if required headers are present while querying

* Suppose, table B is related to table A and to query B certain headers are
  necessary, then the test checks that we are throwing error when the header
  is not set when B is queried through A

* fix mutations not checking for view mutability

* [skip ci] add variable type checking and corresponding tests

* [skip ci] add test to check if update headers are present while doing an upsert

* [skip ci] add positive counterparts to some of the negative permission tests

* fix args missing their description in introspect

* [skip ci] Remove unused function; insert missing markNotReusable call

* [skip ci] Add a Note about InputValue

* [skip ci] Delete LegacySchema/ 🎉

* [skip ci] Delete GraphQL/{Resolve,Validate}/ 🎉

* [skip ci] Delete top-level Resolve/Validate modules; tidy .cabal file

* [skip ci] Delete LegacySchema top-level module

Somehow I missed this one.

* fix input value to json

* [skip ci] elaborate on JSON objects in GraphQL

* [skip ci] add missing file

* [skip ci] add a test with subscription containing remote joins

* add a test with remote joins in mutation output

* [skip ci] Add some comments to Schema/Mutation.hs

* [skip ci] Remove no longer needed code from RemoteServer.hs

* [skip ci] Use a helper function to generate conflict clause parsers

* [skip ci] fix type checker error in fields with default value

* capitalize the header keys in select_articles_without_required_headers

* Somehow, this was the reason the tests were failing. I have no idea, why!

* [skip ci] Add a long Note about optional fields and nullability

* Improve comments a bit; simplify Schema/Common.hs a bit

* [skip ci] full implementation of 5.8.5 type checking.

* [skip ci] fix validation test teardown

* [skip ci] fix schema stitching test

* fix remote schema ignoring enum nullability

* [skip ci] fix fieldOptional to not discard nullability

* revert nullability of use_spheroid

* fix comment

* add required remote fields with arguments for tests

* [skip ci] add missing docstrings

* [skip ci] fixed description of remote fields

* [skip ci] change docstring for consistency

* fix several schema inconsistencies

* revert behaviour change in function arguments parsing

* fix remaining nullability issues in new schema

* minor no-op refactor; use isListType from graphql-parser-hs

* use nullability of remote schema node, while creating a Remote reln

* fix 'ID' input coercing & action 'ID' type relationship mapping

* include ASTs in MonadExecuteQuery

* needed for PRO code-base

* Delete code for "interfaces implementing ifaces" (draft GraphQL spec)

Previously I started writing some code that adds support for a future GraphQL
feature where interfaces may themselves be sub-types of other interfaces.
However, this code was incomplete, and partially incorrect.  So this commit
deletes support for that entirely.

* Ignore a remote schema test during the upgrade/downgrade test

The PDV refactor does a better job at exposing a minimal set of types through
introspection.  In particular, not every type that is present in a remote schema
is re-exposed by Hasura.  The test
test_schema_stitching.py::TestRemoteSchemaBasic::test_introspection assumed that
all types were re-exposed, which is not required for GraphQL compatibility, in
order to test some aspect of our support for remote schemas.

So while this particular test has been updated on PDV, the PDV branch now does
not pass the old test, which we argue to be incorrect.  Hence this test is
disabled while we await a release, after which we can re-enable it.

This also re-enables a test that was previously disabled for similar, though
unrelated, reasons.

* add haddock documentation to the action's field parsers

* Deslecting some tests in server-upgrade

Some tests with current build are failing on server upgrade
which it should not. The response is more accurate than
what it was.

Also the upgrade tests were not throwing errors when the test is
expected to return an error, but succeeds. The test framework is
patched to catch this case.

* [skip ci] Add a long Note about interfaces and object types

* send the response headers back to client after running a query

* Deselect a few more tests during upgrade/downgrade test

* Update commit_diff.txt

* change log kind from db_migrate to catalog_migrate (#5531)

* Show method and complete URI in traced HTTP calls (#5525)

Co-authored-by: Vamshi Surabhi <0x777@users.noreply.github.com>

* restrict env variables start with HASURA_GRAPHQL_ for headers configuration in actions, event triggers & remote schemas (#5519)

* restrict env variables start with HASURA_GRAPHQL_ for headers definition in actions & event triggers

* update CHANGELOG.md

* Apply suggestions from code review

Co-authored-by: Vamshi Surabhi <0x777@users.noreply.github.com>

* fix introspection query if any enum column present in primary key (fix #5200) (#5522)

* Fix telemetry reporting of transport (websocket was reported as http)

* add log kinds in cli-migrations image (#5529)

* add log kinds in cli-migrations image

* give hint to resolve timeout error

* minor changes and CHANGELOG

* server: set hasura.tracecontext in RQL mutations [#5542] (#5555)

* server: set hasura.tracecontext in RQL mutations [#5542]

* Update test suite

Co-authored-by: Tirumarai Selvan <tiru@hasura.io>

* Add bulldozer auto-merge and -update configuration

We still need to add the github app (as of time of opening this PR)

Afterwards devs should be able to allow bulldozer to automatically
"update" the branch, merging in parent when it changes, as well as
automatically merge when all checks pass.

This is opt-in by adding the `auto-update-auto-merge` label to the PR.

* Remove 'bulldozer' config, try 'kodiak' for auto-merge

see: https://github.com/chdsbd/kodiak

The main issue that bit us was not being able to auto update forked
branches, also:
https://github.com/palantir/bulldozer/issues/66
https://github.com/palantir/bulldozer/issues/145

* Cherry-picked all commits

* [skip ci] Slightly improve formatting

* Revert "fix introspection query if any enum column present in primary key (fix #5200) (#5522)"

This reverts commit 0f9a5afa59.

This undoes a cherry-pick of 34288e1eb5 that was
already done previously in a6450e126b, and
subsequently fixed for PDV in 70e89dc250

* Do a small bit of tidying in Hasura.GraphQL.Parser.Collect

* Fix cherry-picking work

Some previous cherry-picks ended up modifying code that is commented out

* [skip ci] clarified comment regarding insert representation

* [skip ci] removed obsolete todos

* cosmetic change

* fix action error message

* [skip ci] remove obsolete comment

* [skip ci] synchronize stylish haskell extensions list

* use previously defined scalar names in parsers rather than ad-hoc literals

* Apply most syntax hlint hints.

* Clarify comment on update mutation.

* [skip ci] Clarify what fields should be specified for objects

* Update "_inc" description.

* Use record types rather than tuples fo IntrospectionResult and ParsedIntrospection

* Get rid of checkFieldNamesUnique (use Data.List.Extended.duplicates)

* Throw more errors when collecting query root names

* [skip ci] clean column parser comment

* Remove dead code inserted in ab65b39

* avoid converting to non-empty list where not needed

* add note and TODO about the disabled checks in PDV

* minor refactor in remoteField' function

* Unify two getObject methods

* Nitpicks in Remote.hs

* Update CHANGELOG.md

* Revert "Unify two getObject methods"

This reverts commit bd6bb40355.

We do need two different getObject functions as the corresponding error message is different

* Fix error message in Remote.hs

* Update CHANGELOG.md

Co-authored-by: Auke Booij <auke@tulcod.com>

* Apply suggested Changelog fix.

Co-authored-by: Auke Booij <auke@tulcod.com>

* Fix typo in Changelog.

* [skip ci] Update changelog.

* reuse type names to avoid duplication

* Fix Hashable instance for Definition

The presence of `Maybe Unique`, and an optional description, as part of
`Definition`s, means that `Definition`s that are considered `Eq`ual may get
different hashes.  This can happen, for instance, when one object is memoized
but another is not.

* [skip ci] Update commit_diff.txt

* Bump parser version.

* Bump freeze file after changes in parser.

* [skip ci] Incorporate commits from master

* Fix developer flag in server/cabal.project.freeze

Co-authored-by: Auke Booij <auke@tulcod.com>

* Deselect a changed ENUM test for upgrade/downgrade CI

* Deselect test here as well

* [skip ci] remove dead code

* Disable more tests for upgrade/downgrade

* Fix which test gets deselected

* Revert "Add hdb_catalog.current_setting abstraction for reading Hasura settings"

This reverts commit 66e85ab9fb.

* Remove circular reference in cabal.project.freeze

Co-authored-by: Karthikeyan Chinnakonda <karthikeyan@hasura.io>
Co-authored-by: Auke Booij <auke@hasura.io>
Co-authored-by: Tirumarai Selvan <tiru@hasura.io>
Co-authored-by: Marion Schleifer <marion@hasura.io>
Co-authored-by: Aleksandra Sikora <ola.zxcvbnm@gmail.com>
Co-authored-by: Brandon Simmons <brandon.m.simmons@gmail.com>
Co-authored-by: Vamshi Surabhi <0x777@users.noreply.github.com>
Co-authored-by: Anon Ray <rayanon004@gmail.com>
Co-authored-by: rakeshkky <12475069+rakeshkky@users.noreply.github.com>
Co-authored-by: Anon Ray <ecthiender@users.noreply.github.com>
Co-authored-by: Vamshi Surabhi <vamshi@hasura.io>
Co-authored-by: Antoine Leblanc <antoine@hasura.io>
Co-authored-by: Brandon Simmons <brandon@hasura.io>
Co-authored-by: Phil Freeman <phil@hasura.io>
Co-authored-by: Lyndon Maydwell <lyndon@sordina.net>
Co-authored-by: Phil Freeman <paf31@cantab.net>
Co-authored-by: Naveen Naidu <naveennaidu479@gmail.com>
Co-authored-by: Karthikeyan Chinnakonda <chkarthikeyan95@gmail.com>
Co-authored-by: Nizar Malangadan <nizar-m@users.noreply.github.com>
Co-authored-by: Antoine Leblanc <crucuny@gmail.com>
Co-authored-by: Auke Booij <auke@tulcod.com>
2020-08-21 12:27:01 -05:00
Karthikeyan Chinnakonda
bf2de78ea3 server: don't throw validation error when joining singleton type to array type 2020-08-17 14:51:11 +05:30
Rakesh Emmadi
34288e1eb5
fix introspection query if any enum column present in primary key (fix #5200) (#5522) 2020-08-05 19:38:36 +05:30
Rakesh Emmadi
cfd7944849
restrict env variables start with HASURA_GRAPHQL_ for headers configuration in actions, event triggers & remote schemas (#5519)
* restrict env variables start with HASURA_GRAPHQL_ for headers definition in actions & event triggers

* update CHANGELOG.md

* Apply suggestions from code review

Co-authored-by: Vamshi Surabhi <0x777@users.noreply.github.com>
2020-08-05 18:44:53 +05:30
Karthikeyan Chinnakonda
0ef52292b5
server: call the webhook asynchronously in event triggers (#5352)
* server: call the webhook asynchronosly in event triggers
2020-07-10 22:17:05 +05:30
Rakesh Emmadi
2fe353a294
allow array relation connection fields regardless of aggregation permission & change relay endpoint to '/v1beta1/relay' (fix #5218) (#5257)
* fix error when array relation connections are queried, fix #5218

* change relay endpoint to '/v1beta1/relay'

* Update CHANGELOG.md

Co-authored-by: Tirumarai Selvan <tiru@hasura.io>
2020-07-03 12:00:35 +05:30
Karthikeyan Chinnakonda
9ef6de5113
server: include additional fields in scheduled trigger webhook payload (#5262)
* include scheduled triggers metadata in the webhook body

Co-authored-by: Tirumarai Selvan <tiru@hasura.io>
2020-07-03 06:25:07 +05:30
Rakesh Emmadi
8b49f472a2
fix postgres query error for object relationship with permission limit, fix #5148 (#5177)
Co-authored-by: Tirumarai Selvan <tiru@hasura.io>
2020-06-25 09:03:37 +05:30
Rakesh Emmadi
c7ffd882d0
fix relay introspection when remote relationships are defined, fix #5144 (#5145)
Co-authored-by: Tirumarai Selvan <tiru@hasura.io>
2020-06-24 19:25:50 +05:30
Karthikeyan Chinnakonda
6a58c144f5
server: fix updating of headers behaviour in the update cron trigger API and create future events immediately (#5151)
* server: fix bug to update headers in an existing cron trigger and create future events

Co-authored-by: Tirumarai Selvan <tiru@hasura.io>
2020-06-23 20:51:34 +05:30
Rakesh Emmadi
ea23571049
fix introspection faling when multiple actions defined with PG scalar types (fix #5166) (#5173)
Introspection query is failing with `type info not found for xxxx` error message if multiple actions are defined with reused PG scalars. The fix for the same.
2020-06-23 15:35:54 +05:30
Karthikeyan Chinnakonda
d064959ac3
server: drop catalog dependencies when parent column/table is dropped containing a remote relationship (#5119) 2020-06-17 13:18:31 +05:30
Rakesh Emmadi
4e229dc568
relay fixes (#5013)
* fix relay introspection failing if any views exist, fix #5020

* reduce base64 encoded node id length, close #5037

* make node field type non-nullable in an edge

* more relay tests with permissions & complete restructure of test yaml files

Co-authored-by: Aravind <aravindkp@outlook.in>
Co-authored-by: Vamshi Surabhi <0x777@users.noreply.github.com>
2020-06-16 19:55:49 +05:30
Brandon Simmons
cf8cf4f5aa
Merge branch 'master' into 4736-security-testing 2020-06-09 10:50:35 -04:00
Karthikeyan Chinnakonda
b782986e48
fix bug which arised when renaming a column/table if it was used to create the remote relationship (#5005) 2020-06-09 19:59:39 +05:30
Brandon Simmons
5e37350561 Refactor and unit test authentication code paths (closes #4736)
The bulk of changes here is some shifting of code around and a little
parameterizing of functions for easier testing.

Also: comments, some renaming for clarity/less-chance-for-misue.
2020-06-08 13:10:58 -04:00
Vamshi Surabhi
2a9bc2354f
add relay modern support (#4458)
* validation support for unions and interfaces

* refactor SQL generation logic for improved readability

* '/v1/relay' endpoint for relay schema

* implement 'Node' interface and top level 'node' field resolver

* add relay toggle on graphiql

* fix explain api response & index plan id with query type

* add hasura mutations to relay

* add relay pytests

* update CHANGELOG.md

Co-authored-by: rakeshkky <12475069+rakeshkky@users.noreply.github.com>
Co-authored-by: Rishichandra Wawhal <rishi@hasura.io>
Co-authored-by: Rikin Kachhia <54616969+rikinsk@users.noreply.github.com>
2020-06-08 17:43:01 +05:30
Karthikeyan Chinnakonda
d6de3592ed
actions: fix behaviour when using remote relationship in mutation action's relationship (#4982)
* resolve the remote server when a remote join query used in action mutation
2020-06-05 17:33:18 +05:30
Tirumarai Selvan
c0d2bc6653
Remote Joins: Create relationships across database and remote schemas (#2392)
add remote joins: Create relationships across database and remote schemas (#2392)

Co-authored-by: Aleksandra Sikora <ola.zxcvbnm@gmail.com>

Co-authored-by: Chris Done <chrisdone@gmail.com>
Co-authored-by: Chris Done <github@chrisdone.com>
Co-authored-by: wawhal <rishichandra.wawhal@gmail.com>
Co-authored-by: Aravind Shankar <aravind@hasura.io>
Co-authored-by: Brandon Simmons <brandon.m.simmons@gmail.com>
Co-authored-by: Rishichandra Wawhal <rishi@hasura.io>
Co-authored-by: Brandon Simmons <brandon@hasura.io>
Co-authored-by: nizar-m <19857260+nizar-m@users.noreply.github.com>
Co-authored-by: Praveen Durairaju <praveend.web@gmail.com>
Co-authored-by: rakeshkky <12475069+rakeshkky@users.noreply.github.com>
Co-authored-by: Anon Ray <rayanon004@gmail.com>
Co-authored-by: Shahidh K Muhammed <shahidh@hasura.io>
Co-authored-by: soorajshankar <soorajshankar@users.noreply.github.com>
Co-authored-by: Sooraj Sanker <sooraj@Soorajs-MacBook-Pro.local>
Co-authored-by: Karthikeyan Chinnakonda <karthikeyan@hasura.io>
Co-authored-by: Aleksandra Sikora <ola.zxcvbnm@gmail.com>
2020-05-27 20:32:58 +05:30
rakeshkky
e347ef3e45 fix explain queries with role permissions, fix #4816 2020-05-22 14:40:57 +05:30
Vamshi Surabhi
ff99b24031 fix a security issue with 1.2 2020-05-22 14:40:57 +05:30
Karthikeyan Chinnakonda
ac3076796c
Allowlist metadata Import bug (#4762)
fix bug which was not allowing the allowlist to be imported
2020-05-20 11:46:26 +05:30
Auke Booij
20cbe9cfd3
server: fix an introspection query caching issue (fix #4547) (#4661)
Introspection queries accept variables, but we need to make sure to
also touch the variables that we ignore, so that an introspection
query is marked not reusable if we are not able to build a correct
query plan for it.

A better solution here would be to deal with such unused variables
correctly, so that more introspection queries become reusable.

An even better solution would be to type-safely track *how* to reuse
which variables, rather than to split the reusage marking from the
planning.

Co-authored-by: Tirumarai Selvan <tiru@hasura.io>
2020-05-18 14:27:56 +02:00
Tirumarai Selvan
cc8e2ccc78
Scheduled triggers (close #1914) (#3553)
server: add scheduled triggers 

Co-authored-by: Alexis King <lexi.lambda@gmail.com>
Co-authored-by: Marion Schleifer <marion@hasura.io>
Co-authored-by: Karthikeyan Chinnakonda <karthikeyan@hasura.io>
Co-authored-by: Aleksandra Sikora <ola.zxcvbnm@gmail.com>
2020-05-13 18:03:16 +05:30
Auke Booij
2735d284c1
server: use a new version of graphql-parser-hs to avoid loss of precision (#4741)
Fixes #4733.  See also hasura/graphql-parser-hs#29.
2020-05-13 12:10:46 +02:00
Auke Booij
4d10a610f4
server: fix mishandling of GeoJSON inputs in subscriptions (fix #3239) (#4551)
* Add support for multiple top-level fields in a subscription to improve testability of subscriptions

* Add an internal flag to enable multiple subscriptions

* Add missing call to withConstructorFn in live queries (fix #3239)

Co-authored-by: Alexis King <lexi.lambda@gmail.com>
2020-05-13 10:09:44 +02:00
Auke Booij
ad882a93e2
tests: tear down numerics values (fix #4602) (#4604)
Also temporarily disable part of the CI to avoid it becoming confused about tests for/from old versions
2020-04-29 16:56:16 +02:00
Auke Booij
ee7c7b1672
server: allow computed fields to have access to Hasura's session variables (fix #3846) (#4486)
* Allow computed fields to have access to Hasura's session variables

* Inform about session args for computed fields in changelog and docs

* Add tests for session arguments for computed fields (and the respective errors)

Co-authored-by: Tirumarai Selvan <tiru@hasura.io>
Co-authored-by: Marion Schleifer <marion@hasura.io>
Co-authored-by: Rakesh Emmadi <12475069+rakeshkky@users.noreply.github.com>
2020-04-27 17:07:03 +02:00
Rakesh Emmadi
d52bfcda4e
backend only insert permissions (rfc #4120) (#4224)
* move user info related code to Hasura.User module

* the RFC #4120 implementation; insert permissions with admin secret

* revert back to old RoleName based schema maps

An attempt made to avoid duplication of schema contexts in types
if any role doesn't possess any admin secret specific schema

* fix compile errors in haskell test

* keep 'user_vars' for session variables in http-logs

* no-op refacto

* tests for admin only inserts

* update docs for admin only inserts

* updated CHANGELOG.md

* default behaviour when admin secret is not set

* fix x-hasura-role to X-Hasura-Role in pytests

* introduce effective timeout in actions async tests

* update docs for admin-secret not configured case

* Update docs/graphql/manual/api-reference/schema-metadata-api/permission.rst

Co-Authored-By: Marion Schleifer <marion@hasura.io>

* Apply suggestions from code review

Co-Authored-By: Marion Schleifer <marion@hasura.io>

* a complete iteration

backend insert permissions accessable via 'x-hasura-backend-privilege'
session variable

* console changes for backend-only permissions

* provide tooltip id; update labels and tooltips;

* requested changes

* requested changes

- remove className from Toggle component
- use appropriate function name (capitalizeFirstChar -> capitalize)

* use toggle props from definitelyTyped

* fix accidental commit

* Revert "introduce effective timeout in actions async tests"

This reverts commit b7a59c19d6.

* generate complete schema for both 'default' and 'backend' sessions

* Apply suggestions from code review

Co-Authored-By: Marion Schleifer <marion@hasura.io>

* remove unnecessary import, export Toggle as is

* update session variable in tooltip

* 'x-hasura-use-backend-only-permissions' variable to switch

* update help texts

* update docs

* update docs

* update console help text

* regenerate package-lock

* serve no backend schema when backend_only: false and header set to true

- Few type name refactor as suggested by @0x777

* update CHANGELOG.md

* Update CHANGELOG.md

* Update CHANGELOG.md

* fix a merge bug where a certain entity didn't get removed

Co-authored-by: Marion Schleifer <marion@hasura.io>
Co-authored-by: Rishichandra Wawhal <rishi@hasura.io>
Co-authored-by: rikinsk <rikin.kachhia@gmail.com>
Co-authored-by: Tirumarai Selvan <tiru@hasura.io>
2020-04-24 14:40:53 +05:30
Rakesh Emmadi
6f100e0009
improve debug information in actions errors response (close #4031) (#4432)
* config options for internal errors for non-admin role, close #4031

More detailed action debug info is added in response 'internal' field

* add docs

* update CHANGELOG.md

* set admin graphql errors option in ci tests, minor changes to docs

* fix tests

Don't use any auth for sync actions error tests. The request body
changes based on auth type in session_variables (x-hasura-auth-mode)

* Apply suggestions from code review

Co-Authored-By: Marion Schleifer <marion@hasura.io>

* use a new sum type to represent the inclusion of internal errors

As suggested in review by @0x777
-> Move around few modules in to specific API folder
-> Saperate types from Init.hs

* fix tests

Don't use any auth for sync actions error tests. The request body
changes based on auth type in session_variables (x-hasura-auth-mode)

* move 'HttpResponse' to 'Hasura.HTTP' module

* update change log with breaking change warning

* Update CHANGELOG.md

Co-authored-by: Marion Schleifer <marion@hasura.io>
Co-authored-by: Tirumarai Selvan <tiru@hasura.io>
2020-04-24 13:25:51 +05:30
Karthikeyan Chinnakonda
a8affc2cda
fix intermittent errors occur when query actions used with variables (#4527)
* don't add query actions to the plan cache

Co-authored-by: rakeshkky <12475069+rakeshkky@users.noreply.github.com>
2020-04-24 11:39:00 +05:30
Rakesh Emmadi
b51a8ece4d
fix creating relationships for custom object types with fields reusing Postgres scalars (fix #4447) (#4455)
* fix creating relationships for custom object types with fields reusing Postgres scalars, close #4447

* fix changelog entry

* rearrange entries

Co-authored-by: Tirumarai Selvan <tiru@hasura.io>
2020-04-24 10:58:42 +05:30
Rakesh Emmadi
e983b1596e
fix recreating action's permission, fix #4377 (#4495)
Co-authored-by: Vamshi Surabhi <0x777@users.noreply.github.com>
2020-04-22 11:29:14 +05:30
Auke Booij
b2ad3ee2ee
server: avoid integer overflows (fix #576) (fix #4368) (#4435)
* Update graphql-parser-hs and hence use `Scientific` directly

The new version of graphql-parser-hs returns Scientific and Integer
rather than Double and Int32, respectively.  So we now need to do less
work in graphql-engine, and we can process larger numbers.

In practice, this means that when inserting a bigint, we no longer
need to specify the inserted integer as text.  This is also
represented in the updated tests.

* Generate int overflow error on insert

* Document bigint insertion support in changelog
2020-04-21 15:56:15 +02:00
Auke Booij
cd2e09c6ad
server: add support for timestamps without timezone to graphql-engine (fix #1217) (#4452)
* Add support for timestamps without timezone to graphql-engine

* Add tests for aggregations on timestamps without timezones
2020-04-21 14:30:48 +02:00
Rakesh Emmadi
9b7781ee6b
introduce effective timeout in actions async tests (#4363)
Co-authored-by: Vamshi Surabhi <0x777@users.noreply.github.com>
Co-authored-by: Tirumarai Selvan <tiru@hasura.io>
2020-04-21 15:55:56 +05:30
Auke Booij
82cdad1556
Link to pytest docs in the server test suite READMEs (#4425) 2020-04-21 11:29:16 +02:00
Karthikeyan Chinnakonda
ced6275ff0
add additional tests for testing claims_namespace_path in JWT tokens (#4481)
* add additional tests for testing claims_namespace_path in JWT tokens

- add tests for at root level and at a nested level

* modify the JWT tests

* combine the claims_namespace_path tests together in test-server.sh

* change the order of the claims_namespace_path tests

* change the order of the claims_namespace_path tests
2020-04-21 14:54:35 +05:30
Toan Nguyen
5f84669568
server: support single $ as root json path (#4482)
* support single $ json path

* support sql query with root json path

* update changelog

* update changelog

Co-authored-by: Karthikeyan Chinnakonda <karthikeyan@hasura.io>
Co-authored-by: Tirumarai Selvan <tiru@hasura.io>
2020-04-21 13:36:11 +05:30
Toan Nguyen
15c0ebf1ef
allow special characters in json path's property name (close #3890) (#3892)
* allow underscore prefix and special characters in json path

* server: Rewrite/refactor JSONPath parser

The JSONPath parser is also rewritten, the previous implementation
was written in a very explicitly “recursive descent” style, but the whole
point of using attoparsec is to be able to backtrack! Taking advantage
of the combinators makes for a much simpler parser.

Co-authored-by: Vamshi Surabhi <0x777@users.noreply.github.com>
Co-authored-by: Alexis King <lexi.lambda@gmail.com>
Co-authored-by: Aleksandra Sikora <ola.zxcvbnm@gmail.com>
Co-authored-by: Shahidh K Muhammed <shahidh@hasura.io>
2020-04-20 14:25:09 +05:30
Auke Booij
b2d65d16d3
server: _inc for non-integer numeric types (fix #3573) (#4429)
* Allow `_inc` to update other numeric types in addition to integers

* Add support for PostgreSQL's `money` field type

* Add support for _inc on money types

* Add note of generalized `_inc` support to changelog
2020-04-17 11:32:09 +02:00
Karthikeyan Chinnakonda
5116e16e18
server(actions): add support for queries (close #4032) (#4309)
* add support for action queries

* a new parameter `type` is added in the ArgumentDefinition, its value
  can be either `query` or `mutation` and it defaults to the latter

* throw 400 when a query action is tried to explain

* update the actions docs to include query actions

* refactor the ToJSON and ToOrdJSON of ActionDefinition

Co-authored-by: Rishichandra Wawhal <rishi@hasura.io>
Co-authored-by: Tirumarai Selvan <tiru@hasura.io>
2020-04-16 12:55:19 +05:30
Karthikeyan Chinnakonda
a26bc80496
accept a new argument claims_namespace_path in JWT config (#4365)
* add new optional field `claims_namespace_path` in JWT config

* return value when empty array is found in executeJSONPath

* update the docs related to claims_namespace_path

* improve encodeJSONPath, add property tests for parseJSONPath

* throw error if both claims_namespace_path and claims_namespace are set

* refactor the Data.Parser.JsonPath to Data.Parser.JSONPathSpec

* update the JWT docs

Co-Authored-By: Marion Schleifer <marion@hasura.io>

Co-authored-by: Marion Schleifer <marion@hasura.io>
Co-authored-by: rakeshkky <12475069+rakeshkky@users.noreply.github.com>
Co-authored-by: Tirumarai Selvan <tirumarai.selvan@gmail.com>
2020-04-16 12:15:21 +05:30
Auke Booij
dbf0c43ca8
server: Avoid duplicated test runs (#4420)
This avoids re-running tests when a parameterized test is specified
that doesn't actually depend on its parameter.
2020-04-15 11:13:53 -05:00
Rakesh Emmadi
dc31b835e1
allow reusing Postgres scalars in custom types & actions (close #4125) (#4333)
* allow re-using Postgres scalars in custom types, close #4125

* add pytest tests

* update CHANGELOG.md

* add a doc pointer for reusable postgres scalars

* document the code, improve the CHANGELOG entry

As suggested by @lexi-lambda

* a bit more source code documentation, use WriterT to collect reused scalars

* Apply suggestions from code review

Co-Authored-By: Marion Schleifer <marion@hasura.io>

* improve doc for Postgres scalars in custom graphql types

* Add some more references to Note; fix Haddock syntax

Also a few very minor tweaks:
  * Use HashSet instead of [] more pervasively
  * Export execWriterT from Hasura.Prelude
  * Use pattern guards in multi-way if
  * Tweak a few names/comments

* Pull buildActions out of buildAndCollectInfo, use buildInfoMap

* Tweak wording in documentation

* incorporate changes in console code

* account Postgres scalars for action input arguments

-> Avoid unnecessary 'throw500' in making action schema

* Review changes

Co-authored-by: Marion Schleifer <marion@hasura.io>
Co-authored-by: Alexis King <lexi.lambda@gmail.com>
Co-authored-by: Vamshi Surabhi <0x777@users.noreply.github.com>
Co-authored-by: Aleksandra Sikora <ola.zxcvbnm@gmail.com>
2020-04-15 17:33:13 +05:30
nizar-m
0e666a9203
Fix catalog version for v1.1.1 (close #4354) (#4355)
* Fix catalog version for v1.1.1

* Remove entries of removed tables from hdb_catalog

While downgrading catalog version from 32 -> 31, not removing entries
in hdb_table and hdb_relationship for the tables that are removed in
the downgrade, results in incosistent schema, when the server with
downgraded version is started. This should probably be handled in
a better fashion.

With the change in this commit, the server is able to successfully
start with downgraded catalog version 31.

* Test downgrade command along with upgrade tests
2020-04-09 19:57:59 -05:00
Antoine Leblanc
5b54f9d766
server: add support for webhook connection expiration (#4196)
* add expiry time to webhook user info

This also adds an optional message to webhook errors: if we fail to
parse an expiry time, we will log a warning with the parse error.

* refactored Auth

This change had one main goal: put in common all expiry time
extraction code between the JWT and WebHook parts of the
code. Furthermore, this change also moves all WebHook specific code to
its own module, similarly to what is done for JWT.

* Remove dependency on string-conversions in favor of text-conversions

string-conversions silently uses UTF8 instead of being explicit about
it, and it uses lenientDecode when decoding ByteStrings when it’s
usually better to reject invalid UTF8 input outright. text-conversions
solves both those problems.

Co-authored-by: Alexis King <lexi.lambda@gmail.com>
2020-04-02 19:00:13 -05:00
Lyndon Maydwell
85b7c552af
Allow field names to start with reserved keywords (fix #3597) (#3927) 2020-04-02 00:27:43 -05:00
Antoine Leblanc
5b74b2e2df
server: prevent metadata checks in read-only mode (#4250)
* do not perform the metadata check in read-only mode
* improve the isAltrDropReplace regex
* quote the regex at compile-time to handle syntax errors statically

Co-authored-by: Alexis King <lexi.lambda@gmail.com>
2020-04-01 18:22:55 -05:00
Vamshi Surabhi
114268910a
Merge branch 'master' into issue-4035-check-computed-field 2020-03-27 14:12:59 +05:30
Antoine Leblanc
b7dba573f1
tests: fix stringify function (#4191)
The stackoverflow answer this was copied from has a glaring problem: python really dislikes a dictionary being modified while it is being iterated on. I rewrote the function to instead return a modified copy.
2020-03-26 15:21:32 -05:00
Rakesh Emmadi
fd6535b861
option to reload remote schemas in 'reload metadata' (fix #3792, #4117) (#4141)
* option to reload remote schemas in 'reload_metadata' API, fix #3792, #4117

* add tests

* update changelog

* update docs api reference for 'reload_metadata'

* send reload_remote_schemas: true with the reload_metadata query

* add reload remote schemas checkbox; minor refactor

* Add a Note about cache invalidation and inconsistent metadata objects

* Small pluralization agreement tweak in docs

* Remove duplicated line in CHANGELOG

* no-op refactor

Suggested by Alexis @lexi-lambda

* Update server/src-lib/Hasura/RQL/DDL/RemoteSchema.hs

As suggested by @lexi-lambda

Co-Authored-By: Alexis King <lexi.lambda@gmail.com>

* fix tests

* requested changes

* comment 'replaceMetadataToOrdJson' unit tests

Co-authored-by: Rishichandra Wawhal <rishi@hasura.io>
Co-authored-by: Alexis King <lexi.lambda@gmail.com>
Co-authored-by: Tirumarai Selvan <tiru@hasura.io>
2020-03-26 17:22:20 +05:30
Antoine Leblanc
eb81d6947a
server: add tests for track_table of a materialized view (#4155)
* server: add tests for track_table of a materialized view

In the context of #91, we discovered that materialized views were
already "automagically" supported; to ensure we don't regress on this
accidental but welcome change, this patch adds simple tests.

This is basically just a copy of `track_untrack_table`, but for
materialized views.

* Expand abbreviations

Co-authored-by: Alexis King <lexi.lambda@gmail.com>
2020-03-24 12:35:34 +05:30
Antoine Leblanc
d9fa299750
server: fix all EWKT warnings in python tests (#4154)
The setup in several tests was using `ST_GeomFromText`, which expects
data in the OGC WKT format, but was providing the SRID in the text
itself, which is part of the EWKT format.

The fix was simply to replace all calls to `ST_GeomFromText` to
`ST_GeomFromEWKT`.
2020-03-23 20:48:09 -05:00
Rakesh Emmadi
c12dd1bae1
Merge branch 'master' into issue-4035-check-computed-field 2020-03-23 10:44:48 +05:30
Rakesh Emmadi
f80b69e931
few actions' fixes and improvements (fix #3977, #4061 & close #4021) (#4109)
* add 'ID' to default scalars for custom types, fix #4061

* preserve cookie headers from sync action webhook, close #4021

* validate action webhook response to conform to output type, fix #3977

* fix tests, don't run actions' tests on PG version < 10

* update CHANGELOG.md

* no-op refactor, use types from http-network more

Co-authored-by: Vamshi Surabhi <0x777@users.noreply.github.com>
2020-03-20 12:16:45 +05:30
rakeshkky
889f375ae2 Merge branch 'master' into issue-4035-check-computed-field
Resolve Conflicts:
	CHANGELOG.md
2020-03-12 10:21:43 +05:30
Rakesh Emmadi
996ce928d4
auto-include __typename field in custom types' objects (fix #4063) (#4074)
* include `__typename` field in custom types' objects, fix #4063

Co-authored-by: Vamshi Surabhi <0x777@users.noreply.github.com>
2020-03-11 17:09:00 +05:30
rakeshkky
8c2b5ad9d3 mark skip server upgrade test for new tests 2020-03-11 16:11:12 +05:30
rakeshkky
bb2b631fae Merge branch 'master' into issue-4035-check-computed-field
Resolve Conflicts:
	CHANGELOG.md
2020-03-11 12:09:19 +05:30
Brandon Simmons
c425b554b8
server(events): utilize proper backpressure scheme (close #3839) (#4013)
* Test working through a backlog of change events

* Use a slightly more performant threaded http server in eventing pytests

This helped locally but not on CI it seems...

* Rework event processing for backpressure. Closes #3839

With loo low `HASURA_GRAPHQL_EVENTS_FETCH_INTERVAL` and/or slow webhooks
and/or too small `HASURA_GRAPHQL_EVENTS_HTTP_POOL_SIZE` we might
previously check out events from the DB faster than we can service them,
leading to space leaks, weirdness, etc.

Other changes:
- avoid fetch interval sleep latency when we previously did a non-empty
  fetch
- prefetch event batch while http pool is working
- warn when it appears we can't keep up with events being generated
- make some effort to process events in creation order so we don't
  starve older ones.

ALSO NOTE: HASURA_GRAPHQL_EVENTS_FETCH_INTERVAL changes semantics
slightly, since it only comes into play after an empty fetch. The old
semantics weren't documented in detail, so I think this is fine.
2020-03-11 11:57:31 +05:30
rakeshkky
9128c69a80 fix postgres query error when computed fields included in mutation response, fix #4035 2020-03-11 10:23:28 +05:30
Vamshi Surabhi
b84db36ebb
allow custom mutations through actions (#3042)
* basic doc for actions

* custom_types, sync and async actions

* switch to graphql-parser-hs on github

* update docs

* metadata import/export

* webhook calls are now supported

* relationships in sync actions

* initialise.sql is now in sync with the migration file

* fix metadata tests

* allow specifying arguments of actions

* fix blacklist check on check_build_worthiness job

* track custom_types and actions related tables

* handlers are now triggered on async actions

* default to pgjson unless a field is involved in relationships, for generating definition list

* use 'true' for action filter for non admin role

* fix create_action_permission sql query

* drop permissions when dropping an action

* add a hdb_role view (and relationships) to fetch all roles in the system

* rename 'webhook' key in action definition to 'handler'

* allow templating actions wehook URLs with env vars

* add 'update_action' /v1/query type

* allow forwarding client headers by setting `forward_client_headers` in action definition

* add 'headers' configuration in action definition

* handle webhook error response based on status codes

* support array relationships for custom types

* implement single row mutation, see https://github.com/hasura/graphql-engine/issues/3731

* single row mutation: rename 'pk_columns' -> 'columns' and no-op refactor

* use top level primary key inputs for delete_by_pk & account select permissions for single row mutations

* use only REST semantics to resolve the webhook response

* use 'pk_columns' instead of 'columns' for update_by_pk input

* add python basic tests for single row mutations

* add action context (name) in webhook payload

* Async action response is accessible for non admin roles only if
  the request session vars equals to action's

* clean nulls, empty arrays for actions, custom types in export metadata

* async action mutation returns only the UUID of the action

* unit tests for URL template parser

* Basic sync actions python tests

* fix output in async query & add async tests

* add admin secret header in async actions python test

* document async action architecture in Resolve/Action.hs file

* support actions returning array of objects

* tests for list type response actions

* update docs with actions and custom types metadata API reference

* update actions python tests as per #f8e1330

Co-authored-by: Tirumarai Selvan <tirumarai.selvan@gmail.com>
Co-authored-by: Aravind Shankar <face11301@gmail.com>
Co-authored-by: Rakesh Emmadi <12475069+rakeshkky@users.noreply.github.com>
2020-02-13 23:08:23 +05:30
Tirumarai Selvan
f8e133070b
run default tests in test_server_upgrade (#3718)
* run basic tests after upgrade

* terminate before specifying file in pytest cmd

* Move fixture definitions out of test classes

Previously we had abstract classes with the fixtures defined
in them. The test classes then inherits these super classes. This
is creating inheritence problems, especially when you want to just
inherit the tests in class, but not the fixtures. We have now moved
all those fixture definitions outside of the class (in conftest.py).
These fixtures are now used by the test classes when and where they
are required.

* Run pytests on server upgrade

Server upgrade tests are run by
  1) Run pytest with schema/metadata setup but do not do schema/metadata
teardown
  2) Upgrade the server
  3) Run pytest using the above schema and teardown at the end of the
tests
  4) Cleanup hasura metadata and start again with next set of tests

We have added options --skip-schema-setup and --skip-schema-teardown to
help running server upgrade tests.

While running the tests, we noticed that error codes and messages for
some of the tests have changed. So we have added another option to
pytest `--avoid-error-message-checks`. If this flag is set, and if
comparing expected and response message fails, and if the expected
response has an error message, Pytest will throw warnings instead of an
error.

* Use marks to specify server-upgrade tests

Not all tests can be run as serve upgrade tests, particularly those
which themselves change the schema. We introduce two pytest markers.
Marker allow_server_upgrade_test will add the test into the list of
server  upgrade  tests  that  can  be run. skip_server_upgrade_test
removes it from the list.

With this we have added tests for queries, mutations, and selected
event trigger and remote schema tests to the list of server upgrade
tests.

* Remove components not needed anymore

* Install curl

* Fix error in query validation

* Fix error in test_v1_queries.py

* install procps for server upgrade tests

* Use postgres image which has postgis installed

* set pager off with psql

* quote the bash variable WORKTREE_DIR

Co-authored-by: nizar-m <19857260+nizar-m@users.noreply.github.com>
Co-authored-by: Vamshi Surabhi <0x777@users.noreply.github.com>
2020-02-13 14:44:02 +05:30
Phil Freeman
f615abd2f2
Add check expresion to update permissions (close #384) (#3804)
* Add check expresion to update permissions (close #384)

* wip on conflict behavior

* Handle upserts for views properly

* Use insert check if there is no update check

* Fix the test

* Improve error message slightly

Co-authored-by: Vamshi Surabhi <0x777@users.noreply.github.com>
2020-02-13 13:08:49 +05:30
Rakesh Emmadi
3a07228525
fix casting citext column type (fix #2818) (#3861) 2020-02-11 16:02:13 +05:30
Vamshi Surabhi
2de663d2a8
Merge branch 'master' into 3759-3791-minor-metadata-build-bugfixes 2020-02-05 18:25:46 +05:30
Anon Ray
c6e34baad8
fix parsing JWK expiry time from headers on startup (fix #3655) (#3779) 2020-02-05 12:37:30 +05:30
Rakesh Emmadi
53b9cabd88
fix few bugs related to nested insert returning (fix #3609, #3642, #3271) (#3618)
* fix nested insert with returning computed fields gives error, fix #3609

* revert using ordered hashmaps, sort columns based on ordinal postion

* fix 1. keys order 2. json/jsonb column value in nested insert returning

* add a note for sorted columns

* cast 'VALUES' expression as table row type

* use single CTE expression for generating returning for nested inserts
2020-02-04 21:04:17 +05:30
Alexis King
8ef205fba5 Explicitly invalidate enum values when metadata is reloaded
This fixes #3759. Also, while we’re at it, also improve the way
invalidations are synced across instances so enums and remote schemas
are appropriately reloaded by the schema syncing process.
2020-01-30 18:17:29 -06:00
Alexis King
3cdb3841e6 Build the GraphQL context after pruning dangling dependents
fixes #3791
2020-01-30 18:17:29 -06:00
Karthikeyan Chinnakonda
b344e7f39c disable explain end-points when metadata API is disabled, fix #3717 (#3751) 2020-01-22 16:20:49 +05:30
Rakesh Emmadi
319606b5ff include scalars types returning by computed fields in generated schema (fix #3650) (#3651) 2020-01-10 22:05:07 -06:00
Tirumarai Selvan
66beb02f7b remove brotli from packaging and CI images (#3673)
* Revert "add brotli shared lib to packager image (#2924)"
This reverts commit 79414cb225.
* remove unneeded dockerfile
* remove brotli traces in ci images and compression test
Co-authored-by: Rakesh Emmadi <12475069+rakeshkky@users.noreply.github.com>
2020-01-10 15:15:47 -06:00
Alexis King
06df174e8a Add missing check in SetTableCustomFields; update various test cases 2020-01-08 16:45:54 -06:00
Alexis King
25c5f97de2 Fix new hdb_table_info_agg query to fetch column base types
We mostly want to do this to make queries against information_schema
tables work, which the console cares about. information_schema tables
use types like sql_identifier, which have no corresponding array types
defined! Therefore, in order to generate valid queries for _in and _nin
conditions, we need to treat them as their base types, instead.
2020-01-08 16:45:54 -06:00
Alexis King
e2eabcd54e Properly check that custom field names do not conflict with other fields 2020-01-08 16:45:53 -06:00
Alexis King
c322e8a5d4 Use a significantly more efficient table_info_agg view
Also, use the view in Schema.Diff to share some more logic.
2020-01-08 16:45:46 -06:00
Alexis King
5b969208c6 Use arrows instead of monads to define the schema cache construction 2020-01-08 16:43:06 -06:00
Alexis King
1387722970 Refactor schema cache construction to avoid imperative updates
wip: fix error codes in remote schema tests
2020-01-08 16:43:06 -06:00
Phil Freeman
9e2c8b420b Report errors in parallel when batching (#3605)
* Report errors in parallel when batching
* Add some more test cases
2019-12-30 17:18:20 -06:00
Rakesh Emmadi
181902cc6c fix absence of "args" input field omits session variable argument, fix #3576 (#3585) 2019-12-26 16:32:48 -06:00
nizar-m
1fca7591c1 Show request id on test failures (#3556)
Right now on errors, only the expected and the actual responses are
shown. The actual response sometimes may not have all the information,
and you may have to look at the logs. In this case, request id would be
of great help to get the extra information from the logs.
2019-12-24 21:35:32 -06:00
Phil Freeman
c766881125 Support batched queries (fix #1812) (#3490) 2019-12-20 10:04:02 -06:00
Phil Freeman
b3e0595a9d Test with postgis 3.0.0 (#3519) 2019-12-18 19:32:15 -06:00
Rakesh Emmadi
421a182f64 export metadata without nulls, empty arrays & default values (#3393)
* export metadata without nulls, empty arrays
* property tests for 'ReplaceMetadata' using QuickCheck
-> Derive Arbitrary class for 'ReplaceMetadata' dependant types

* reduce property test cases number to 30
QuickCheck generates the `ReplaceMetadata` value really large
for higher number test cases. Encoded JSON for such values is large and
consumes more memory. Thus, CI is giving up while running property
tests.

* circle-ci: Add property tests as saperate job
* add no command mode to tests
* add yaml.v2 to go mod
* remove indirect comment for yaml.v2 dependency
2019-12-14 00:47:38 -06:00
Rakesh Emmadi
60acf7c081 fix json/jsonb columns as String values in nested returning of a mutation (fix #3365) (#3375) 2019-12-10 17:20:55 -06:00
Rakesh Emmadi
3f8a1d9ebf fix insert permission views are not unique for long role names (fix #3444) (#3486)
* fix insert permission views are not unique for long role names, fix #3444
* Use GHC notes reference and improve comments
2019-12-09 17:23:06 -06:00
Tirumarai Selvan
ff4b2bf8b0 bulk query should not care about access mode of select or count queries (#3467) 2019-12-04 13:16:37 -06:00
Anon Ray
afd6f30e72 read cache control header to refresh JWK (fix #3301) (#3446) 2019-12-03 14:56:59 -06:00
Rakesh Emmadi
cb682e2539 fix updating a column with multiple operators causing postgres query error (fix #3432) (#3458) 2019-12-03 14:00:37 -06:00
nizar-m
9faadec005 remove usage of deprecated 'pytest.config' (#3434)
pytest is now at version 5.3
2019-11-29 10:44:26 +05:30
Anon Ray
490b639981 refactor some internal components (#3414) 2019-11-26 17:44:21 +05:30
Rakesh Emmadi
c4c5dd87ac allow identical fields in custom column names configuration (fix #3137) & improve root fields validation (#3154)
* allow identical column fields in 'custom_column_names'
* improve validation of custom column names
* improve 'checkForFieldConflicts' & validate custom column names with non column fields
* split `validateTableConfig` into two isolated validation logic
* improve validation of root fields
* improve validating custom root fields and duplicate root fields
* move 'validateCustomRootFields' to 'buildSchemaCache'
2019-11-20 06:40:56 -06:00
Rakesh Emmadi
9b8e6b42d1 functions can access session info via input arg (close #2322) (#3143) 2019-11-20 12:17:06 +05:30
Alexis King
ec6df7c884
Merge pull request #3356 from jberryman/issue-3312-dev.sh-support-python-3.7 2019-11-15 10:39:46 -06:00
Tirumarai Selvan
d2b2a58c0e add read_only to run_sql metadata api (#3191) 2019-11-14 18:20:18 -06:00
Brandon Simmons
a1da8bcfdd Fix product_mul_price test
The intention was to make this two cases, using a top-level YAML list.
The result was one test with duplicate keys (effectively only running
the second test). This is an error that's now flagged by newer ruamel.

Both tests needed to be "corrected" to pass and need review.
2019-11-14 18:53:33 -05:00
Brandon Simmons
92b1f9c93d In tests: fix extraneous extra keys in yaml 2019-11-14 18:53:33 -05:00
Brandon Simmons
da78a77fb2 In tests/dev.sh: upgrade ruamel to support python 3.7. Closes #3312
Tested on python 3.5 and 3.7

We make light use of pyenv to set an appropriate python version if
installed. We could easily install a correct version too if we wanted
but that seemed invasive.

The newer ruamel was an annoying upgrade but also offers some
improvements that exposed some test suite issues (fixed later).
2019-11-14 18:53:33 -05:00
Tirumarai Selvan
ffeda35ff7 add few x-forwarded- headers (close #2572) (#3347) 2019-11-13 14:25:11 -06:00
Rakesh Emmadi
3888ceb24a computed fields in export/import metadata, other fixes (#3211) 2019-11-07 20:09:48 +05:30
Rakesh Emmadi
37dd0966d0 fix insert with nested returning clause fails alongside text[] column (fix #3148 & #2520) (#3198) 2019-11-06 23:14:36 -06:00
Rakesh Emmadi
1b96ebc7d2 deterministic ordering of objects in exported metadata (close #3125) (#3230)
* deterministic ordering of objects in exported metadata, close #3125
* refactor 'Hasura.RQL.DDL.Metadata'
2019-11-05 20:11:03 -06:00
Brandon Simmons
008a3df359 Comment flaky test_jsonb_has_all test 2019-11-05 15:15:25 -06:00
Brandon Simmons
a89777c808 Fix result ordering in some incorrect tests
These were generated with `--accept` and inspected individually.

Mark failing cases as xfail: #3271
2019-11-05 15:15:25 -06:00
Brandon Simmons
91aee7fdeb Test result ordering, add --accept test mode to automatically accept changed test cases
We add a new pytest flag `--accept` that will automatically write back
yaml files with updated responses. This makes it much easier and less
error-prone to update test cases when we expect output to change, or
when authoring new tests.

Second we make sure to test that we actually preserve the order of the
selection set when returning results. This is a "SHOULD" part of the
spec but seems pretty important and something that users will rely on.

To support both of the above we use ruamel.yaml which preserves a
certain amount of formatting and comments (so that --accept can work in
a failry ergonomic way), as well as ordering (so that when we write yaml
the order of keys has meaning that's preserved during parsing).

Use ruamel.yaml everywhere for consistency (since both libraries have
different quirks).

Quirks of ruamel.yaml:
- trailing whitespace in multiline strings in yaml files isn't written
  back out as we'd like: https://bitbucket.org/ruamel/yaml/issues/47/multiline-strings-being-changed-if-they
- formatting is only sort of preserved; ruamel e.g. normalizes
  indentation. Normally the diff is pretty clean though, and you can
  always just check in portions of your test file after --accept

fixup
2019-11-05 15:15:25 -06:00
Brandon Simmons
81fe4a23cf Test fixup: 'yes' being YAML synonym for 'true' is dubious
See: https://stackoverflow.com/q/57682657/176841

I don't think this is something we care about, and we need to fix this
for ruamel which uses the more sane v1.2 spec.
2019-11-05 15:15:25 -06:00
Shahidh K Muhammed
31e0225230
add tests with postgres 12 (close #2749) (#3102) 2019-10-26 11:09:57 +05:30
nizar-m
842913f566 Add tests for directives skip and include and basic tests for fragments (fix #3180) (#3185)
* Add tests for directives include and skip
* Add basic tests for fragments
2019-10-20 06:59:41 -05:00
Rakesh Emmadi
d8d21c1487 support computed fields returning scalars or set of tables (close #1387) (#2917) 2019-10-18 13:59:47 +05:30
Alexis King
e01008413e
Track variable uses within query validation for caching (fix #3097) (#3135)
This fix is a little ugly, but it’s the only simple solution without a
significant refactoring that restructures the relationship between
GraphQL/Validate and GraphQL/Resolve. The ugliness should go away if we
implement something like #2801.
2019-10-16 09:33:34 -05:00
Alexis King
c0d7402e15
Fix two enum table reference bugs (fix #2820 and #3010) (#3074)
* Include enum types in schema whenever references are visible (fix #2820)
* Fix RQL parsing for nullable enum table references (fix #3010)
2019-10-10 21:22:16 -05:00
Rakesh Emmadi
b0d60ec14f fix hdb_catalog.hdb_column view (fix #3083) (#3084) 2019-10-10 10:11:17 -05:00
Alexis King
3ef6feb394
server: Fix flaky logging test (#3081)
The changes in 0c74839934 adjusted the
format of error logs slightly to omit fields instead of including them
with null values. However, this was rarely triggered by this test
because it only looks at the first log message, but log messages can
sometimes be written out of order. This makes the test order-agnostic.
2019-10-10 08:40:19 -05:00
Rakesh Emmadi
f3b418c631 support where clause in on_conflict of insert mutation (close #2795) (#3002) 2019-10-09 05:09:20 -05:00
Toan Nguyen
0c74839934 add raw query field for error http log (close #2963) (#3020) 2019-10-07 13:04:33 -05:00
Rakesh Emmadi
8972dfb018 remove brotli compression (#2967)
Although brotli itself is MIT-licensed, the Haskell brotli library that provides bindings to it is GPL-licensed, so we cannot use it unless we get a response on haskell-hvr/brotli#1.
2019-10-05 02:20:50 -05:00
Rakesh Emmadi
084439db7e fix SQL generation if more than one aggregate order_by items present, fix #2981 (#2998) 2019-10-04 23:00:53 -05:00
Rakesh Emmadi
55a788594b update custom column names on renaming/dropping columns (#2933) 2019-10-03 13:15:52 +05:30
nizar-m
44da458c81 fix hpc combine error (close #2946) (#2947)
* Fix hpc combine error

* Do not perform ciignore

* xfail test jsonb_has_all

* Bring back ciignore

* Refer jsonb_has_all xfaul to the corresponding issue in graphql-engine-internal
2019-10-02 12:06:27 +05:30
Alexis King
18e8fbab1b
Parameterize all SQL values when multiplexing subscription queries (#2942)
Also, add support for explaining subscriptions while we’re at it.
2019-09-30 14:50:57 -05:00
Rakesh Emmadi
8a0615ff70 add gzip brotli compression to http responses (close #2674) (#2751) 2019-09-19 18:24:40 +05:30
Rakesh Emmadi
9bd5826020 allow customising graphql schema for a table (close #981) (#2509)
* allow customizing GraphQL root field names, close #981

* document v2 track_table API in reference

* support customising column field names in GraphQL schema

* [docs] add custom column fields doc in API reference

* add tests

* rename 'ColField' to 'ColumnField'

* embed column's graphql field in 'PGColumnInfo'

-> Value constructor of 'PGCol' is not exposed
-> Using 'parseJSON' to construct 'PGCol' in 'FromJSON' instances

* avoid using 'Maybe TableConfig'

* refactors & 'custom_column_fields' -> 'custom_column_names'

* cli-test: add configuration field in metadata export test

* update expected keys in `FromJSON` instance of `TableMeta`

* use `buildSchemaCacheFor` to update configuration in v2 track_table

* remove 'GraphQLName' type and use 'isValidName' exposed from parser lib

* point graphql-parser-hs library git repo to hasura

* support 'set_table_custom_fields' query API & added docs and tests
2019-09-19 10:17:36 +05:30
Alexis King
54e6439579 Change the way we determine whether or not queries are reusable
This fixes an issue where queries could incorrectly be considered
reusable if a variable was used in two positions: one where it affected
SQL generation and one where it did not.
2019-09-16 22:00:46 -05:00
Rakesh Emmadi
e5eb0c4f34 fix row comparison operator in event triggers (fix #2036) (#2868)
Update trigger is failing if any json/geometry columns are present in
event payload rows. Use '*<>' operator instead of '<>' to compare the
internal binary representation of rows if '<>' doesn’t work.
2019-09-12 18:22:01 -05:00
Rakesh Emmadi
c148e5753a support optional parameters in database url (close #1709) (#2344) 2019-09-05 15:59:26 -07:00
Rakesh Emmadi
de1ab241f8 allow creating permissions with conditions spanning tables (close #2512) (#2701) 2019-09-05 13:04:53 +05:30
Rakesh Emmadi
f7c99689da support intersect filters on raster columns (close #2613) (#2704)
* initial raster support

* _st_intersects_geom -> _st_intersects_geom_nband

* add tests

* update docs

* improve docs

As requested by @marionschleifer

* new type for raster values

Suggested by @lexi-lambda

* replace `SEUnsafe "NULL"` with SENull
2019-08-29 18:37:05 +05:30
Rakesh Emmadi
d9fb0f8780 use named notation for function arguments if any argument is not specified (fix #2730) (#2777)
* use positional arguments in SQL functions
* only allow omitting set of last arguments in functions
* disallow omitting of a non default argument in functions
2019-08-28 14:27:15 -05:00
Alexis King
ed26da59a6 Add support for GraphQL enum types via enum table references
These changes also add a new type, PGColumnType, between PGColInfo and
PGScalarType, and they process PGRawColumnType values into PGColumnType
values during schema cache generation.
2019-08-26 00:54:56 -05:00
Tirumarai Selvan
98784212e2 allow configuring timeout for remote schema calls (close #2501) (#2753) 2019-08-23 14:27:19 +05:30
Rakesh Emmadi
8ac78fdaec accept null values in order_by input field (fix #2754) (#2755) 2019-08-22 03:14:27 -05:00
Rakesh Emmadi
3527b085fd allow altering type of a column whose permissions defined only with session variables (close #2070) (#2683)
* allow altering type of a column iff session vars are defined in permissions
* use a sum type to define dependency reason
* set jwt expiry test's expiry time to 4 seconds
* derive Data instance for necessary types to simplify 'hasStaticExp'
2019-08-16 16:35:22 -05:00
Alexis King
2aa66ca6f5 Fix websocket race condition in server test suite (fix #2710) (#2712) 2019-08-12 15:14:29 +05:30
Rakesh Emmadi
a03c78854d capture Postgres error code 22025 as HTTP 400 bad request (close #2486) (#2671) 2019-08-08 15:57:42 -05:00
Vamshi Surabhi
a5a07634a5
Merge branch 'master' into dev-scripts-and-doc-tweaks 2019-08-07 12:08:46 +05:30
Anon Ray
b4a0a03631 log when request body parsing fails (fix #2555) (#2556) 2019-08-01 16:21:59 +05:30
Rakesh Emmadi
6b8a6ca48f dont use sub-query for perm limit if aggregations are absent (#2630) 2019-08-01 05:09:52 +00:00
Brandon Simmons
3a4071af09 Remove some output noise from tests 2019-07-26 01:17:55 -04:00
Brandon Simmons
bc4456eccc Add local development swiss army knife script scripts/dev.sh
At the moment we can...

...run tests in isolation, generating coverage report:

    $ dev.sh test

You can pass args to pytest as well. e.g. to run a specific test:

    $ dev.sh test -k "test_jsonb_has_all"

Launch a postgres container with useful dev defaults, with PostGIS,
cleaning up afterwards:

    $ dev.sh postgres

Build and launch graphql-engine in dev mode, connecting with a
`postgres` launched above

    $ dev.sh graphql-engine
2019-07-26 01:17:35 -04:00
Brandon Simmons
04f90dd35d pytest.exit breaks pytest-xdist and produces a misleading error 2019-07-26 01:16:17 -04:00
Vamshi Surabhi
4facb3c780 remove support for query templates (#2560)
query templates is a little known feature that lets you template rql
queries and serve them as rest apis. This is not relevant anymore
given the GraphQL interface and getting rid of it reduces the dev
time when adding features in few subsystems.

This feature has never been used outside hasura's internal projects or
documented or exposed through console and hence can safely be removed.
2019-07-23 19:11:34 +00:00
Alexis King
8f9a41ff88 Support casting between PostGIS geometry and geography types in where expressions (close #1983) (#2495)
* server: Bump dependencies to allow Haddock to run successfully

* Support casting between PostGIS geometry and geography types in filters
2019-07-15 14:22:45 +05:30
Anon Ray
c797d23a14 fix server tests (#2510) 2019-07-11 10:55:34 +00:00
Anon Ray
f2f14e727b Merge pull request from GHSA-2j98-fw5g-j43v
* fix bug in audience check while verifying JWT

  - previously the check was converting the audience type into a string
  and then comparing with the conf value. all audience types (as it is a
  string or URI) will convert to plain strings
  - use the Audience type from the jose library for comparing

* add docs for audience

* add issuer check as well

* docs minor syntax fix

* skip audience check if not given in conf

* minor docs update

* qualify import jose library
2019-07-11 09:58:39 +00:00
Ajeet D'Souza
92c4cff79e check input for empty strings for metadata api (close #2302) (#2300) 2019-07-11 09:00:45 +00:00
Ajeet D'Souza
605f8633f3 fail on tracking table/function with name conflict (close #2020) (#2383)
Currently, we allow tracking of a table with the same name as an already tracked function, and vice-versa. This causes an issue when querying from GraphQL since it will only query the table and not the function. I've made changes to disallow this by throwing an error.
2019-07-11 07:41:20 +00:00
Anon Ray
8f1e7dbc8d breaking: server logging changes (close #507, close #2171) (#1835) 2019-07-11 05:37:06 +00:00
Vamshi Surabhi
f1cf6d0b17
allow session variables in operators which expect array input (#2475) 2019-07-10 15:49:58 +05:30
Rakesh Emmadi
9eb38e6c96 cache remote schema's introspection query response (fix #1679) (#2089) 2019-07-08 11:21:41 +05:30
Anon Ray
f31c3b2887 freeze requirements.txt for server tests (#2450) 2019-07-01 13:34:48 +00:00
Rakesh Emmadi
dc84bb4e77 fix renaming of columns used in insert permission (fix #2398) (#2414) 2019-06-21 16:34:21 +05:30
Shahidh K Muhammed
a8dd3b3deb add api to get server config details (close #1831); add jwt-analyzer (close #1369) (#1925) 2019-06-11 18:59:03 +05:30
Rakesh Emmadi
c3c01beccc support null and default values for function arguments (close #2176, close #2250) (#2282) 2019-06-04 18:13:28 +05:30
Anon Ray
278f26b073 forward set-cookie headers from remote servers (fix #1654) (#2305) 2019-06-04 15:40:28 +05:30
Rakesh Emmadi
31cf7314e2 better change detection when altering foreign key constraints (fix #2060) (#2252)
foreign keys are considered to be dropped only if constraint oid changes
2019-06-03 15:51:55 +05:30
Anon Ray
95a27fba89 fix response for remote schema queries over ws (fix #2246) (#2248) 2019-05-29 17:21:09 +05:30
Rakesh Emmadi
2e19cbee8d keep allowed queries in sync when collections are changed, fix #2221 (#2230) 2019-05-20 15:59:32 +05:30
Rakesh Emmadi
0b210cc245 support allow-list for graphql queries (closes #989) (#2075) 2019-05-16 11:43:25 +05:30
Anon Ray
7d03e7af2f fix non-200 response for authorization errors on /v1/graphql (#2173) 2019-05-14 16:50:55 +05:30
Rakesh Emmadi
c6f40df6d5 close websocket connection on JWT expiry (fix #578) (#2156) 2019-05-14 11:54:46 +05:30
Anon Ray
ee783e142e fix sending duplicate content-type header to remote schemas (fix #2159) (#2170) 2019-05-13 18:17:01 +05:30
Tirumarai Selvan
36e49ea75b manual event triggers (close #1687) (#2077) 2019-05-13 15:11:07 +05:30
Anon Ray
a21f6cd648 introduce v1/graphql (fix #1368) (#2064)
Changes compared to `/v1alpha1/graphql`

* Changed all graphql responses in **/v1/graphql** endpoint to be 200. All graphql clients expect responses to be HTTP 200. Non-200 responses are considered transport layer errors. 

* Errors in http and websocket layer are now consistent and have similar structure.
2019-05-10 11:35:10 +05:30
Anon Ray
dfaf7d3a1f fix duplicate headers being sent to remote schema (#2118) 2019-05-06 16:57:34 +05:30
Rakesh Emmadi
b436948e7f update schema cache on a column's null-ability or type changes (fix #2101) (#2106) 2019-05-02 18:01:32 +05:30