In my aplications I use Hasura for my graphql server and Apollo for the client. I have a postgres schema with snake_case table and field names, but I want to have camelCases keys in my responses' objects. Any known way to achieve that? I can see that apollo server offers fieldResolver where it can be done(Convert snake_case to camelCase field names in apollo-server-express), but I found no similar option for Hasura/ApolloClient.
Asked
Active
Viewed 641 times
-1
-
1https://github.com/hasura/graphql-engine/issues/3320 – Abraham Labkovsky Dec 23 '20 at 15:07
3 Answers
1
To make a long story short - currently, there is no such a solution for Hasura. The best suggestion I could get was to rename the column names manually, one-by-one via the console => DATA section => Modify tab:

benams
- 4,308
- 9
- 32
- 74
0
you can expose any column with a different name in the GraphQLAPI without you having to rename the column itself...
you can do that in the hasura console as in the picture below

Muluken Getachew
- 858
- 6
- 8
-1
Any way to achieve that?
Check out GraphQL aliases.
https://graphql.org/learn/queries/#aliases https://hasura.io/blog/customising-alias-graphql-fields-with-hasura/
Example:
# Query
query {
users {
id
name: full_name
email: email_addr
}
}
# Response
{
"data": {
"users": [
{
"id": "3ea1352a-6654-444d-9357-62816ccbd2b3",
"name": "Praveen",
"email": "email@mydomain.com"
}
]
}
}

jmdavalos
- 168
- 6