-1

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.

benams
  • 4,308
  • 9
  • 32
  • 74

3 Answers3

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: enter image description here

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 belowenter image description here

-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