@@ -15,9 +15,7 @@ export const GQ_QUERY_KEY = 'gq_query';
1515export const GQ_MUTATION_KEY = 'gq_mutation' ;
1616export const GQ_SUBSCRIPTION_KEY = 'gq_subscription' ;
1717export const GQ_FIELDS_KEY = 'gq_fields' ;
18- export const GQ_VALUES_KEY = 'gq_values' ;
1918export const GQ_OBJECT_METADATA_KEY = 'gq_object_type' ;
20- export const GQ_ENUM_METADATA_KEY = 'gq_enum_type' ;
2119export const GQ_DESCRIPTION_KEY = 'gq_description' ;
2220
2321export interface TypeMetadata {
@@ -54,18 +52,6 @@ export interface ObjectTypeMetadata {
5452 isInput ?: boolean ;
5553}
5654
57- export interface EnumTypeMetadata {
58- name ?: string ;
59- description ?: string ;
60- values ?: EnumValueMetadata [ ] ;
61- }
62-
63- export interface EnumValueMetadata {
64- name : string ;
65- value ?: any ;
66- description ?: string ;
67- }
68-
6955export interface DefaultOption {
7056 description ?: string ;
7157}
@@ -119,32 +105,6 @@ function createOrSetObjectTypeMetadata(target: any, metadata: ObjectTypeMetadata
119105 }
120106}
121107
122- function createOrSetEnumTypeMetadata ( target : any , metadata : EnumTypeMetadata ) {
123- if ( ! Reflect . hasMetadata ( GQ_ENUM_METADATA_KEY , target . prototype ) ) {
124- let mergedMetadata = mergeDescriptionMetadata ( target , metadata ) ;
125- Reflect . defineMetadata ( GQ_ENUM_METADATA_KEY , mergedMetadata , target . prototype ) ;
126- } else {
127- const originalMetadata = Reflect . getMetadata ( GQ_ENUM_METADATA_KEY , target . prototype ) as EnumTypeMetadata ;
128- Object . assign ( originalMetadata , metadata ) ;
129- }
130- }
131-
132- function createOrSetValueTypeMetadata ( target : any , metadata : EnumValueMetadata ) {
133- let valueDefs : EnumValueMetadata [ ] ;
134- if ( ! Reflect . hasMetadata ( GQ_VALUES_KEY , target ) ) {
135- valueDefs = [ ] ;
136- Reflect . defineMetadata ( GQ_VALUES_KEY , valueDefs , target ) ;
137- } else {
138- valueDefs = Reflect . getMetadata ( GQ_VALUES_KEY , target ) ;
139- }
140- const def = valueDefs . find ( d => d . name === metadata . name ) ;
141- if ( ! def ) {
142- let propertyDescriptionMetadata = getPropertyDescriptionMetadata ( target , metadata . name ) ;
143- Object . assign ( metadata , propertyDescriptionMetadata ) ;
144- valueDefs . push ( metadata ) ;
145- }
146- }
147-
148108function createOrSetFieldTypeMetadata ( target : any , metadata : FieldTypeMetadata ) {
149109 let fieldDefs : FieldTypeMetadata [ ] ;
150110 if ( ! Reflect . hasMetadata ( GQ_FIELDS_KEY , target ) ) {
@@ -202,13 +162,6 @@ export function getFieldMetadata(target: any, name: string) {
202162 return ( < FieldTypeMetadata [ ] > Reflect . getMetadata ( GQ_FIELDS_KEY , target ) ) . find ( m => m . name === name ) ;
203163}
204164
205- export function getValueMetadata ( target : any , name : string ) {
206- if ( ! Reflect . hasMetadata ( GQ_VALUES_KEY , target ) ) {
207- return null ;
208- }
209- return ( < EnumValueMetadata [ ] > Reflect . getMetadata ( GQ_VALUES_KEY , target ) ) . find ( m => m . name === name ) ;
210- }
211-
212165function setArgumentMetadata ( target : any , propertyKey : any , index : number , metadata : ArgumentMetadata ) {
213166 const fieldMetadata = getFieldMetadata ( target , propertyKey ) ;
214167 if ( fieldMetadata && fieldMetadata . args && fieldMetadata . args [ index ] ) {
@@ -258,11 +211,6 @@ function setDescriptionMetadata(description: string, target: any, propertyKey: s
258211 name : propertyKey ,
259212 description : description ,
260213 } ) ;
261- } else if ( getValueMetadata ( target , propertyKey ) != null ) {
262- createOrSetValueTypeMetadata ( target , {
263- name : propertyKey ,
264- description : description ,
265- } ) ;
266214 } else {
267215 createPropertyDescriptionMetadata ( target , description , propertyKey ) ;
268216 }
@@ -271,10 +219,6 @@ function setDescriptionMetadata(description: string, target: any, propertyKey: s
271219 createOrSetObjectTypeMetadata ( target , {
272220 description : description ,
273221 } ) ;
274- } else if ( Reflect . hasMetadata ( GQ_ENUM_METADATA_KEY , target . prototype ) ) {
275- createOrSetEnumTypeMetadata ( target , {
276- description : description ,
277- } ) ;
278222 } else {
279223 createDescriptionMetadata ( target , description ) ;
280224 }
@@ -321,22 +265,6 @@ function setPaginationMetadata(target: any, propertyKey: string, methodDescripto
321265 } ;
322266}
323267
324-
325- export function EnumType ( option ?: DefaultOption ) {
326- return function ( target : any ) {
327- createOrSetEnumTypeMetadata ( target , {
328- name : target . name ,
329- } ) ;
330-
331- if ( option ) {
332- // description
333- if ( option . description ) {
334- setDescriptionMetadata ( option . description , target ) ;
335- }
336- }
337- } as Function ;
338- }
339-
340268export function ObjectType ( option ?: DefaultOption ) {
341269 return function ( target : any ) {
342270 createOrSetObjectTypeMetadata ( target , {
@@ -415,22 +343,6 @@ export function Field(option?: FieldOption) {
415343 } as Function ;
416344}
417345
418- export function Value ( value ?: any , option ?: DefaultOption ) {
419- return function ( target : any , propertyKey : any ) {
420- createOrSetValueTypeMetadata ( target , {
421- name : propertyKey ,
422- value : value ,
423- } ) ;
424-
425- if ( option ) {
426- // description
427- if ( option . description ) {
428- setDescriptionMetadata ( option . description , target , propertyKey ) ;
429- }
430- }
431- } as Function ;
432- }
433-
434346export function NonNull ( ) {
435347 return function ( target : any , propertyKey : any , index ?: number ) {
436348 setNonNullMetadata ( target , propertyKey , index ) ;
0 commit comments