Skip to content

Commit 3f52824

Browse files
committed
fix(utils/mapSchema): do not map builtin scalars
1 parent 3b99a9b commit 3f52824

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

packages/utils/src/mapSchema.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {
1414
GraphQLNonNull,
1515
GraphQLObjectType,
1616
GraphQLObjectTypeConfig,
17-
GraphQLScalarType,
1817
GraphQLSchema,
1918
GraphQLType,
2019
InputValueDefinitionNode,
@@ -29,7 +28,6 @@ import {
2928
isScalarType,
3029
isUnionType,
3130
Kind,
32-
specifiedScalarTypes,
3331
} from 'graphql';
3432
import { getObjectTypeFromTypeMap } from './getObjectTypeFromTypeMap.js';
3533
import {
@@ -99,6 +97,8 @@ export function mapSchema(schema: GraphQLSchema, schemaMapper: SchemaMapper = {}
9997
});
10098
}
10199

100+
const builtinTypes = ['String', 'ID', 'Int', 'Float', 'Boolean'];
101+
102102
function mapTypes(
103103
originalTypeMap: Record<string, GraphQLNamedType>,
104104
schema: GraphQLSchema,
@@ -108,13 +108,10 @@ function mapTypes(
108108
const newTypeMap = {};
109109

110110
for (const typeName in originalTypeMap) {
111-
if (!typeName.startsWith('__')) {
111+
if (!typeName.startsWith('__') && !builtinTypes.includes(typeName)) {
112112
const originalType = originalTypeMap[typeName];
113113

114-
if (
115-
originalType == null ||
116-
(!testFn(originalType) && !specifiedScalarTypes.includes(originalType as GraphQLScalarType))
117-
) {
114+
if (originalType == null || !testFn(originalType)) {
118115
newTypeMap[typeName] = originalType;
119116
continue;
120117
}

0 commit comments

Comments
 (0)