@@ -32,7 +32,7 @@ import {
32
32
isInterfaceType ,
33
33
isUnionType ,
34
34
isInputObjectType ,
35
- isWrappingType ,
35
+ getNamedType ,
36
36
} from './definition' ;
37
37
38
38
/**
@@ -324,39 +324,39 @@ function typeMapReducer(map: TypeMap, type: ?GraphQLType): TypeMap {
324
324
if ( ! type ) {
325
325
return map ;
326
326
}
327
- if ( isWrappingType ( type ) ) {
328
- return typeMapReducer ( map , type . ofType ) ;
329
- }
330
- if ( map [ type . name ] ) {
331
- if ( map [ type . name ] !== type ) {
327
+
328
+ const namedType = getNamedType ( type ) ;
329
+ const seenType = map [ namedType . name ] ;
330
+ if ( seenType ) {
331
+ if ( seenType !== namedType ) {
332
332
throw new Error (
333
- `Schema must contain uniquely named types but contains multiple types named "${ type . name } ".` ,
333
+ `Schema must contain uniquely named types but contains multiple types named "${ namedType . name } ".` ,
334
334
) ;
335
335
}
336
336
return map ;
337
337
}
338
- map [ type . name ] = type ;
338
+ map [ namedType . name ] = namedType ;
339
339
340
340
let reducedMap = map ;
341
341
342
- if ( isUnionType ( type ) ) {
343
- reducedMap = type . getTypes ( ) . reduce ( typeMapReducer , reducedMap ) ;
342
+ if ( isUnionType ( namedType ) ) {
343
+ reducedMap = namedType . getTypes ( ) . reduce ( typeMapReducer , reducedMap ) ;
344
344
}
345
345
346
- if ( isObjectType ( type ) ) {
347
- reducedMap = type . getInterfaces ( ) . reduce ( typeMapReducer , reducedMap ) ;
346
+ if ( isObjectType ( namedType ) ) {
347
+ reducedMap = namedType . getInterfaces ( ) . reduce ( typeMapReducer , reducedMap ) ;
348
348
}
349
349
350
- if ( isObjectType ( type ) || isInterfaceType ( type ) ) {
351
- for ( const field of objectValues ( type . getFields ( ) ) ) {
350
+ if ( isObjectType ( namedType ) || isInterfaceType ( namedType ) ) {
351
+ for ( const field of objectValues ( namedType . getFields ( ) ) ) {
352
352
const fieldArgTypes = field . args . map ( arg => arg . type ) ;
353
353
reducedMap = fieldArgTypes . reduce ( typeMapReducer , reducedMap ) ;
354
354
reducedMap = typeMapReducer ( reducedMap , field . type ) ;
355
355
}
356
356
}
357
357
358
- if ( isInputObjectType ( type ) ) {
359
- for ( const field of objectValues ( type . getFields ( ) ) ) {
358
+ if ( isInputObjectType ( namedType ) ) {
359
+ for ( const field of objectValues ( namedType . getFields ( ) ) ) {
360
360
reducedMap = typeMapReducer ( reducedMap , field . type ) ;
361
361
}
362
362
}
0 commit comments