@graphql-tools/wrap 9.0.6 → 9.1.0-alpha-20220909135557-dc2d610f

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/introspect.js CHANGED
@@ -9,7 +9,16 @@ function getSchemaFromIntrospection(introspectionResult, options) {
9
9
  if ((_a = introspectionResult === null || introspectionResult === void 0 ? void 0 : introspectionResult.data) === null || _a === void 0 ? void 0 : _a.__schema) {
10
10
  return (0, graphql_1.buildClientSchema)(introspectionResult.data, options);
11
11
  }
12
- throw new Error('Could not obtain introspection result, received: ' + JSON.stringify(introspectionResult));
12
+ if (introspectionResult === null || introspectionResult === void 0 ? void 0 : introspectionResult.errors) {
13
+ const graphqlErrors = introspectionResult.errors.map(error => (0, utils_1.createGraphQLError)(error.message, error));
14
+ if (introspectionResult.errors.length === 1) {
15
+ throw graphqlErrors[0];
16
+ }
17
+ else {
18
+ throw new utils_1.AggregateError(graphqlErrors, 'Could not obtain introspection result');
19
+ }
20
+ }
21
+ throw (0, utils_1.createGraphQLError)(`Could not obtain introspection result, received the following as response; \n ${(0, utils_1.inspect)(introspectionResult)}`);
13
22
  }
14
23
  function introspectSchema(executor, context, options) {
15
24
  const parsedIntrospectionQuery = (0, graphql_1.parse)((0, graphql_1.getIntrospectionQuery)(options), options);
package/esm/introspect.js CHANGED
@@ -1,12 +1,21 @@
1
1
  import { getIntrospectionQuery, buildClientSchema, parse, } from 'graphql';
2
2
  import { ValueOrPromise } from 'value-or-promise';
3
- import { isAsyncIterable } from '@graphql-tools/utils';
3
+ import { isAsyncIterable, AggregateError, createGraphQLError, inspect, } from '@graphql-tools/utils';
4
4
  function getSchemaFromIntrospection(introspectionResult, options) {
5
5
  var _a;
6
6
  if ((_a = introspectionResult === null || introspectionResult === void 0 ? void 0 : introspectionResult.data) === null || _a === void 0 ? void 0 : _a.__schema) {
7
7
  return buildClientSchema(introspectionResult.data, options);
8
8
  }
9
- throw new Error('Could not obtain introspection result, received: ' + JSON.stringify(introspectionResult));
9
+ if (introspectionResult === null || introspectionResult === void 0 ? void 0 : introspectionResult.errors) {
10
+ const graphqlErrors = introspectionResult.errors.map(error => createGraphQLError(error.message, error));
11
+ if (introspectionResult.errors.length === 1) {
12
+ throw graphqlErrors[0];
13
+ }
14
+ else {
15
+ throw new AggregateError(graphqlErrors, 'Could not obtain introspection result');
16
+ }
17
+ }
18
+ throw createGraphQLError(`Could not obtain introspection result, received the following as response; \n ${inspect(introspectionResult)}`);
10
19
  }
11
20
  export function introspectSchema(executor, context, options) {
12
21
  const parsedIntrospectionQuery = parse(getIntrospectionQuery(options), options);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-tools/wrap",
3
- "version": "9.0.6",
3
+ "version": "9.1.0-alpha-20220909135557-dc2d610f",
4
4
  "description": "A set of utils for faster development of GraphQL tools",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {