diff --git a/src/__tests__/__snapshots__/strictMode.test.ts.snap b/src/__tests__/__snapshots__/strictMode.test.ts.snap index caa030e..f452211 100644 --- a/src/__tests__/__snapshots__/strictMode.test.ts.snap +++ b/src/__tests__/__snapshots__/strictMode.test.ts.snap @@ -35,7 +35,7 @@ export interface GQLUser { */ username: string; email: string; - role: GQLUserRole; + role: keyof typeof GQLUserRole; /** * Url to the image diff --git a/src/__tests__/__snapshots__/typeScriptGenerator.test.ts.snap b/src/__tests__/__snapshots__/typeScriptGenerator.test.ts.snap index b6127bd..aacee0b 100644 --- a/src/__tests__/__snapshots__/typeScriptGenerator.test.ts.snap +++ b/src/__tests__/__snapshots__/typeScriptGenerator.test.ts.snap @@ -35,7 +35,7 @@ export interface GQLUser { */ username: string; email: string; - role: GQLUserRole; + role: keyof typeof GQLUserRole; /** * Url to the image diff --git a/src/utils.ts b/src/utils.ts index e45930a..6a9083c 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -156,6 +156,9 @@ export const getTypeToTS = (field: any, prefix: string, nonNullable: boolean = f if (field.kind === 'LIST') { tsType = getTypeToTS(field.ofType, prefix, false); tsType = `Array<${tsType}>`; + } else if (field.kind === 'ENUM') { + tsType = gqlScalarToTS(field.name, prefix); + tsType = `keyof typeof ${tsType}`; } else { tsType = gqlScalarToTS(field.name, prefix); }