graphql-codegen-typescript
Advanced tools
Comparing version 0.18.0-alpha.b1641564 to 0.18.0-alpha.cab8e330
@@ -6,4 +6,6 @@ import { PluginFunction } from 'graphql-codegen-core'; | ||
avoidOptionals?: boolean; | ||
constEnums?: boolean; | ||
enumsAsTypes?: boolean; | ||
maybeValue?: string; | ||
} | ||
export declare const plugin: PluginFunction<TypeScriptPluginConfig>; |
import { BaseVisitor, ParsedConfig } from 'graphql-codegen-visitor-plugin-common'; | ||
import { TypeScriptPluginConfig } from './index'; | ||
import { FieldDefinitionNode, NamedTypeNode, ListTypeNode, NonNullTypeNode } from 'graphql'; | ||
import { FieldDefinitionNode, NamedTypeNode, ListTypeNode, NonNullTypeNode, EnumTypeDefinitionNode } from 'graphql'; | ||
export interface TypeScriptPluginParsedConfig extends ParsedConfig { | ||
avoidOptionals: boolean; | ||
constEnums: boolean; | ||
enumsAsTypes: boolean; | ||
maybeValue: string; | ||
@@ -15,2 +17,3 @@ } | ||
FieldDefinition(node: FieldDefinitionNode, key?: number | string, parent?: any): string; | ||
EnumTypeDefinition(node: EnumTypeDefinitionNode): string; | ||
} |
@@ -25,3 +25,5 @@ "use strict"; | ||
avoidOptionals: pluginConfig.avoidOptionals || false, | ||
maybeValue: pluginConfig.maybeValue || 'T | null' | ||
maybeValue: pluginConfig.maybeValue || 'T | null', | ||
constEnums: pluginConfig.constEnums || false, | ||
enumsAsTypes: pluginConfig.enumsAsTypes || false | ||
}, null) || this; | ||
@@ -57,2 +59,19 @@ autoBind(_this); | ||
}; | ||
TsVisitor.prototype.EnumTypeDefinition = function (node) { | ||
var _this = this; | ||
if (this.config.enumsAsTypes) { | ||
return new graphql_codegen_visitor_plugin_common_1.DeclarationBlock(this._declarationBlockConfig) | ||
.export() | ||
.asKind('type') | ||
.withName(this.convertName(node.name)) | ||
.withContent(node.values.map(function (v) { return "'" + (_this.config.enumValues[v.name] || v.name) + "'"; }).join(' | ')).string; | ||
} | ||
else { | ||
return new graphql_codegen_visitor_plugin_common_1.DeclarationBlock(this._declarationBlockConfig) | ||
.export() | ||
.asKind(this.config.constEnums ? 'const enum' : 'enum') | ||
.withName(this.convertName(node.name)) | ||
.withBlock(this.buildEnumValuesBlock(node.values)).string; | ||
} | ||
}; | ||
return TsVisitor; | ||
@@ -59,0 +78,0 @@ }(graphql_codegen_visitor_plugin_common_1.BaseVisitor)); |
{ | ||
"name": "graphql-codegen-typescript", | ||
"version": "0.18.0-alpha.b1641564", | ||
"version": "0.18.0-alpha.cab8e330", | ||
"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.b1641564", | ||
"graphql-codegen-plugin-helpers": "0.18.0-alpha.b1641564", | ||
"graphql-codegen-visitor-plugin-common": "0.18.0-alpha.b1641564" | ||
"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" | ||
}, | ||
@@ -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
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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
15349
212
0
+ Addedaggregate-error@2.0.0(transitive)
+ Addedclean-stack@2.2.0(transitive)
+ Addeddeepmerge@3.2.0(transitive)
+ Addedgraphql-codegen-core@0.18.0-alpha.cab8e330(transitive)
+ Addedgraphql-codegen-plugin-helpers@0.18.0-alpha.cab8e330(transitive)
+ Addedgraphql-codegen-visitor-plugin-common@0.18.0-alpha.cab8e330(transitive)
+ Addedgraphql-tag-pluck@0.6.0(transitive)
+ Addedgraphql-toolkit@0.1.1(transitive)
+ Addedindent-string@3.2.0(transitive)
- Removeddeepmerge@3.1.0(transitive)
- Removedgraphql-codegen-core@0.18.0-alpha.b1641564(transitive)
- Removedgraphql-codegen-plugin-helpers@0.18.0-alpha.b1641564(transitive)
- Removedgraphql-codegen-visitor-plugin-common@0.18.0-alpha.b1641564(transitive)
- Removedgraphql-tag-pluck@0.5.0(transitive)
- Removedgraphql-toolkit@0.0.5(transitive)
Updatedgraphql-codegen-visitor-plugin-common@0.18.0-alpha.cab8e330