With the introduction of the Custom GraphQL Root Fields and GraphQL Field Name features, one can specify the name used in the schema generation, for every field and table. This is very useful, especially, when referencing from client apps. But, this might become overhead for very large schemas, spanning across multiple Postgres schemas.
I would like to see a feature where one can specify the naming convention globally (perhaps at a schema level?), e.g. camelCase, PascalCase, etc.
This should be available for table names, field names, mutation names and relationship names.
Bonus Request:
'add'${PascalCase table name}${singular camelCase table name} and normal select query: ${plural camelCase table name}As a JavaScript developer, I really want this feature.
馃憤We are interested as well. Currently we rely on the Custom GraphQL Root Fields feature but it involves error-prone work. Also, some parts cannot be changed such as on_conflict & update_columns fields.
In the meantime we should soon have missing field available in console: https://github.com/hasura/graphql-engine/issues/4203.
I wrote a utility function for internal use to do the naming conversion. Fork it if you need more customization, such as generate permission/interfaces etc. (I remove permission part since it's business related)
@xiaoyu-tamu I do something similar but based on Java JPA annotations + specific Hasura annotations (for permissions, for example)
https://github.com/beepsoft/hasuraconf
Just added support for the new Hasura 1.2 root fields insert_one, update_by_pk, delete_by_pk.
Please take inspiration from Postgraphile naming convention. It has the best defaults IMO.
Here is the doc of its inflection system : https://www.graphile.org/postgraphile/inflection/
And the simplified naming plugin : https://github.com/graphile/pg-simplify-inflector
I'd really like to have this feature. After going through painstaking effort to convert each root query and relationship name to camelCase I was shocked to find out that aggregates of relationships still use snake_case and apparently there's no way to change it.
This is a clash of conventions between the front end and the data layer
+1 for this, it is very tedious to change them one by one
Javascript developers - aliases might be a good workaround for now
https://atheros.ai/blog/how-to-use-graphql-aliases
When I started with Hasura a couple of months ago, being used to camelCase I did not understand why all examples bother with _ugly_ snake_case. So I went straight for camelCase for all my DB entities.
Today after several frustrating moments trying to write custom SQLs for either views or computed fields I've given up and renamed columns/tables/views to snake_case. Arguably arbitrary SQL is not needed that often with Hasura, but when things get complicated it's kinda hard to find the error in syntax, especially for a frontend developer.
I think Hasura should explain the pros/cons of each naming convention in docs.
To keep my Javascript OCD happy I had to painfully specify custom GraphQL names for all columns. Only to later realize to do the same with table names, I would have to specify all 9 names for each table to keep it consistent. Why there can't be a single name similar to columns that gets suffix?
Then I also realized that my actions use camelCase as well and I would have a total mess in naming conventions. On top of that, my backend uses the action name from the payload to identify action instead of having it in the URL. That would cascade into changes I am not comfortable with anymore.
So after weighing the pros/cons I've reverted everything back and I will rather deal with SQL from time to time than this craziness :/
For most users this customisation probably wouldn't be needed if Hasura would transform all table/column/relation names to GraphQL conventions automatically the same way that Postgraphile does it: https://www.graphile.org/postgraphile/inflection/
On one hand it's nice that you can rename all fields by yourself, but on the other it is frustrating that you're still stuck to the GraphQL type names that Hasura generates from tacked tables. For example, I now have camelCase fields but snake_case types and can't find any option to rename those types apart from defining new custom types.
The whole customization shouldn't even be necessary in the first place. I think it's a "nice to have", but more importantly, Hasura should apply common GraphQL conventions automatically or via a checkbox when you're about to track new tables. This is something that I, as a new user, miss by far the most after a few days playing around with Hasura.
Most helpful comment
For most users this customisation probably wouldn't be needed if Hasura would transform all table/column/relation names to GraphQL conventions automatically the same way that Postgraphile does it: https://www.graphile.org/postgraphile/inflection/
On one hand it's nice that you can rename all fields by yourself, but on the other it is frustrating that you're still stuck to the GraphQL type names that Hasura generates from tacked tables. For example, I now have camelCase fields but snake_case types and can't find any option to rename those types apart from defining new custom types.
The whole customization shouldn't even be necessary in the first place. I think it's a "nice to have", but more importantly, Hasura should apply common GraphQL conventions automatically or via a checkbox when you're about to track new tables. This is something that I, as a new user, miss by far the most after a few days playing around with Hasura.