graphql-codegen-typescript
Advanced tools
Comparing version 0.18.0-alpha.cab8e330 to 0.19.0-alpha.2249ff45
@@ -8,4 +8,5 @@ import { PluginFunction } from 'graphql-codegen-core'; | ||
enumsAsTypes?: boolean; | ||
immutableTypes?: boolean; | ||
maybeValue?: string; | ||
} | ||
export declare const plugin: PluginFunction<TypeScriptPluginConfig>; |
@@ -5,3 +5,4 @@ import { OperationVariablesToObject, ScalarsMap, ConvertNameFn } from 'graphql-codegen-visitor-plugin-common'; | ||
private _avoidOptionals; | ||
constructor(_scalars: ScalarsMap, _convertName: ConvertNameFn, _avoidOptionals: boolean); | ||
private _immutableTypes; | ||
constructor(_scalars: ScalarsMap, _convertName: ConvertNameFn, _avoidOptionals: boolean, _immutableTypes: boolean); | ||
private clearOptional; | ||
@@ -8,0 +9,0 @@ wrapAstTypeWithModifiers(baseType: string, typeNode: TypeNode): string; |
@@ -20,5 +20,6 @@ "use strict"; | ||
__extends(TypeScriptOperationVariablesToObject, _super); | ||
function TypeScriptOperationVariablesToObject(_scalars, _convertName, _avoidOptionals) { | ||
function TypeScriptOperationVariablesToObject(_scalars, _convertName, _avoidOptionals, _immutableTypes) { | ||
var _this = _super.call(this, _scalars, _convertName) || this; | ||
_this._avoidOptionals = _avoidOptionals; | ||
_this._immutableTypes = _immutableTypes; | ||
return _this; | ||
@@ -39,3 +40,3 @@ } | ||
var innerType = this.wrapAstTypeWithModifiers(baseType, typeNode.type); | ||
return "Maybe<Array<" + innerType + ">>"; | ||
return "Maybe<" + (this._immutableTypes ? 'ReadonlyArray' : 'Array') + "<" + innerType + ">>"; | ||
} | ||
@@ -42,0 +43,0 @@ else { |
@@ -8,2 +8,3 @@ import { BaseVisitor, ParsedConfig } from 'graphql-codegen-visitor-plugin-common'; | ||
enumsAsTypes: boolean; | ||
immutableTypes: boolean; | ||
maybeValue: string; | ||
@@ -16,2 +17,3 @@ } | ||
ListType(node: ListTypeNode): string; | ||
protected wrapWithListType(str: string): string; | ||
NonNullType(node: NonNullTypeNode): string; | ||
@@ -18,0 +20,0 @@ FieldDefinition(node: FieldDefinitionNode, key?: number | string, parent?: any): string; |
@@ -27,6 +27,7 @@ "use strict"; | ||
constEnums: pluginConfig.constEnums || false, | ||
enumsAsTypes: pluginConfig.enumsAsTypes || false | ||
enumsAsTypes: pluginConfig.enumsAsTypes || false, | ||
immutableTypes: pluginConfig.immutableTypes || false | ||
}, null) || this; | ||
autoBind(_this); | ||
_this.setArgumentsTransformer(new typescript_variables_to_object_1.TypeScriptOperationVariablesToObject(_this.scalars, _this.convertName, _this.config.avoidOptionals)); | ||
_this.setArgumentsTransformer(new typescript_variables_to_object_1.TypeScriptOperationVariablesToObject(_this.scalars, _this.convertName, _this.config.avoidOptionals, _this.config.immutableTypes)); | ||
_this.setDeclarationBlockConfig({ | ||
@@ -49,2 +50,5 @@ enumNameValueSeparator: ' =' | ||
}; | ||
TsVisitor.prototype.wrapWithListType = function (str) { | ||
return (this.config.immutableTypes ? 'ReadonlyArray' : 'Array') + "<" + str + ">"; | ||
}; | ||
TsVisitor.prototype.NonNullType = function (node) { | ||
@@ -58,3 +62,3 @@ var baseValue = _super.prototype.NonNullType.call(this, node); | ||
var addOptionalSign = !this.config.avoidOptionals && originalFieldNode.type.kind !== 'NonNullType'; | ||
return graphql_codegen_visitor_plugin_common_1.indent("" + node.name + (addOptionalSign ? '?' : '') + ": " + typeString + ","); | ||
return graphql_codegen_visitor_plugin_common_1.indent("" + (this.config.immutableTypes ? 'readonly ' : '') + node.name + (addOptionalSign ? '?' : '') + ": " + typeString + ","); | ||
}; | ||
@@ -61,0 +65,0 @@ TsVisitor.prototype.EnumTypeDefinition = function (node) { |
{ | ||
"name": "graphql-codegen-typescript", | ||
"version": "0.18.0-alpha.cab8e330", | ||
"version": "0.19.0-alpha.2249ff45", | ||
"description": "GraphQL Code Generator plugin for generating TypeScript types", | ||
@@ -14,5 +14,5 @@ "repository": "git@github.com:dotansimha/graphql-code-generator.git", | ||
"dependencies": { | ||
"graphql-codegen-core": "0.18.0-alpha.cab8e330", | ||
"graphql-codegen-plugin-helpers": "0.18.0-alpha.cab8e330", | ||
"graphql-codegen-visitor-plugin-common": "0.18.0-alpha.cab8e330" | ||
"graphql-codegen-core": "0.19.0-alpha.2249ff45", | ||
"graphql-codegen-plugin-helpers": "0.19.0-alpha.2249ff45", | ||
"graphql-codegen-visitor-plugin-common": "0.19.0-alpha.2249ff45" | ||
}, | ||
@@ -19,0 +19,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
16322
221
+ Addedaggregate-error@2.1.0(transitive)
+ Addedgraphql-codegen-core@0.19.0-alpha.2249ff45(transitive)
+ Addedgraphql-codegen-plugin-helpers@0.19.0-alpha.2249ff45(transitive)
+ Addedgraphql-codegen-visitor-plugin-common@0.19.0-alpha.2249ff45(transitive)
+ Addedgraphql-toolkit@0.2.0(transitive)
- Removedaggregate-error@2.0.0(transitive)
- Removedgraphql-codegen-core@0.18.0-alpha.cab8e330(transitive)
- Removedgraphql-codegen-plugin-helpers@0.18.0-alpha.cab8e330(transitive)
- Removedgraphql-codegen-visitor-plugin-common@0.18.0-alpha.cab8e330(transitive)
- Removedgraphql-toolkit@0.1.1(transitive)
Updatedgraphql-codegen-visitor-plugin-common@0.19.0-alpha.2249ff45