graphql-engine/server/src-lib/Hasura/RQL/DDL
Antoine Leblanc 81d9071948 Fix remote relationship invalid type name issue (fix hasura/graphql-engine#8002)
## Description

When setting up a remote relationship to a remote schema, values coming from the left-hand side are given as _arguments_ to the targeted field of the remote schema. In turn, that means we need to adjust the arguments to that remote field; in the case of input objects, it means creating a brand new input object in which the relevant fields have been removed.

To both avoid conflicts, and be explicit, we give a pretty verbose name to such an input object: its original name, followed by "remote_rel", followed by the full name of the field (table name + relationship name). The bug there was introduced when working on extending remote relationships to other backends: we changed the code that translates the table name to a graphql identifier to be generic, and use the table's `ToTxt` instance instead. However, when a table is not in the default schema, the character used by that instance is `.`, which is not a valid GraphQL name.

This PR fixes it, by doing two things:
- it defines a safe function to translate LHS identifiers to graphql names (by replacing all invalid characters by `_`)
- it doesn't use `unsafeMkName` anymore, and checks at validation time that the type name is correct

## Further work

On this PR:
- [x] add a test
- [x] write a Changelog entry

Beyond this PR, we might want to:
- prioritize #1747
- analyze all calls to `unsafeMkName` and remove as many as possible

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3363
GitOrigin-RevId: fe98eb1d34157b2c8323af453f5c369de616af38
2022-01-27 14:34:01 +00:00
..
Metadata Feature/webhook response transforms 2022-01-19 04:47:36 +00:00
Permission server: cleanup references to "pgCol" in common and non-postgres backend code 2022-01-19 08:38:48 +00:00
Relationship server, pro: actually reformat the code-base using ormolu 2021-09-23 22:57:37 +00:00
RemoteRelationship Fix remote relationship invalid type name issue (fix hasura/graphql-engine#8002) 2022-01-27 14:34:01 +00:00
RemoteSchema Changed RemoteSchemaIntrospection's internal representation from a list to a hashmap. 2021-11-30 14:47:50 +00:00
Schema server: cleanup references to "pgCol" in common and non-postgres backend code 2022-01-19 08:38:48 +00:00
Action.hs Feature/webhook response transforms 2022-01-19 04:47:36 +00:00
ApiLimit.hs server: add explicit export lists in OSS server and enforce with warning 2021-11-04 16:09:38 +00:00
ComputedField.hs server/mssql: add cascade to mssql_run_sql 2021-10-22 14:50:13 +00:00
CustomTypes.hs server: add support for nested object type in action 2021-12-15 23:52:43 +00:00
Endpoint.hs server, pro: actually reformat the code-base using ormolu 2021-09-23 22:57:37 +00:00
EventTrigger.hs Feature/webhook response transforms 2022-01-19 04:47:36 +00:00
GraphqlSchemaIntrospection.hs server: add explicit export lists in OSS server and enforce with warning 2021-11-04 16:09:38 +00:00
Headers.hs server: add explicit export lists in OSS server and enforce with warning 2021-11-04 16:09:38 +00:00
InheritedRoles.hs server: enable inherited roles by default 2021-10-05 12:29:32 +00:00
Metadata.hs Feature/webhook response transforms 2022-01-19 04:47:36 +00:00
Network.hs server: add explicit export lists in OSS server and enforce with warning 2021-11-04 16:09:38 +00:00
Permission.hs server: cleanup references to "pgCol" in common and non-postgres backend code 2022-01-19 08:38:48 +00:00
QueryCollection.hs server, pro: actually reformat the code-base using ormolu 2021-09-23 22:57:37 +00:00
QueryTags.hs server: add explicit export lists in OSS server and enforce with warning 2021-11-04 16:09:38 +00:00
Relationship.hs server/mssql: add cascade to mssql_run_sql 2021-10-22 14:50:13 +00:00
RemoteRelationship.hs server: cleanup references to "pgCol" in common and non-postgres backend code 2022-01-19 08:38:48 +00:00
RemoteSchema.hs Remove Unique from Definition 2021-12-01 16:21:35 +00:00
ScheduledTrigger.hs server: add a new metadata API to return all the cron triggers 2022-01-27 06:44:37 +00:00
Schema.hs server, pro: actually reformat the code-base using ormolu 2021-09-23 22:57:37 +00:00
WebhookTransforms.hs Feature/webhook response transforms 2022-01-19 04:47:36 +00:00