-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtype-loader.js
39 lines (38 loc) · 1.02 KB
/
type-loader.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/* eslint-disable @typescript-eslint/no-var-requires */
const { createConfigLoader } = require('node-buffs');
const axios = require('axios');
const fsExtra = require('fs-extra');
const _ = require('lodash');
const util = require('util');
const configLoader = createConfigLoader();
const url = `${configLoader.loadConfig('ENDPOINT') ?? ''}/graphql`;
axios
.post(url, {
// language=GraphQL
query: `
{
sys_model_schemas {
name
schema
}
}
`,
})
.then((response) => {
const data = _.get(response.data, 'data.sys_model_schemas');
const schemas = _.map(data, (current) => ({
[current.name]: current.schema.map((v) => {
console.log(v.name, v.config.type);
return { [v.name]: '' };
}),
}));
console.log(util.inspect(schemas, { color: true, depth: 5 }));
fsExtra
.writeJson('./schema.json', schemas)
.then(() => {
console.log('success!');
})
.catch((err) => {
console.error(err);
});
});