
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
graphql-mysql-schema
Advanced tools
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
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
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.