How to change database schema and have queries/mutations still work? #7198
-
Hello! I am about to embark on a significant re-architecture of the Postgres database that our Hasura project uses. Namely, I am migrating some e-commerce product data to a new schema, but I will have mobile app users that are on older versions of the app still executing queries and mutations against an outdated schema. Currently the GraphQL schema and the database schema are intimately tied. I am wondering what the best way is to map existing parts of my GraphQL schema to the new database tables I am going to add? I looked this up and found the following advice in this Hasura blog post:
This sounds great! But when I try searching for Hasura named queries, I can't seem to find documentation on them. What are named queries and how do I do this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
IMO this is one of the issues with Hasura. The API is coupled with the database structure. Changes to the database will automatically change your API. To do what you want you will need to use the metadata API to add custom_root_fields I don't think you can have multiple values for the I know this is something Hasura was going to add to their cloud product. I don't use the cloud so I am not sure if that was added or not. Another option would be to add the old API schema as a |
Beta Was this translation helpful? Give feedback.
IMO this is one of the issues with Hasura. The API is coupled with the database structure. Changes to the database will automatically change your API.
To do what you want you will need to use the metadata API to add custom_root_fields
https://hasura.io/docs/latest/graphql/core/api-reference/metadata-api/table-view.html#pg-track-table
I don't think you can have multiple values for the
custom_root_fields
. You can change the database structure and remap using it but you can't have 2 different graphql-engines connected to the same database with different metadata.I know this is something Hasura was going to add to their cloud product. I don't use the cloud so I am not sure if that was added …