2020-05-27 18:02:58 +03:00
|
|
|
type: bulk
|
|
|
|
args:
|
|
|
|
- type: run_sql
|
|
|
|
args:
|
|
|
|
sql: |
|
|
|
|
create table address (
|
|
|
|
address_id serial primary key,
|
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 17:32:55 +03:00
|
|
|
user_id integer references custom.profiles(id),
|
2020-05-27 18:02:58 +03:00
|
|
|
address_line text
|
|
|
|
)
|
|
|
|
- type: run_sql
|
|
|
|
args:
|
|
|
|
sql: |
|
|
|
|
insert into address (user_id, address_line) values
|
|
|
|
( 1, 'address-1' ),
|
|
|
|
( 2, 'address-2' ),
|
|
|
|
( 3, 'address-3'),
|
|
|
|
( 1, 'address-1b')
|
|
|
|
- type: track_table
|
|
|
|
args:
|
|
|
|
name: address
|
|
|
|
- type: create_object_relationship
|
|
|
|
args:
|
|
|
|
name: myProfile
|
|
|
|
table: address
|
|
|
|
using:
|
|
|
|
foreign_key_constraint_on: user_id
|
|
|
|
- type: create_array_relationship
|
|
|
|
args:
|
|
|
|
name: myAddresses
|
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 17:32:55 +03:00
|
|
|
table: {schema: custom, name: profiles}
|
2020-05-27 18:02:58 +03:00
|
|
|
using:
|
|
|
|
foreign_key_constraint_on:
|
|
|
|
table: address
|
|
|
|
column: user_id
|
|
|
|
- type: create_object_relationship
|
|
|
|
args:
|
|
|
|
name: mySpecialAddress
|
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 17:32:55 +03:00
|
|
|
table: {schema: custom, name: profiles}
|
2020-05-27 18:02:58 +03:00
|
|
|
using:
|
|
|
|
manual_configuration:
|
|
|
|
remote_table: address
|
|
|
|
column_mapping:
|
|
|
|
id: address_id
|