All Projects → puzl-ee → hasura-metadata-patcher

puzl-ee / hasura-metadata-patcher

Licence: MIT License
CLI tool to patch Hasura metadata json file. Helps to organize complex CI/CD flows through different environments.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to hasura-metadata-patcher

instagram-clone
Instagram clone using apollo, react and graphQl (hasura-graphQl engine)
Stars: ✭ 44 (+214.29%)
Mutual labels:  hasura, hasura-graphql-engine
hasura-node-monolith-example
Example of a monolithic web application using Hasura GraphQL Engine + Node.js + Next.js
Stars: ✭ 25 (+78.57%)
Mutual labels:  hasura, hasura-graphql-engine
mongration
MongoDB data migration tool for Spring Boot projects
Stars: ✭ 21 (+50%)
Mutual labels:  migration, migration-tool
maildir2gmail
Maildir 2 Gmail
Stars: ✭ 14 (+0%)
Mutual labels:  migration, migration-tool
hasura-sdk
Hasura Schema & Metadata Typescript SDK
Stars: ✭ 21 (+50%)
Mutual labels:  metadata, hasura
Migrate2Postgres
Easily migrate from other DBMSs to PostgreSQL
Stars: ✭ 47 (+235.71%)
Mutual labels:  migration, migration-tool
roda
RODA - Repository of Authentic Digital Objects
Stars: ✭ 54 (+285.71%)
Mutual labels:  metadata, migration
toggl2clockify
Migrate data from toggl to clockify
Stars: ✭ 21 (+50%)
Mutual labels:  migration, migration-tool
butterfly
Application transformation tool
Stars: ✭ 35 (+150%)
Mutual labels:  migration, migration-tool
mgmigrate
mgmigrate is a tool for migrating data from MySQL or PostgreSQL to Memgraph and between Memgraph instances.
Stars: ✭ 17 (+21.43%)
Mutual labels:  migration, migration-tool
metaschema
Schema definition and validation 💡
Stars: ✭ 25 (+78.57%)
Mutual labels:  metadata
github-migrator
GitHub repository migrator
Stars: ✭ 39 (+178.57%)
Mutual labels:  migration-tool
carpenter
Carpenter is a tool to manage DB schema and data
Stars: ✭ 41 (+192.86%)
Mutual labels:  migration
management-sdk
GraphCMS Management SDK
Stars: ✭ 43 (+207.14%)
Mutual labels:  migration-tool
time-api
Nodejs API for Wobbly Time Tracker for the Teams
Stars: ✭ 24 (+71.43%)
Mutual labels:  hasura
PHES-ODM
Metadata and code to support covid-19 wastewater surveillance and open science.
Stars: ✭ 34 (+142.86%)
Mutual labels:  metadata
kendraio-app
Kendraio App
Stars: ✭ 19 (+35.71%)
Mutual labels:  metadata
laravel-online-migrator
Apply Laravel's database migrations with minimal disruptions using tools like Percona Online Schema Change
Stars: ✭ 43 (+207.14%)
Mutual labels:  migration
plow
👨‍🌾 Postgres migrations and seeding made easy
Stars: ✭ 13 (-7.14%)
Mutual labels:  migration
pipeline-lib
Global shared library for Glia pipeline jobs
Stars: ✭ 68 (+385.71%)
Mutual labels:  ci-cd

What it is

CLI tool to patch Hasura metadata json file with needed objects or with another Hasura metadata file. You can use it to deploy complex CI/CD flows for applications, which are using Hasura on a backend.

Why it is useful

If you use different environments, you likely have different webhooks in each environment. With this tool you can describe needed metadata for each webhook separately and finally merge them all when you need to deploy your release. Such approach gives an ability to several people to develop different webhooks independently.

Requirements

  • Python 3.6 or higher
  • requirements.txt

How it works

Syntax

python main.py -r remote_schemas -r actions -r custom_types -r event_triggers -s dev_metadata.json -m prod_metadata.json -o out.json

Find all the syntax by python main.py --help

Supported operations

Merge

Default mode. Use it to merge needed Hasura objects from a mixin file to a source metadata file.

Replace -r

Use it to define, which objects should be fully replaced in a source metadata file by objects from a mixin.

For example, if a mixin file is another Hasura metadata file and you call

python main.py -r event_triggers -s dev_metadata.json -m prod_metadata.json -o out.json

then:

  1. All the metadata objects from prod_metadata.json will be mixed in to metadata from dev_metadata.json. This means that if object does not exist in dev_metadata.json, it will be created, but if exists it will be replaced with new object from a mixin file prod_metadata.json.
  2. All the event triggers will be removed for all the tables in the resulted metadata from the previous step.
  3. New event triggers from prod_metadata.json will be inserted instead.
  4. The result metadata goes to out.json.

Typical Hasura metadata release flow

  1. Export metadata in json format from Hasura in dev environment, which should be deployed to production.
  2. Export metadata in json format from Hasura in current production environment.
  3. Run patcher with source json file from dev and mixin file from production.
  4. Run patcher with output json file from previous step and mixin files with new Hasura objects to deploy.
  5. The last output file is your new Hasura metadata for production environment.

Points 1-3 are needed to migrate new tables and permissions from dev environment, since they are not supported by this patcher for now.

Supported Hasura objects

  • Event triggers
  • Remote schemas
  • Actions
  • Custom types (object types and input types)
  • Sources
  • Tables
  • Table permissions

Hasura objects format to patch

Event trigger

{
    "type": "event_trigger",
    "object": {
        "name": "myEventTrigger",
        "table": {
            "schema": "core",
            "name": "some_table"
        },
        "definition": {
            "enable_manual": false,
            "insert": {
                "columns": "*"
            },
            "update": {
                "columns": []
            }
        },
        "retry_conf": {
            "num_retries": 0,
            "interval_sec": 10,
            "timeout_sec": 60
        },
        "webhook": "https://mywebhook.url",
        "config": "1.2.3",
        "headers": [{
            "name": "token",
            "value": "%TOKEN_ENV%"
        }],
        "comment": "0.1.0"
    }
}

Action

{
  "type": "action",
  "object": {
      "name": "myAction",
      "definition": {
        "handler": "https://mywebhook.url",
        "output_type": "myOutputType",
        "headers": [
          {
            "name": "Authorization",
            "value_from_env": "AUTHORIZATION_HEADER"
          }
        ],
        "arguments": [
          {
            "name": "value",
            "type": "String!"
          }
        ],
        "type": "mutation",
        "kind": "synchronous"
      },
      "permissions": [
        {
          "role": "user"
        }
      ],
      "comment": "0.1.0"
  }
}

Custom type

{
    "type": "custom_type",
    "object": {
      "name": "myCustomType",
      "fields": [
        {
          "name": "affected_rows",
          "type": "Int!"
        }
      ]
    }
}

Remote schema

{
    "type": "remote_schema",
    "object": {
      "name": "myRemoteSchema",
      "definition": {
        "url": "https://myschema.url/graphql",
        "timeout_seconds": 60,
        "forward_client_headers": false,
        "headers": [
          {
            "name": "Authorization",
            "value_from_env": "AUTHORIZATION_HEADER"
          }
        ]
      },
      "comment": "0.1.0"
    }
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].