Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

behaviour of prefix and suffix in SourceCustomization with naming convention #8544

Closed
paritosh-08 opened this issue Jun 1, 2022 · 3 comments
Assignees
Labels
k/enhancement New feature or improve an existing feature

Comments

@paritosh-08
Copy link
Contributor

paritosh-08 commented Jun 1, 2022

Before naming convention was introduced, adding prefix and suffix was pretty straightforward.

For example, say I have a table called foo then HGE generated field names such as foo, foo_by_pk, etc. Now if I want to add prefix while retaining the snakecase of the fields, I would add prefix my_prefix_ and suffix _my_suffix and thus the new field names will be my_prefix_foo_my_suffix, my_prefix_foo_by_pk_my_suffix, etc. (Please note that this is the case with hasura-default naming convention)

With the introduction of graphql-default naming convention, there is no way to add prefix and still retain the case of the field name. For example, if I have a table named foo, the field names generated are foo, fooByPk, etc. Now if I want to add some prefix, say myPrefix, the new fields will be myPrefixfoo, myPrefixfooByPk, etc.

This raises a few questions:

  1. Should hasura change the already generated field names when someone adds a prefix or suffix? i.e. should hasura generate myPrefixFoo, myPrefixFooByPk, etc. in the above example.
  2. If yes, then to be consistent shouldn't hasura also add _ automatically when adding prefix and suffix for hasura-default?

PS: There is a really dirty workaround to fix the prefixing issue by renaming the table to oo and adding prefix myPrefixF, but I don't think anyone should do this.

@paritosh-08 paritosh-08 added the k/enhancement New feature or improve an existing feature label Jun 1, 2022
@anazar
Copy link

anazar commented Jun 28, 2022

I think we should also consider allowing the graphql-default naming convention to apply to custom_table_name as well. I consider custom_table_name an alias. If the custom_name is specified in the metadata and no other custom_root_fields are specified to override the defaults I would assume that the naming convention should apply to the root fields as well.

@paritosh-08
Copy link
Contributor Author

@anazar, The root fields follow the naming convention with custom_table_name as well. For example, if I have a table called user_table and I set the naming convention to graphql-default and set the custom_table_name to my_user_table then we will have the following root fields:

my_user_table
my_user_tableByPk
my_user_tableAggregate

Please note that we are not applying the naming convention on the custom_table_name itself.

@paritosh-08
Copy link
Contributor Author

This issue has been resolved via 84366c9. I am closing this issue for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
k/enhancement New feature or improve an existing feature
Projects
None yet
Development

No branches or pull requests

2 participants