Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/joaom182/xsura
Tooling for Hasura
https://github.com/joaom182/xsura
Last synced: 3 months ago
JSON representation
Tooling for Hasura
- Host: GitHub
- URL: https://github.com/joaom182/xsura
- Owner: joaom182
- Created: 2021-09-15T01:02:39.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2021-09-15T13:27:45.000Z (about 3 years ago)
- Last Synced: 2024-04-24T17:27:17.280Z (6 months ago)
- Language: TypeScript
- Size: 120 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-hasura - xsura
README
# About
This is a tool to migrate data between two Hasura instances through the GraphQL endpoints# The problem
If you are trying to migrate data from an Hasura environment to another that runs in a free tier, you will face issues with the permission level of your Postgres credentials.For example, if you try to run the COPY command to import the data from a CSV file using the Postgres CLI `psql`, you will receive this error message:
```
ERROR: must be a superuser or a member of the pg_read_server_files role to COPY from a file
```This error occurs because a free tier instance of Hasura runs in a shared server, which means that the database server, has many other users running their databases, and it's reasonable to you not have a superuser or a different grant on the database server due to security reasons.
# Solution
Fetch the data using the GraphQL introspection query to discover the properties/fields of each table/field on GraphQL, and dynamically insert it to the tables using the Hasura insert mutation convention `insert_`# Installing
```
yarn global add xsura
```# Commands
## copy
Copy the data from an instance of Hasura to another instance of Hasura```bash
xsura copy \
--fields="table_a,table_b" \
--source="https://source.hasura.app/v1/graphql" \
--source-headers="x-hasura-admin-secret|ADMIN_SECRET_KEY" \
--target="https://target.hasura.app/v1/graphql" \
--target-headers="x-hasura-admin-secret|ADMIN_SECRET_KEY"
```# Options
## --fields
GraphQL fields that you want to copy to the target## --source
GraphQL URL of your source server
## --source-headers
Headers that you may need to use to authenticate your requests for you source server
## --target
GraphQL URL of your target server## --target-headers
Headers that you may need to use to authenticate your requests for you target server