scripts: add graphql:codegen script
This commit is contained in:
parent
751d18889d
commit
576f9092bd
@ -9,6 +9,7 @@
|
||||
"lint:fix": "next lint -- --fix",
|
||||
"start": "next start",
|
||||
"graphql:update": "node ./scripts/graphql-update.js",
|
||||
"graphql:codegen": "node ./scripts/graphql-codegen.js",
|
||||
"test": "jest"
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
3
apps/web/scripts/graphql-codegen.js
Normal file
3
apps/web/scripts/graphql-codegen.js
Normal file
@ -0,0 +1,3 @@
|
||||
const { generateTypescript } = require('./lib/graphql');
|
||||
|
||||
generateTypescript();
|
||||
@ -1,10 +1,4 @@
|
||||
const run = require('tools/scripts');
|
||||
const { downloadSchema, generateTypescript } = require('./lib/graphql');
|
||||
|
||||
const { URL_CRM_GRAPHQL_DIRECT } = process.env;
|
||||
const PATH_CRM_GRAPHQL_SCHEMA = './graphql/crm.schema.graphql';
|
||||
|
||||
const command1 = ['gql-sdl', URL_CRM_GRAPHQL_DIRECT, '-o', PATH_CRM_GRAPHQL_SCHEMA].join(' ');
|
||||
run(command1, 'Download GraphQL Schema...');
|
||||
|
||||
const command2 = ['graphql-codegen,', '--config', '.graphqlrc.yml'].join(' ');
|
||||
run(command2, 'Generating TypeScript code...');
|
||||
downloadSchema();
|
||||
generateTypescript();
|
||||
|
||||
18
apps/web/scripts/lib/graphql.js
Normal file
18
apps/web/scripts/lib/graphql.js
Normal file
@ -0,0 +1,18 @@
|
||||
const run = require('tools/scripts');
|
||||
|
||||
function downloadSchema() {
|
||||
const { URL_CRM_GRAPHQL_DIRECT } = process.env;
|
||||
const PATH_CRM_GRAPHQL_SCHEMA = './graphql/crm.schema.graphql';
|
||||
const command1 = ['gql-sdl', URL_CRM_GRAPHQL_DIRECT, '-o', PATH_CRM_GRAPHQL_SCHEMA].join(' ');
|
||||
run(command1, 'Download GraphQL Schema...');
|
||||
}
|
||||
|
||||
function generateTypescript() {
|
||||
const command2 = ['graphql-codegen,', '--config', '.graphqlrc.yml'].join(' ');
|
||||
run(command2, 'Generating TypeScript code...');
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
downloadSchema,
|
||||
generateTypescript,
|
||||
};
|
||||
@ -16,7 +16,8 @@
|
||||
"test": "dotenv -e .env.local turbo run test",
|
||||
"prepare": "husky install",
|
||||
"precommit": "yarn format && yarn lint:fix && yarn test",
|
||||
"graphql:update": "dotenv -e .env.local node ./scripts/graphql-update.js"
|
||||
"graphql:update": "dotenv -e .env.local node ./scripts/graphql-update.js",
|
||||
"graphql:codegen": "dotenv -e .env.local node ./scripts/graphql-codegen.js"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
|
||||
5
scripts/graphql-codegen.js
Normal file
5
scripts/graphql-codegen.js
Normal file
@ -0,0 +1,5 @@
|
||||
const run = require('tools/scripts');
|
||||
|
||||
const command = ['yarn', 'workspace', 'web', 'graphql:codegen'].join(' ');
|
||||
|
||||
run(command, '*** Update GraphQL files ***');
|
||||
Loading…
x
Reference in New Issue
Block a user