@graphql-tools/utils 8.11.0 → 8.12.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.
package/cjs/heal.js CHANGED
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.healTypes = exports.healSchema = void 0;
4
4
  const graphql_1 = require("graphql");
5
+ const inspect_1 = require("./inspect");
5
6
  // Update any references to named schema types that disagree with the named
6
7
  // types found in schema.getTypeMap().
7
8
  //
@@ -49,8 +50,10 @@ function healTypes(originalTypeMap, directives) {
49
50
  if (actualName.startsWith('__')) {
50
51
  continue;
51
52
  }
52
- if (actualName in actualNamedTypeMap) {
53
- throw new Error(`Duplicate schema type name ${actualName}`);
53
+ if (actualNamedTypeMap[actualName] != null) {
54
+ console.warn(`Duplicate schema type name ${actualName} found; using the last one found in the schema;
55
+ Existing one is ${(0, inspect_1.inspect)(actualNamedTypeMap[actualName].toConfig())}
56
+ The new one is ${namedType.toConfig()}`);
54
57
  }
55
58
  actualNamedTypeMap[actualName] = namedType;
56
59
  // Note: we are deliberately leaving namedType in the schema by its
package/cjs/rewire.js CHANGED
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.rewireTypes = void 0;
4
4
  const graphql_1 = require("graphql");
5
+ const inspect_js_1 = require("./inspect.js");
5
6
  const stub_js_1 = require("./stub.js");
6
7
  function rewireTypes(originalTypeMap, directives) {
7
8
  const referenceTypeMap = Object.create(null);
@@ -19,7 +20,9 @@ function rewireTypes(originalTypeMap, directives) {
19
20
  continue;
20
21
  }
21
22
  if (newTypeMap[newName] != null) {
22
- throw new Error(`Duplicate schema type name ${newName}`);
23
+ console.warn(`Duplicate schema type name ${newName} found; using the last one found in the schema;
24
+ Existing one is ${(0, inspect_js_1.inspect)(newTypeMap[newName].toConfig())}
25
+ The new one is ${namedType.toConfig()}`);
23
26
  }
24
27
  newTypeMap[newName] = namedType;
25
28
  }
package/esm/heal.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { GraphQLList, GraphQLNonNull, isNamedType, isObjectType, isInterfaceType, isUnionType, isInputObjectType, isLeafType, isListType, isNonNullType, } from 'graphql';
2
+ import { inspect } from './inspect';
2
3
  // Update any references to named schema types that disagree with the named
3
4
  // types found in schema.getTypeMap().
4
5
  //
@@ -45,8 +46,10 @@ export function healTypes(originalTypeMap, directives) {
45
46
  if (actualName.startsWith('__')) {
46
47
  continue;
47
48
  }
48
- if (actualName in actualNamedTypeMap) {
49
- throw new Error(`Duplicate schema type name ${actualName}`);
49
+ if (actualNamedTypeMap[actualName] != null) {
50
+ console.warn(`Duplicate schema type name ${actualName} found; using the last one found in the schema;
51
+ Existing one is ${inspect(actualNamedTypeMap[actualName].toConfig())}
52
+ The new one is ${namedType.toConfig()}`);
50
53
  }
51
54
  actualNamedTypeMap[actualName] = namedType;
52
55
  // Note: we are deliberately leaving namedType in the schema by its
package/esm/rewire.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { GraphQLDirective, GraphQLEnumType, GraphQLInputObjectType, GraphQLInterfaceType, GraphQLList, GraphQLObjectType, GraphQLNonNull, GraphQLScalarType, GraphQLUnionType, isInterfaceType, isEnumType, isInputObjectType, isListType, isNamedType, isNonNullType, isObjectType, isScalarType, isUnionType, isSpecifiedScalarType, isSpecifiedDirective, } from 'graphql';
2
+ import { inspect } from './inspect.js';
2
3
  import { getBuiltInForStub, isNamedStub } from './stub.js';
3
4
  export function rewireTypes(originalTypeMap, directives) {
4
5
  const referenceTypeMap = Object.create(null);
@@ -16,7 +17,9 @@ export function rewireTypes(originalTypeMap, directives) {
16
17
  continue;
17
18
  }
18
19
  if (newTypeMap[newName] != null) {
19
- throw new Error(`Duplicate schema type name ${newName}`);
20
+ console.warn(`Duplicate schema type name ${newName} found; using the last one found in the schema;
21
+ Existing one is ${inspect(newTypeMap[newName].toConfig())}
22
+ The new one is ${namedType.toConfig()}`);
20
23
  }
21
24
  newTypeMap[newName] = namedType;
22
25
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-tools/utils",
3
- "version": "8.11.0",
3
+ "version": "8.12.0-alpha-20220909153003-d51cf9f8",
4
4
  "description": "Common package containing utils and types for GraphQL tools",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {