@graphql-mesh/compose-cli 1.3.13 → 1.3.14
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/loadGraphQLHTTPSubgraph.js +24 -21
- package/esm/loadGraphQLHTTPSubgraph.js +25 -22
- package/package.json +6 -5
|
@@ -38,6 +38,7 @@ const graphql_1 = require("graphql");
|
|
|
38
38
|
const string_interpolation_1 = require("@graphql-mesh/string-interpolation");
|
|
39
39
|
const utils_1 = require("@graphql-mesh/utils");
|
|
40
40
|
const utils_2 = require("@graphql-tools/utils");
|
|
41
|
+
const promise_helpers_1 = require("@whatwg-node/promise-helpers");
|
|
41
42
|
function fixExtends(node) {
|
|
42
43
|
return (0, graphql_1.visit)(node, {
|
|
43
44
|
[graphql_1.Kind.OBJECT_TYPE_EXTENSION](node) {
|
|
@@ -162,28 +163,30 @@ function loadGraphQLHTTPSubgraph(subgraphName, { endpoint, method, useGETForQuer
|
|
|
162
163
|
}, schema);
|
|
163
164
|
}
|
|
164
165
|
if (interpolatedSource) {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
166
|
+
schema$ = (0, promise_helpers_1.handleMaybePromise)(() => {
|
|
167
|
+
let source$;
|
|
168
|
+
if ((0, utils_1.isUrl)(interpolatedSource)) {
|
|
169
|
+
source$ = (0, promise_helpers_1.handleMaybePromise)(() => ctx.fetch(interpolatedSource, {
|
|
170
|
+
headers: schemaHeaders,
|
|
171
|
+
}), res => res.text());
|
|
172
|
+
}
|
|
173
|
+
else if ((0, utils_2.isValidPath)(interpolatedSource)) {
|
|
174
|
+
source$ = (0, utils_1.readFile)(interpolatedSource, {
|
|
175
|
+
allowUnknownExtensions: true,
|
|
176
|
+
cwd: ctx.cwd,
|
|
177
|
+
fetch: ctx.fetch,
|
|
178
|
+
importFn: (p) => Promise.resolve(`${p}`).then(s => __importStar(require(s))),
|
|
179
|
+
logger: ctx.logger,
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
return source$;
|
|
183
|
+
}, sdl => (0, graphql_1.buildASTSchema)(fixExtends((0, graphql_1.parse)(sdl, { noLocation: true })), {
|
|
181
184
|
assumeValidSDL: true,
|
|
182
185
|
assumeValid: true,
|
|
183
186
|
}));
|
|
184
187
|
}
|
|
185
188
|
else {
|
|
186
|
-
const fetchAsRegular = () => (0,
|
|
189
|
+
const fetchAsRegular = () => (0, promise_helpers_1.handleMaybePromise)(() => ctx.fetch(interpolatedEndpoint, {
|
|
187
190
|
method: method || (useGETForQueries ? 'GET' : 'POST'),
|
|
188
191
|
headers: {
|
|
189
192
|
'Content-Type': 'application/json',
|
|
@@ -194,7 +197,7 @@ function loadGraphQLHTTPSubgraph(subgraphName, { endpoint, method, useGETForQuer
|
|
|
194
197
|
}),
|
|
195
198
|
}), res => {
|
|
196
199
|
assertResponseOk(res);
|
|
197
|
-
return (0,
|
|
200
|
+
return (0, promise_helpers_1.handleMaybePromise)(() => res.json(), (result) => {
|
|
198
201
|
if (result.errors) {
|
|
199
202
|
throw new AggregateError(result.errors.map(err => (0, utils_2.createGraphQLError)(err.message, err)), 'Introspection Query Failed');
|
|
200
203
|
}
|
|
@@ -215,7 +218,7 @@ function loadGraphQLHTTPSubgraph(subgraphName, { endpoint, method, useGETForQuer
|
|
|
215
218
|
return schema;
|
|
216
219
|
});
|
|
217
220
|
});
|
|
218
|
-
const fetchAsFederation = () => (0,
|
|
221
|
+
const fetchAsFederation = () => (0, promise_helpers_1.handleMaybePromise)(() => ctx.fetch(interpolatedEndpoint, {
|
|
219
222
|
method: method || (useGETForQueries ? 'GET' : 'POST'),
|
|
220
223
|
headers: {
|
|
221
224
|
'Content-Type': 'application/json',
|
|
@@ -226,7 +229,7 @@ function loadGraphQLHTTPSubgraph(subgraphName, { endpoint, method, useGETForQuer
|
|
|
226
229
|
}),
|
|
227
230
|
}), res => {
|
|
228
231
|
assertResponseOk(res);
|
|
229
|
-
return (0,
|
|
232
|
+
return (0, promise_helpers_1.handleMaybePromise)(() => res.json(), (result) => {
|
|
230
233
|
if (result.errors) {
|
|
231
234
|
throw new AggregateError(result.errors.map(err => (0, utils_2.createGraphQLError)(err.message, err)), 'Introspection Query Failed');
|
|
232
235
|
}
|
|
@@ -242,7 +245,7 @@ function loadGraphQLHTTPSubgraph(subgraphName, { endpoint, method, useGETForQuer
|
|
|
242
245
|
});
|
|
243
246
|
schema$ = federation ? fetchAsFederation() : fetchAsRegular();
|
|
244
247
|
}
|
|
245
|
-
schema$ = (0,
|
|
248
|
+
schema$ = (0, promise_helpers_1.handleMaybePromise)(() => schema$, handleFetchedSchema);
|
|
246
249
|
return {
|
|
247
250
|
name: subgraphName,
|
|
248
251
|
schema$,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { buildASTSchema, buildClientSchema, DirectiveLocation, getIntrospectionQuery, getNamedType, GraphQLDirective, GraphQLList, GraphQLNonNull, GraphQLScalarType, GraphQLSchema, GraphQLString, isObjectType, Kind, parse, visit, } from 'graphql';
|
|
2
2
|
import { stringInterpolator } from '@graphql-mesh/string-interpolation';
|
|
3
3
|
import { isUrl, readFile } from '@graphql-mesh/utils';
|
|
4
|
-
import { createGraphQLError, isValidPath,
|
|
4
|
+
import { createGraphQLError, isValidPath, } from '@graphql-tools/utils';
|
|
5
|
+
import { handleMaybePromise } from '@whatwg-node/promise-helpers';
|
|
5
6
|
function fixExtends(node) {
|
|
6
7
|
return visit(node, {
|
|
7
8
|
[Kind.OBJECT_TYPE_EXTENSION](node) {
|
|
@@ -126,28 +127,30 @@ export function loadGraphQLHTTPSubgraph(subgraphName, { endpoint, method, useGET
|
|
|
126
127
|
}, schema);
|
|
127
128
|
}
|
|
128
129
|
if (interpolatedSource) {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
130
|
+
schema$ = handleMaybePromise(() => {
|
|
131
|
+
let source$;
|
|
132
|
+
if (isUrl(interpolatedSource)) {
|
|
133
|
+
source$ = handleMaybePromise(() => ctx.fetch(interpolatedSource, {
|
|
134
|
+
headers: schemaHeaders,
|
|
135
|
+
}), res => res.text());
|
|
136
|
+
}
|
|
137
|
+
else if (isValidPath(interpolatedSource)) {
|
|
138
|
+
source$ = readFile(interpolatedSource, {
|
|
139
|
+
allowUnknownExtensions: true,
|
|
140
|
+
cwd: ctx.cwd,
|
|
141
|
+
fetch: ctx.fetch,
|
|
142
|
+
importFn: (p) => import(p),
|
|
143
|
+
logger: ctx.logger,
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
return source$;
|
|
147
|
+
}, sdl => buildASTSchema(fixExtends(parse(sdl, { noLocation: true })), {
|
|
145
148
|
assumeValidSDL: true,
|
|
146
149
|
assumeValid: true,
|
|
147
150
|
}));
|
|
148
151
|
}
|
|
149
152
|
else {
|
|
150
|
-
const fetchAsRegular = () =>
|
|
153
|
+
const fetchAsRegular = () => handleMaybePromise(() => ctx.fetch(interpolatedEndpoint, {
|
|
151
154
|
method: method || (useGETForQueries ? 'GET' : 'POST'),
|
|
152
155
|
headers: {
|
|
153
156
|
'Content-Type': 'application/json',
|
|
@@ -158,7 +161,7 @@ export function loadGraphQLHTTPSubgraph(subgraphName, { endpoint, method, useGET
|
|
|
158
161
|
}),
|
|
159
162
|
}), res => {
|
|
160
163
|
assertResponseOk(res);
|
|
161
|
-
return
|
|
164
|
+
return handleMaybePromise(() => res.json(), (result) => {
|
|
162
165
|
if (result.errors) {
|
|
163
166
|
throw new AggregateError(result.errors.map(err => createGraphQLError(err.message, err)), 'Introspection Query Failed');
|
|
164
167
|
}
|
|
@@ -179,7 +182,7 @@ export function loadGraphQLHTTPSubgraph(subgraphName, { endpoint, method, useGET
|
|
|
179
182
|
return schema;
|
|
180
183
|
});
|
|
181
184
|
});
|
|
182
|
-
const fetchAsFederation = () =>
|
|
185
|
+
const fetchAsFederation = () => handleMaybePromise(() => ctx.fetch(interpolatedEndpoint, {
|
|
183
186
|
method: method || (useGETForQueries ? 'GET' : 'POST'),
|
|
184
187
|
headers: {
|
|
185
188
|
'Content-Type': 'application/json',
|
|
@@ -190,7 +193,7 @@ export function loadGraphQLHTTPSubgraph(subgraphName, { endpoint, method, useGET
|
|
|
190
193
|
}),
|
|
191
194
|
}), res => {
|
|
192
195
|
assertResponseOk(res);
|
|
193
|
-
return
|
|
196
|
+
return handleMaybePromise(() => res.json(), (result) => {
|
|
194
197
|
if (result.errors) {
|
|
195
198
|
throw new AggregateError(result.errors.map(err => createGraphQLError(err.message, err)), 'Introspection Query Failed');
|
|
196
199
|
}
|
|
@@ -206,7 +209,7 @@ export function loadGraphQLHTTPSubgraph(subgraphName, { endpoint, method, useGET
|
|
|
206
209
|
});
|
|
207
210
|
schema$ = federation ? fetchAsFederation() : fetchAsRegular();
|
|
208
211
|
}
|
|
209
|
-
schema$ =
|
|
212
|
+
schema$ = handleMaybePromise(() => schema$, handleFetchedSchema);
|
|
210
213
|
return {
|
|
211
214
|
name: subgraphName,
|
|
212
215
|
schema$,
|
package/package.json
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-mesh/compose-cli",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.14",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"graphql": "*"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@commander-js/extra-typings": "^13.0.0",
|
|
10
|
-
"@graphql-mesh/fusion-composition": "^0.7.
|
|
11
|
-
"@graphql-mesh/include": "^0.2.
|
|
10
|
+
"@graphql-mesh/fusion-composition": "^0.7.26",
|
|
11
|
+
"@graphql-mesh/include": "^0.2.19",
|
|
12
12
|
"@graphql-mesh/string-interpolation": "^0.5.8",
|
|
13
|
-
"@graphql-mesh/types": "^0.103.
|
|
14
|
-
"@graphql-mesh/utils": "^0.103.
|
|
13
|
+
"@graphql-mesh/types": "^0.103.20",
|
|
14
|
+
"@graphql-mesh/utils": "^0.103.20",
|
|
15
15
|
"@graphql-tools/code-file-loader": "^8.1.7",
|
|
16
16
|
"@graphql-tools/graphql-file-loader": "^8.0.5",
|
|
17
17
|
"@graphql-tools/load": "^8.0.1",
|
|
18
18
|
"@graphql-tools/schema": "^10.0.5",
|
|
19
19
|
"@graphql-tools/utils": "^10.8.0",
|
|
20
20
|
"@whatwg-node/fetch": "^0.10.4",
|
|
21
|
+
"@whatwg-node/promise-helpers": "^1.0.0",
|
|
21
22
|
"commander": "^13.0.0",
|
|
22
23
|
"dotenv": "^16.3.1"
|
|
23
24
|
},
|