@graphql-tools/wrap 9.1.0 → 9.2.0-alpha-20220909153003-d51cf9f8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -12,6 +12,7 @@ class RenameTypes {
|
|
|
12
12
|
this.renameScalars = renameScalars;
|
|
13
13
|
}
|
|
14
14
|
transformSchema(originalWrappingSchema, _subschemaConfig) {
|
|
15
|
+
const typeNames = new Set(Object.keys(originalWrappingSchema.getTypeMap()));
|
|
15
16
|
return (0, utils_1.mapSchema)(originalWrappingSchema, {
|
|
16
17
|
[utils_1.MapperKind.TYPE]: (type) => {
|
|
17
18
|
if ((0, graphql_1.isSpecifiedScalarType)(type) && !this.renameBuiltins) {
|
|
@@ -22,9 +23,15 @@ class RenameTypes {
|
|
|
22
23
|
}
|
|
23
24
|
const oldName = type.name;
|
|
24
25
|
const newName = this.renamer(oldName);
|
|
26
|
+
if (newName != null && typeNames.has(newName)) {
|
|
27
|
+
console.warn(`New type name ${newName} for ${oldName} already exists in the schema. Skip renaming.`);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
25
30
|
if (newName !== undefined && newName !== oldName) {
|
|
26
31
|
this.map[oldName] = newName;
|
|
27
32
|
this.reverseMap[newName] = oldName;
|
|
33
|
+
typeNames.delete(oldName);
|
|
34
|
+
typeNames.add(newName);
|
|
28
35
|
return (0, utils_1.renameType)(type, newName);
|
|
29
36
|
}
|
|
30
37
|
},
|
|
@@ -10,6 +10,7 @@ export default class RenameTypes {
|
|
|
10
10
|
this.renameScalars = renameScalars;
|
|
11
11
|
}
|
|
12
12
|
transformSchema(originalWrappingSchema, _subschemaConfig) {
|
|
13
|
+
const typeNames = new Set(Object.keys(originalWrappingSchema.getTypeMap()));
|
|
13
14
|
return mapSchema(originalWrappingSchema, {
|
|
14
15
|
[MapperKind.TYPE]: (type) => {
|
|
15
16
|
if (isSpecifiedScalarType(type) && !this.renameBuiltins) {
|
|
@@ -20,9 +21,15 @@ export default class RenameTypes {
|
|
|
20
21
|
}
|
|
21
22
|
const oldName = type.name;
|
|
22
23
|
const newName = this.renamer(oldName);
|
|
24
|
+
if (newName != null && typeNames.has(newName)) {
|
|
25
|
+
console.warn(`New type name ${newName} for ${oldName} already exists in the schema. Skip renaming.`);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
23
28
|
if (newName !== undefined && newName !== oldName) {
|
|
24
29
|
this.map[oldName] = newName;
|
|
25
30
|
this.reverseMap[newName] = oldName;
|
|
31
|
+
typeNames.delete(oldName);
|
|
32
|
+
typeNames.add(newName);
|
|
26
33
|
return renameType(type, newName);
|
|
27
34
|
}
|
|
28
35
|
},
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-tools/wrap",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.2.0-alpha-20220909153003-d51cf9f8",
|
|
4
4
|
"description": "A set of utils for faster development of GraphQL tools",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"peerDependencies": {
|
|
7
7
|
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@graphql-tools/delegate": "9.0.
|
|
11
|
-
"@graphql-tools/schema": "9.0.
|
|
12
|
-
"@graphql-tools/utils": "8.
|
|
10
|
+
"@graphql-tools/delegate": "9.0.6-alpha-20220909153003-d51cf9f8",
|
|
11
|
+
"@graphql-tools/schema": "9.0.4-alpha-20220909153003-d51cf9f8",
|
|
12
|
+
"@graphql-tools/utils": "8.12.0-alpha-20220909153003-d51cf9f8",
|
|
13
13
|
"tslib": "^2.4.0",
|
|
14
14
|
"value-or-promise": "1.0.11"
|
|
15
15
|
},
|