File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
packages/graphql/lib/schema-builder/factories Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change
1
+ import { upperCase } from 'lodash' ;
1
2
import { Injectable } from '@nestjs/common' ;
2
3
import { GraphQLEnumType } from 'graphql' ;
3
4
import { EnumMetadata } from '../metadata' ;
4
5
6
+ export const mapToUppercase = ( value : string ) : string =>
7
+ upperCase ( value ) . replace ( ' ' , '_' ) ;
8
+
5
9
export interface EnumDefinition {
6
10
enumRef : object ;
7
11
type : GraphQLEnumType ;
@@ -19,7 +23,13 @@ export class EnumDefinitionFactory {
19
23
description : metadata . description ,
20
24
values : Object . keys ( enumValues ) . reduce ( ( prevValue , key ) => {
21
25
const valueMap = metadata . valuesMap [ key ] ;
22
- prevValue [ key ] = {
26
+
27
+ let graphqlKey = key ;
28
+ if ( metadata . mapToUppercase ) {
29
+ graphqlKey = mapToUppercase ( key ) ;
30
+ }
31
+
32
+ prevValue [ graphqlKey ] = {
23
33
value : enumValues [ key ] ,
24
34
description : valueMap ?. description ,
25
35
deprecationReason : valueMap ?. deprecationReason ,
You can’t perform that action at this time.
0 commit comments