@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 +10 -1
- package/esm/introspect.js +11 -2
- package/package.json +1 -1
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
|
-
|
|
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
|
-
|
|
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);
|