1
0
mirror of https://github.com/hasura/graphql-engine.git synced 2024-12-29 02:14:57 +03:00
Commit Graph

54 Commits

Author SHA1 Message Date
Rakesh Emmadi
319606b5ff include scalars types returning by computed fields in generated schema (fix ) () 2020-01-10 22:05:07 -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
Phil Freeman
9e2c8b420b Report errors in parallel when batching ()
* 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 () 2019-12-26 16:32:48 -06:00
Phil Freeman
c766881125 Support batched queries (fix ) () 2019-12-20 10:04:02 -06:00
Rakesh Emmadi
9b8e6b42d1 functions can access session info via input arg (close ) () 2019-11-20 12:17:06 +05:30
Rakesh Emmadi
3888ceb24a computed fields in export/import metadata, other fixes () 2019-11-07 20:09:48 +05:30
Brandon Simmons
008a3df359 Comment flaky test_jsonb_has_all test 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
nizar-m
842913f566 Add tests for directives skip and include and basic tests for fragments (fix ) ()
* 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 ) () 2019-10-18 13:59:47 +05:30
Alexis King
e01008413e
Track variable uses within query validation for caching (fix ) ()
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 .
2019-10-16 09:33:34 -05:00
Alexis King
c0d7402e15
Fix two enum table reference bugs (fix and ) ()
* Include enum types in schema whenever references are visible (fix )
* Fix RQL parsing for nullable enum table references (fix )
2019-10-10 21:22:16 -05:00
Rakesh Emmadi
084439db7e fix SQL generation if more than one aggregate order_by items present, fix () 2019-10-04 23:00:53 -05:00
nizar-m
44da458c81 fix hpc combine error (close ) ()
* 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
Rakesh Emmadi
9bd5826020 allow customising graphql schema for a table (close ) ()
* allow customizing GraphQL root field names, close 

* 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
Rakesh Emmadi
de1ab241f8 allow creating permissions with conditions spanning tables (close ) () 2019-09-05 13:04:53 +05:30
Rakesh Emmadi
f7c99689da support intersect filters on raster columns (close ) ()
* 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 ) ()
* 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
Rakesh Emmadi
8ac78fdaec accept null values in order_by input field (fix ) () 2019-08-22 03:14:27 -05:00
Rakesh Emmadi
a03c78854d capture Postgres error code 22025 as HTTP 400 bad request (close ) () 2019-08-08 15:57:42 -05:00
Rakesh Emmadi
6b8a6ca48f dont use sub-query for perm limit if aggregations are absent () 2019-08-01 05:09:52 +00:00
Alexis King
8f9a41ff88 Support casting between PostGIS geometry and geography types in where expressions (close ) ()
* 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
Vamshi Surabhi
f1cf6d0b17
allow session variables in operators which expect array input () 2019-07-10 15:49:58 +05:30
Rakesh Emmadi
c3c01beccc support null and default values for function arguments (close , close ) () 2019-06-04 18:13:28 +05:30
Rakesh Emmadi
31cf7314e2 better change detection when altering foreign key constraints (fix ) ()
foreign keys are considered to be dropped only if constraint oid changes
2019-06-03 15:51:55 +05:30
Anon Ray
a21f6cd648 introduce v1/graphql (fix ) ()
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
Rakesh Emmadi
b436948e7f update schema cache on a column's null-ability or type changes (fix ) () 2019-05-02 18:01:32 +05:30
Rakesh Emmadi
733101bf85 compute dependencies for column operators in permissions (close ) () 2019-04-24 15:58:10 +05:30
nizar-m
a40bf10b9f run graphql tests on both http and websocket; add parallelism (close ) ()
Examples 
1)  `
pytest --hge-urls "http://127.0.0.1:8080" --pg-urls "postgresql://admin@127.0.0.1:5432/hge_tests" -vv
`
2)  `pytest --hge-urls "http://127.0.0.1:8080"   "http://127.0.0.1:8081" --pg-urls "postgresql://admin@127.0.0.1:5432/hge_tests"  "postgresql://admin@127.0.0.1:5432/hge_tests2" -vv
`
### Solution and Design
<!-- How is this issue solved/fixed? What is the design? -->
<!-- It's better if we elaborate -->
#### Reducing execution time of tests
- The Schema setup and teardown, which were earlier done per test method, usually takes around 1 sec. 
- For mutations, the model has now been changed to only do schema setup and teardown once per test class.
-  A data setup and teardown will be done once per test instead (usually takes ~10ms).
- For the test class to get this behaviour, one can can extend the class `DefaultTestMutations`. 
    - The function  `dir()` should be define which returns the location of the configuration folder.
    - Inside the configuration folder, there should be 
        - Files `<conf_dir>/schema_setup.yaml` and `<conf_dir>/schema_teardown.yaml`, which has the metadata query executed during schema setup and teardown respectively
        - Files named `<conf_dir>/values_setup.yaml` and `<conf_dir>/values_teardown.yaml`. These files are executed to setup and remove data from the tables respectively. 

#### Running Graphql queries on both http and websockets
- Each GraphQL query/mutation is run on the both HTTP and websocket protocols
- Pytests test parameterisation is used to achieve this
- The errors over websockets are slightly different from that on HTTP
   - The code takes care of converting the errors in HTTP to errors in websockets

#### Parallel executation of tests.
- The plugin pytest-xdist helps in running tests on parallel workers.
- We are using this plugin to group tests by file and run on different workers.
- Parallel test worker processes operate on separate postgres databases(and separate graphql-engines connected to these databases). Thus tests on one worker will not affect the tests on the other worker.
- With two workers, this decreases execution times by half, as the tests on event triggers usually takes a long time, but does not consume much CPU.
2019-04-08 12:52:38 +05:30
Rakesh Emmadi
3708f95036 fix input argument types for custom SQL functions (close ) () 2019-04-08 12:28:56 +05:30
Shahidh K Muhammed
b8700cce70
add spatial predicates for geography columns (close ) ()
This PR adds support for PostGIS spatial predicates on geography columns. The predicates are _st_d_within and _st_intersects.
2019-03-25 17:59:52 +05:30
Rakesh Emmadi
0833d35088 generate scalar types for SQL function arguments (fix ) ()
Also involved a refactor of the internals to localise the context needed for each field
2019-02-22 15:57:38 +05:30
Rakesh Emmadi
2054bdc44e do not allow overloading already tracked functions () 2019-02-14 09:35:18 +05:30
Rakesh Emmadi
96f8b05326 don't allow altering tracked SQL functions type to VOLATILE (fix ) () 2019-02-05 11:27:03 +05:30
Rakesh Emmadi
3caff9b924 support jsonb and postgis operators in permissions ()
* support jsonb and geometry operators on RQL bool exps, close 

* add tests for jsonb operators in /v1/query

TODO:-
-> add tests for geometry (postgis) operators

* support parsing session variables for st_d_within and has_key ops

-> Add tests for boolExp operators and select permissions

* improve parsing $st_d_within op's json value logic
2019-01-28 23:16:31 +05:30
Rakesh Emmadi
0bf2457e23 allow exposing postgres functions through GraphQL interface (close ) () 2019-01-25 09:01:54 +05:30
Rakesh Emmadi
7ff1c8829a add PostGIS operators in boolean expressions (closes ) () 2019-01-17 11:51:38 +05:30
Rakesh Emmadi
ff6c95c2f8 allow ordering with aggregated fields (close ) () 2018-12-12 18:28:39 +05:30
Rakesh Emmadi
1e896a9c42 handle null values for input arguments, fix () 2018-11-27 17:54:51 +05:30
Rakesh Emmadi
8df23ad6c9 use postgres IN experssion for _in operator (fix ) () 2018-11-26 15:39:55 +05:30
Rakesh Emmadi
58fe579497 support Postgres's DISTINCT ON (close ) () 2018-11-23 07:23:56 +05:30
Rakesh Emmadi
030f094de9 handle empty array for _in and _nin operators, fix () 2018-11-21 12:28:29 +05:30
Vamshi Surabhi
47dcae1614
fix sql generation for boolean expressions, closes ()
When using self referential relationships in boolean expressions, the exists clause incorrectly uses the table names to qualify columns which will be the same for parent table and the child table. This is now fixed by generating unique aliases as we traverse down the relationships.
2018-11-16 18:10:23 +05:30
Rakesh Emmadi
80de0e019a do not generate prefix for column identifiers in agg select, fix () 2018-11-12 12:58:46 +05:30
Rakesh Emmadi
1a91399298 extract session variables from relational bool expression (fix ) () 2018-11-02 15:06:33 +05:30
nizar-m
0ffb0478b9 Tests for server with access control, and some more tests ()
* 1) Tests for creating permissions
2) Test for constraint_on with GraphQL insert on_conflict

* Run tests with access key and webhook

* Tests for GraphQL query with quoted columns

* Rewrite test-server.sh so that it can be run locally

* JWT based tests

* Tests with various postgres types

* For tests on select queries, run setup only once per class

* Tests for v1 count queries

* Skip teardown for tests that does not modify data

* Workaround for hpc 'parse error when reading .tix file'

* Move GeoJson tests to the new structure

* Basic tests for v1 queries

* Tests for column, table or operator not found error cases on GraphQL queries

* Skip test teardown for mutation tests which does not change database state, even when it returns 200.
2018-10-28 23:57:49 +05:30
Rakesh Emmadi
f6ed169219 allow ordering using columns from object relationships (closes ) ()
* allow ordering using columns from object relationships, close 

* validate table fields in nested insert

* add tests

* add docs

* change 'table_order_by' type from enums to ordered map

* remove unwanted code from 'Schema.hs' file

* 'AnnGObject' is not list of field name and value tuple

* update docs for new order_by type

* use 'InsOrdHashMap' for 'AnnGObj'

* handle empty fields in order_by

* remove '_' prefixes for asc/desc

* fix the changed order_by syntax across the repo
2018-10-26 17:27:33 +05:30
Rakesh Emmadi
a8cee16ab5 support aggregations (closes ) ()
* support for count and aggregations on columns, close 

* support explain query for aggregations

* '<arr-rel>_agg' in '<table>' type, fix order by for aggregations

* add 'allow_aggregations' key in select permissions

* Add checkbox to toggle count and aggregations on columns on select permission

* align aggregation checkbox with columns div

* improve readability of the generated sql

* alias is needed at the top level aggregation

* throw internal errors for unexpected fields

* rename SelFld to more readable TableAggFld

* rename agg to aggregate
2018-10-26 14:32:43 +05:30