graphql-engine icon indicating copy to clipboard operation
graphql-engine copied to clipboard

Custom naming convention

Open mnesarco opened this issue 3 years ago • 0 comments

Is your proposal related to a problem?

There are some cases where configuring a custom naming convention will help a lot to avoid setting field/table custom names manually.

For example, in my database, all fields are snake case and end with an additional underscore:

create table pre_x (
  id_ serial primary key, 
  name_ text, 
  office_phone_ text, 
  ...)

And I want that graphql names are snake case but without the trailing underscore. And also I want to remove prefix from table generated names.

Describe the solution you'd like

If there is away to configure two functions:

generate_field_name(source_field_name : str) -> str
generate_table_name(source_table_name : str) -> str

That functions can be in javascript, or haskell whatever better suits Hasura, but it is an idea how to support custom naming transformations.

Describe alternatives you've considered

In one project, I wrote a python script that downloads the metadata from Hasura, add custom names to all tables/fields and update back the Hasura metadata. But I think this is too fragile approach because changes in metadata format can break the script at some point/version.

If the feature is approved, would you be willing to submit a PR?

I don't know how to add it to Hasura, my previous solution was an external script using the metadata api.

mnesarco avatar Oct 05 '22 14:10 mnesarco