gql-types-generator
Advanced tools
Comparing version 1.2.4 to 1.2.5
@@ -11,5 +11,6 @@ import { ParsedGQLEnumType, ParsedGQLOperation, ParsedGQLScalarType, ParsedGQLType, ParsedGQLTypeOrInterface, ParsedGQLUnionType } from '../types'; | ||
* @param {ParsedGQLTypeOrInterface} parsedType | ||
* @param importsRequired | ||
* @returns {string} | ||
*/ | ||
export declare function generateGQLInterface(parsedType: ParsedGQLTypeOrInterface): string; | ||
export declare function generateGQLInterface(parsedType: ParsedGQLTypeOrInterface, importsRequired?: boolean): string; | ||
/** | ||
@@ -16,0 +17,0 @@ * GQL enum => TS enum |
@@ -25,5 +25,7 @@ "use strict"; | ||
* @param {ParsedGQLTypeOrInterface} parsedType | ||
* @param importsRequired | ||
* @returns {string} | ||
*/ | ||
function generateGQLInterface(parsedType) { | ||
function generateGQLInterface(parsedType, importsRequired) { | ||
if (importsRequired === void 0) { importsRequired = false; } | ||
var name = parsedType.name, description = parsedType.description, fields = parsedType.fields; | ||
@@ -35,6 +37,8 @@ var _a = fields.reduce(function (acc, f) { | ||
acc.definition += fullDefinition; | ||
for (var _i = 0, requiredTypes_1 = requiredTypes; _i < requiredTypes_1.length; _i++) { | ||
var type = requiredTypes_1[_i]; | ||
if (!acc.requiredTypes.includes(type)) { | ||
acc.requiredTypes.push(type); | ||
if (importsRequired) { | ||
for (var _i = 0, requiredTypes_1 = requiredTypes; _i < requiredTypes_1.length; _i++) { | ||
var type = requiredTypes_1[_i]; | ||
if (!acc.requiredTypes.includes(type)) { | ||
acc.requiredTypes.push(type); | ||
} | ||
} | ||
@@ -98,3 +102,3 @@ } | ||
+ ("export declare interface " + operationName + " " + operationDefinition + "\n\n") | ||
+ generateGQLInterface(variables) + '\n\n' | ||
+ generateGQLInterface(variables, true) + '\n\n' | ||
+ ("declare const " + operationStringName + ": string;\n") | ||
@@ -101,0 +105,0 @@ + ("export default " + operationStringName + ";"); |
{ | ||
"name": "gql-types-generator", | ||
"version": "1.2.4", | ||
"version": "1.2.5", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "types": "dist/index.d.ts", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
61550
1459