graphql-engine/server/tests-py/queries/v1/relationships
Auke Booij fe8eabff19 server: fix the nullability of object relationships (fix hasura/graphql-engine#7201)
When adding object relationships, we set the nullability of the generated GraphQL field based on whether the database backend enforces that the referenced data always exists. For manual relationships (corresponding to `manual_configuration`), the database backend is unaware of any relationship between data, and hence such fields are always set to be nullable.

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

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

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

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

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

GitOrigin-RevId: 617f12765614f49746d18d3368f41dfae2f3e6ca
2021-08-26 15:27:34 +00:00
..
array_relationship_col_not_foreign_key_error.yaml server: fix the nullability of object relationships (fix hasura/graphql-engine#7201) 2021-08-26 15:27:34 +00:00
array_relationship_foreign_key.yaml add python based tests, remove haskell tests 2018-10-04 18:14:15 +05:30
array_relationship_manual.yaml server: fix bug when renaming table with manual relationships (#5806) 2020-10-28 10:21:53 +00:00
array_relationship_non_public_schema_foreign_key.yaml add python based tests, remove haskell tests 2018-10-04 18:14:15 +05:30
create_array_relationship_as_not_admin_error.yaml add python based tests, remove haskell tests 2018-10-04 18:14:15 +05:30
create_object_relationship_as_not_admin_error.yaml add python based tests, remove haskell tests 2018-10-04 18:14:15 +05:30
object_relationship_col_not_foreign_key_error.yaml server: fix the nullability of object relationships (fix hasura/graphql-engine#7201) 2021-08-26 15:27:34 +00:00
object_relationship_foreign_key.yaml In tests: fix extraneous extra keys in yaml 2019-11-14 18:53:33 -05:00
object_relationship_manual.yaml server: fix bug when renaming table with manual relationships (#5806) 2020-10-28 10:21:53 +00:00
object_relationship_non_public_schema_foreign_key.yaml add python based tests, remove haskell tests 2018-10-04 18:14:15 +05:30
object_relationship_one_to_one.yaml server: Add test file to suite 2021-05-25 11:37:14 +00:00
setup.yaml server: Add test file to suite 2021-05-25 11:37:14 +00:00
teardown.yaml server: Add test file to suite 2021-05-25 11:37:14 +00:00