Skip to content

Commit f010e86

Browse files
committed
Perf improvement for comparing two types
1 parent 6a3eac7 commit f010e86

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/validation/rules/OverlappingFieldsCanBeMerged.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import {
2323
getNamedType,
2424
GraphQLObjectType,
2525
GraphQLInterfaceType,
26+
GraphQLList,
27+
GraphQLNonNull,
2628
} from '../../type/definition';
2729
import type {
2830
GraphQLType,
@@ -253,7 +255,16 @@ function sameValue(value1, value2) {
253255
}
254256

255257
function sameType(type1: GraphQLType, type2: GraphQLType) {
256-
return String(type1) === String(type2);
258+
if (type1 === type2) {
259+
return true;
260+
}
261+
if (type1 instanceof GraphQLList && type2 instanceof GraphQLList) {
262+
return sameType(type1.ofType, type2.ofType);
263+
}
264+
if (type1 instanceof GraphQLNonNull && type2 instanceof GraphQLNonNull) {
265+
return sameType(type1.ofType, type2.ofType);
266+
}
267+
return false;
257268
}
258269

259270

0 commit comments

Comments
 (0)