mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-16 01:44:03 +03:00
fe8eabff19
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 |
||
---|---|---|
.. | ||
array_relationship_col_not_foreign_key_error.yaml | ||
array_relationship_foreign_key.yaml | ||
array_relationship_manual.yaml | ||
array_relationship_non_public_schema_foreign_key.yaml | ||
create_array_relationship_as_not_admin_error.yaml | ||
create_object_relationship_as_not_admin_error.yaml | ||
object_relationship_col_not_foreign_key_error.yaml | ||
object_relationship_foreign_key.yaml | ||
object_relationship_manual.yaml | ||
object_relationship_non_public_schema_foreign_key.yaml | ||
object_relationship_one_to_one.yaml | ||
setup.yaml | ||
teardown.yaml |