@graphql-tools/apollo-engine-loader 7.2.20 → 7.3.0-alpha-b76ec274.0
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.
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const crossUndiciFetch = require('cross-undici-fetch');
|
|
9
|
-
const syncFetch = _interopDefault(require('sync-fetch'));
|
|
10
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SCHEMA_QUERY = exports.ApolloEngineLoader = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const utils_1 = require("@graphql-tools/utils");
|
|
6
|
+
const cross_undici_fetch_1 = require("cross-undici-fetch");
|
|
7
|
+
const sync_fetch_1 = tslib_1.__importDefault(require("sync-fetch"));
|
|
11
8
|
const DEFAULT_APOLLO_ENDPOINT = 'https://engine-graphql.apollographql.com/api/graphql';
|
|
12
9
|
/**
|
|
13
10
|
* This loader loads a schema from Apollo Engine
|
|
@@ -28,7 +25,7 @@ class ApolloEngineLoader {
|
|
|
28
25
|
...options.headers,
|
|
29
26
|
},
|
|
30
27
|
body: JSON.stringify({
|
|
31
|
-
query: SCHEMA_QUERY,
|
|
28
|
+
query: exports.SCHEMA_QUERY,
|
|
32
29
|
variables: {
|
|
33
30
|
id: options.graph,
|
|
34
31
|
tag: options.variant,
|
|
@@ -48,12 +45,12 @@ class ApolloEngineLoader {
|
|
|
48
45
|
return [];
|
|
49
46
|
}
|
|
50
47
|
const fetchArgs = this.getFetchArgs(options);
|
|
51
|
-
const response = await
|
|
48
|
+
const response = await (0, cross_undici_fetch_1.fetch)(...fetchArgs);
|
|
52
49
|
const { data, errors } = await response.json();
|
|
53
50
|
if (errors) {
|
|
54
|
-
throw new
|
|
51
|
+
throw new utils_1.AggregateError(errors, 'Introspection from Apollo Engine failed; \n ' + errors.map((e) => e.message).join('\n'));
|
|
55
52
|
}
|
|
56
|
-
const source =
|
|
53
|
+
const source = (0, utils_1.parseGraphQLSDL)(pointer, data.service.schema.document, options);
|
|
57
54
|
return [source];
|
|
58
55
|
}
|
|
59
56
|
loadSync(pointer, options) {
|
|
@@ -61,19 +58,20 @@ class ApolloEngineLoader {
|
|
|
61
58
|
return [];
|
|
62
59
|
}
|
|
63
60
|
const fetchArgs = this.getFetchArgs(options);
|
|
64
|
-
const response =
|
|
61
|
+
const response = (0, sync_fetch_1.default)(...fetchArgs);
|
|
65
62
|
const { data, errors } = response.json();
|
|
66
63
|
if (errors) {
|
|
67
|
-
throw new
|
|
64
|
+
throw new utils_1.AggregateError(errors, 'Introspection from Apollo Engine failed; \n ' + errors.map((e) => e.message).join('\n'));
|
|
68
65
|
}
|
|
69
|
-
const source =
|
|
66
|
+
const source = (0, utils_1.parseGraphQLSDL)(pointer, data.service.schema.document, options);
|
|
70
67
|
return [source];
|
|
71
68
|
}
|
|
72
69
|
}
|
|
70
|
+
exports.ApolloEngineLoader = ApolloEngineLoader;
|
|
73
71
|
/**
|
|
74
72
|
* @internal
|
|
75
73
|
*/
|
|
76
|
-
|
|
74
|
+
exports.SCHEMA_QUERY = `
|
|
77
75
|
query GetSchemaByTag($tag: String!, $id: ID!) {
|
|
78
76
|
service(id: $id) {
|
|
79
77
|
... on Service {
|
|
@@ -85,6 +83,3 @@ const SCHEMA_QUERY = /* GraphQL */ `
|
|
|
85
83
|
}
|
|
86
84
|
}
|
|
87
85
|
`;
|
|
88
|
-
|
|
89
|
-
exports.ApolloEngineLoader = ApolloEngineLoader;
|
|
90
|
-
exports.SCHEMA_QUERY = SCHEMA_QUERY;
|
package/cjs/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { parseGraphQLSDL, AggregateError } from '@graphql-tools/utils';
|
|
2
2
|
import { fetch } from 'cross-undici-fetch';
|
|
3
3
|
import syncFetch from 'sync-fetch';
|
|
4
|
-
|
|
5
4
|
const DEFAULT_APOLLO_ENDPOINT = 'https://engine-graphql.apollographql.com/api/graphql';
|
|
6
5
|
/**
|
|
7
6
|
* This loader loads a schema from Apollo Engine
|
|
8
7
|
*/
|
|
9
|
-
class ApolloEngineLoader {
|
|
8
|
+
export class ApolloEngineLoader {
|
|
10
9
|
getFetchArgs(options) {
|
|
11
10
|
return [
|
|
12
11
|
options.engine.endpoint || DEFAULT_APOLLO_ENDPOINT,
|
|
@@ -67,7 +66,7 @@ class ApolloEngineLoader {
|
|
|
67
66
|
/**
|
|
68
67
|
* @internal
|
|
69
68
|
*/
|
|
70
|
-
const SCHEMA_QUERY = /* GraphQL */ `
|
|
69
|
+
export const SCHEMA_QUERY = /* GraphQL */ `
|
|
71
70
|
query GetSchemaByTag($tag: String!, $id: ID!) {
|
|
72
71
|
service(id: $id) {
|
|
73
72
|
... on Service {
|
|
@@ -79,5 +78,3 @@ const SCHEMA_QUERY = /* GraphQL */ `
|
|
|
79
78
|
}
|
|
80
79
|
}
|
|
81
80
|
`;
|
|
82
|
-
|
|
83
|
-
export { ApolloEngineLoader, SCHEMA_QUERY };
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-tools/apollo-engine-loader",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.3.0-alpha-b76ec274.0",
|
|
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/utils": "8.
|
|
10
|
+
"@graphql-tools/utils": "8.8.0-alpha-b76ec274.0",
|
|
11
11
|
"cross-undici-fetch": "^0.4.0",
|
|
12
12
|
"sync-fetch": "0.4.1",
|
|
13
13
|
"tslib": "^2.4.0"
|
|
@@ -19,21 +19,42 @@
|
|
|
19
19
|
},
|
|
20
20
|
"author": "Dotan Simha <dotansimha@gmail.com>",
|
|
21
21
|
"license": "MIT",
|
|
22
|
-
"main": "index.js",
|
|
23
|
-
"module": "index.
|
|
24
|
-
"typings": "index.d.ts",
|
|
22
|
+
"main": "cjs/index.js",
|
|
23
|
+
"module": "esm/index.js",
|
|
24
|
+
"typings": "typings/index.d.ts",
|
|
25
25
|
"typescript": {
|
|
26
|
-
"definition": "index.d.ts"
|
|
26
|
+
"definition": "typings/index.d.ts"
|
|
27
27
|
},
|
|
28
|
+
"type": "module",
|
|
28
29
|
"exports": {
|
|
29
30
|
".": {
|
|
30
|
-
"require":
|
|
31
|
-
|
|
31
|
+
"require": {
|
|
32
|
+
"types": "./typings/index.d.ts",
|
|
33
|
+
"default": "./cjs/index.js"
|
|
34
|
+
},
|
|
35
|
+
"import": {
|
|
36
|
+
"types": "./typings/index.d.ts",
|
|
37
|
+
"default": "./esm/index.js"
|
|
38
|
+
},
|
|
39
|
+
"default": {
|
|
40
|
+
"types": "./typings/index.d.ts",
|
|
41
|
+
"default": "./esm/index.js"
|
|
42
|
+
}
|
|
32
43
|
},
|
|
33
44
|
"./*": {
|
|
34
|
-
"require":
|
|
35
|
-
|
|
45
|
+
"require": {
|
|
46
|
+
"types": "./typings/*.d.ts",
|
|
47
|
+
"default": "./cjs/*.js"
|
|
48
|
+
},
|
|
49
|
+
"import": {
|
|
50
|
+
"types": "./typings/*.d.ts",
|
|
51
|
+
"default": "./esm/*.js"
|
|
52
|
+
},
|
|
53
|
+
"default": {
|
|
54
|
+
"types": "./typings/*.d.ts",
|
|
55
|
+
"default": "./esm/*.js"
|
|
56
|
+
}
|
|
36
57
|
},
|
|
37
58
|
"./package.json": "./package.json"
|
|
38
59
|
}
|
|
39
|
-
}
|
|
60
|
+
}
|
|
File without changes
|