Skip to content
Browse files

fix(generation) - fix schema generation for enums in inheritance tree (


* fix(generation) - fix schema generation for enums in inheritence tree

* eliminating for loop
  • Loading branch information
pjpritch authored and deweyjose committed Sep 11, 2019
1 parent f52de49 commit 8779c3c0107ec42df329a52f568039630d2875cf
Showing with 7 additions and 2 deletions.
  1. +1 −1 src/decorators/EnumField.ts
  2. +6 −1 src/schema/TypeORMConverter.ts
@@ -8,7 +8,7 @@ import { composeMethodDecorators, generatedFolderPath, MethodDecoratorFactory }

interface EnumFieldOptions {
nullable?: boolean;
default?: boolean;
default?: any;

export function EnumField(name: string, enumeration: object, options: EnumFieldOptions = {}): any {
@@ -40,7 +40,12 @@ export function filenameToImportPath(filename: string): string {

export function extractEnumObject(column: ColumnMetadata): GraphQLEnumType {
return getMetadataStorage().getEnum(, column.propertyName);
const storage = getMetadataStorage();
const modelEnums = =>
storage.getEnum(, column.propertyName)

return modelEnums.find(m => Boolean(m));

export function columnToGraphQLType(column: ColumnMetadata): GraphQLScalarType | GraphQLEnumType {

1 comment on commit 8779c3c


This comment has been minimized.

Copy link
Collaborator Author

pjpritch commented on 8779c3c Sep 11, 2019

Currently, if one tries to use an Enum in an abstract base class, the property will be added to the generated Type as a Enum type and CreateInput, UpdateInput as String type. This means that no constraining validation will be done in mutations (any value can be submitted). The metadata storage system was not built for a multi-level entity hierarchy.

This bug fix is to check for a Enum info using each name in the inheritance tree, which returns the Enum metadata.

Please sign in to comment.
You can’t perform that action at this time.