Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
graphql-mysql-schema
Advanced tools
Readme
Generate mysql table schema to graphql defination
npm install graphql-mysql-schema --save
const mysqlGQL = require('graphql-mysql-schema');
let r = await mysqlGQL({
host: '127.0.0.1',
port: 3306,
user: "myuser",
password: 'mypwd',
database: 'db1'
}, {
tableName: 't1'
});
console.log(r);
output:
type t2 {
# comment of c1
c1: String,
# comment of c2
c2: Int,
c3: String,
# comment of c4
c4: Float,
# comment of c5
c5: Int,
}
default generate rules:
mysql type | graphql type |
---|---|
varchar | String |
char | String |
tinytext | String |
mediumtext | String |
longtext | String |
int | Int |
tinyint | Int |
smallint | Int |
mediumint | Int |
bigint | Int |
float | Float |
double | Float |
real | Float |
decimal | Float |
date | String |
time | String |
datetime | String |
timestamp | String |
year | String |
Others | UNKNOWN |
mysqlGQL(mysqlOpt, options)
mysqlOpt: reference
options:
string
, name of mysql table. requiredfunction
or object
, rule of generating columns, user-defined rule. optionalExample: override default type rules
// "varchar" will be generated as "my-type" type, instead of "String"
const overrideRules = {
varchar: 'my-type',
};
let r = await mysqlGQL({
host: '127.0.0.1',
port: 3306,
user: "root",
password: 'pwd',
database: 'db'
}, {
tableName: 'tn',
genRule: overrideRules
});
console.log(r);
Example: user define generate rule
const TypeMap = {
varchar: 'String',
char: 'String',
tinytext: 'String',
text: 'String',
// ...
};
// input: string, column type in mysql
function genType(input) {
let gType = TypeMap.hasOwnProperty(input) ? TypeMap[input] : 'UNKNOWN';
return gType;
}
let r = await mysqlGQL({
host: '127.0.0.1',
port: 3306,
user: "myuser",
password: 'mypwd',
database: 'db1'
}, {
tableName: 't2',
genFn: genType
});
console.log(r);
npm install graphql-mysql-schema -g
mygql -H 127.0.0.1 -P 3306 -U myuser -p mypwd -D mydb t2
output:
type t2 {
# comment of c1
c1: String,
# comment of c2
c2: Int,
c3: String,
# comment of c4
c4: Float,
# comment of c5
c5: Int,
}
options:
Usage: mygql [options] <tablename ...>
Options:
-V, --version output the version number
-H, --host [value] Mysql host
-P, --port [value] Mysql port
-U, --user [value] Mysql user
-p, --pwd [value] Mysql password
-D, --database [value] Mysql database
-h, --help output usage information
npm test
FAQs
Generate mysql table schema to graphql defination
The npm package graphql-mysql-schema receives a total of 202 weekly downloads. As such, graphql-mysql-schema popularity was classified as not popular.
We found that graphql-mysql-schema demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.