Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gql-types-generator

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gql-types-generator - npm Package Compare versions

Comparing version 1.2.23 to 1.2.24

5

dist/compiler.d.ts

@@ -16,3 +16,3 @@ import { GraphQLSchema } from 'graphql';

*/
export declare function compileSchema(schemaString: string, outputDirectory: string, removeDescription?: boolean, display?: DisplayType): Promise<{
export declare function compileSchema(schemaString: string, outputDirectory: string, display?: DisplayType): Promise<{
schema: GraphQLSchema;

@@ -25,6 +25,5 @@ }>;

* @param schema
* @param removeDescription
*/
export declare function compileOperations(operationsString: string, outputDirectory: string, schema: GraphQLSchema, removeDescription?: boolean): Promise<{
export declare function compileOperations(operationsString: string, outputDirectory: string, schema: GraphQLSchema): Promise<{
compiledTypes: CompiledOperation[];
}>;

18

dist/compiler.js

@@ -68,3 +68,3 @@ "use strict";

_d.sent();
return [4 /*yield*/, compileSchema(schemaString, outputDirectory, removeDescription, display)];
return [4 /*yield*/, compileSchema(schemaString, outputDirectory, display)];
case 3:

@@ -88,3 +88,3 @@ schema = (_d.sent()).schema;

}
return [4 /*yield*/, compileOperations(operationsString, outputDirectory, schema, removeDescription)];
return [4 /*yield*/, compileOperations(operationsString, outputDirectory, schema)];
case 7:

@@ -99,3 +99,4 @@ compiledTypes = (_d.sent()).compiledTypes;

case 8:
utils_1.transpileTS(index, outputDirectory, 'index.ts', removeDescription);
fs_1.writeFile(outputDirectory, 'index.ts', index);
utils_1.transpileDirectory(outputDirectory, removeDescription);
console.log(chalk_1.yellow('Compilation completed successfully!'));

@@ -115,4 +116,3 @@ return [2 /*return*/];

*/
function compileSchema(schemaString, outputDirectory, removeDescription, display) {
if (removeDescription === void 0) { removeDescription = false; }
function compileSchema(schemaString, outputDirectory, display) {
if (display === void 0) { display = 'default'; }

@@ -136,3 +136,3 @@ return __awaiter(this, void 0, void 0, function () {

// Write all the schema into a single file
utils_1.transpileTS(schemaDefinition, outputDirectory, 'schema.ts', removeDescription);
fs_1.writeFile(outputDirectory, 'schema.ts', schemaDefinition);
return [2 /*return*/, { schema: schema }];

@@ -148,6 +148,4 @@ });

* @param schema
* @param removeDescription
*/
function compileOperations(operationsString, outputDirectory, schema, removeDescription) {
if (removeDescription === void 0) { removeDescription = false; }
function compileOperations(operationsString, outputDirectory, schema) {
return __awaiter(this, void 0, void 0, function () {

@@ -169,3 +167,3 @@ var documentNode, compiledTypes;

var ts = _a.ts, operationName = _a.operationName;
utils_1.transpileTS(ts, outputDirectory, operationName + ".ts", removeDescription);
fs_1.writeFile(outputDirectory, operationName + ".ts", ts);
});

@@ -172,0 +170,0 @@ return [2 /*return*/, { compiledTypes: compiledTypes }];

@@ -24,2 +24,9 @@ import * as shell from 'shelljs';

/**
* Writes content into file
* @param dir
* @param fileName
* @param content
*/
export declare function writeFile(dir: string, fileName: string, content: string): void;
/**
* Recursively creates directory

@@ -26,0 +33,0 @@ * @param {string} directory

@@ -50,2 +50,3 @@ "use strict";

var glob_1 = __importDefault(require("glob"));
var path = __importStar(require("path"));
var fs = __importStar(require("fs"));

@@ -134,2 +135,12 @@ var shell = __importStar(require("shelljs"));

/**
* Writes content into file
* @param dir
* @param fileName
* @param content
*/
function writeFile(dir, fileName, content) {
fs.writeFileSync(path.resolve(dir, fileName), content);
}
exports.writeFile = writeFile;
/**
* Recursively creates directory

@@ -136,0 +147,0 @@ * @param {string} directory

/**
* Transpiles TypeScript code
* @param {string} tsCode
* @param {string} outputDirectory
* @param {string} fileName
* @param directory
* @param {boolean} removeComments
*/
export declare function transpileTS(tsCode: string, outputDirectory: string, fileName: string, removeComments: boolean): void;
export declare function transpileDirectory(directory: string, removeComments: boolean): void;

@@ -15,9 +15,7 @@ "use strict";

* Transpiles TypeScript code
* @param {string} tsCode
* @param {string} outputDirectory
* @param {string} fileName
* @param directory
* @param {boolean} removeComments
*/
function transpileTS(tsCode, outputDirectory, fileName, removeComments) {
var filePath = path.resolve(outputDirectory, fileName);
function transpileDirectory(directory, removeComments) {
var files = fs.readdirSync(directory).map(function (f) { return path.resolve(directory, f); });
var options = {

@@ -37,10 +35,8 @@ declaration: true,

};
// Create TS original file with code
fs.writeFileSync(filePath, tsCode);
// Transpile with typescript
var program = ts.createProgram([filePath], options);
var program = ts.createProgram(files, options);
program.emit();
// Remove original file
fs.unlinkSync(filePath);
// Remove ts files
files.forEach(function (f) { return fs.unlinkSync(f); });
}
exports.transpileTS = transpileTS;
exports.transpileDirectory = transpileDirectory;
{
"name": "gql-types-generator",
"version": "1.2.23",
"version": "1.2.24",
"main": "dist/index.js",

@@ -5,0 +5,0 @@ "types": "dist/index.d.ts",

@@ -129,3 +129,2 @@ gql-types-generator

| `outputDirectory` | `string` | Full path to output directory |
| `includeDescription` | `boolean?` | Should library include descriptions |
| `display` | `DisplayType?` | How to display compiled types. Valid values are "as-is" and "default". By default, generator compiles scalars first, then enums, interfaces, inputs, unions and then types. "as-is" places types as they are placed in schema |

@@ -141,3 +140,2 @@

path.resolve(__dirname, 'gql/compiled'),
true,
'default',

@@ -157,3 +155,2 @@ );

| `schema` | `GraphQLSchema` | Built GQL schema |
| `removeDescription` | `boolean?` | Should library remove descriptions |

@@ -170,4 +167,3 @@ #### Example

gqlSchema,
true,
);
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc