Skip to content

rxvantage/hasura-camelize

 
 

Repository files navigation

Hasura TableName converter

CLI

npm i -g hasura-camelize

# Easy
hasura-camelize --host https://some.domain --secret some-secret

# Dry
hasura-camelize --host https://some.domain --secret some-secret --dry

# Exclude table names
hasura-camelize --host https://some.domain --secret some-secret --exclude some_table

# Include table names
hasura-camelize --host https://some.domain --secret some-secret --include some_table

From code

Simple

import convert from 'hasura-camelize';

convert(
  // connection settings
  {
    // domain name
    host: 'https://some.domain',
    // or ip
    host: 'http://127.0.0.1:3000',
    // admin secret
    secret: 'some-secret',
  }
);

Complex

import convert from 'hasura-camelize';

convert(
  // connection settings
  {
    // domain name
    host: 'https://some.domain',
    // or ip
    host: 'http://127.0.0.1:3000',
    // admin secret
    secret: 'some-secret',
    // optional schema (default 'public')
    schema: 'public',
    // optional source (default 'default')
    source: 'default',
  },
  // optional settings
  {
    // Dry run? (don't apply changes)
    dry: false,
    // Transform table names differently
    transformTableNames(
      name,
      defaultTransformer
    ) {
      // if name === some_name then ignore the table
      if (name === 'some_name') return false;
      return defaultTransformer(name);
    };
    // Transform column names differently
    transformColumnNames(
      name,
      tableName,
      defaultTransformer
    ) {
      // if name === some_name then ignore the column
      if (name === 'some_name' && tableName === 'some_name') return false;
      return defaultTransformer(name);
    };
    // Apply different root field names
    getRootFieldNames(
      name,
      defaultTransformer
    ) {
      return defaultTransformer(name);
    };
  }
);

Credits

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 87.4%
  • JavaScript 12.6%