@graphql-hive/apollo 0.43.0 → 0.44.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.
- package/cjs/index.js +25 -11
- package/cjs/version.js +1 -1
- package/esm/index.js +26 -12
- package/esm/version.js +1 -1
- package/package.json +3 -2
- package/typings/index.d.cts +36 -3
- package/typings/index.d.ts +36 -3
- package/typings/version.d.cts +1 -1
- package/typings/version.d.ts +1 -1
package/cjs/index.js
CHANGED
|
@@ -4,45 +4,59 @@ exports.createSupergraphSDLFetcher = exports.createServicesFetcher = exports.cre
|
|
|
4
4
|
exports.createSupergraphManager = createSupergraphManager;
|
|
5
5
|
exports.createHive = createHive;
|
|
6
6
|
exports.useHive = useHive;
|
|
7
|
-
const tslib_1 = require("tslib");
|
|
8
7
|
const graphql_1 = require("graphql");
|
|
9
8
|
const core_1 = require("@graphql-hive/core");
|
|
9
|
+
const logger_1 = require("@graphql-hive/logger");
|
|
10
10
|
const version_js_1 = require("./version.js");
|
|
11
11
|
var core_2 = require("@graphql-hive/core");
|
|
12
12
|
Object.defineProperty(exports, "atLeastOnceSampler", { enumerable: true, get: function () { return core_2.atLeastOnceSampler; } });
|
|
13
13
|
Object.defineProperty(exports, "createSchemaFetcher", { enumerable: true, get: function () { return core_2.createSchemaFetcher; } });
|
|
14
14
|
Object.defineProperty(exports, "createServicesFetcher", { enumerable: true, get: function () { return core_2.createServicesFetcher; } });
|
|
15
15
|
Object.defineProperty(exports, "createSupergraphSDLFetcher", { enumerable: true, get: function () { return core_2.createSupergraphSDLFetcher; } });
|
|
16
|
-
function createSupergraphManager(
|
|
17
|
-
var
|
|
18
|
-
|
|
19
|
-
const
|
|
16
|
+
function createSupergraphManager(args) {
|
|
17
|
+
var _a, _b, _c, _d;
|
|
18
|
+
const logger = (_a = args.logger) !== null && _a !== void 0 ? _a : new logger_1.Logger({ level: false });
|
|
19
|
+
const pollIntervalInMs = (_b = args.pollIntervalInMs) !== null && _b !== void 0 ? _b : 30000;
|
|
20
|
+
let endpoints = Array.isArray(args.endpoint) ? args.endpoint : [args.endpoint];
|
|
21
|
+
const endpoint = endpoints.map(endpoint => endpoint.endsWith('/supergraph') ? endpoint : (0, core_1.joinUrl)(endpoint, 'supergraph'));
|
|
22
|
+
const artifactsFetcher = (0, core_1.createCDNArtifactFetcher)({
|
|
23
|
+
endpoint: endpoint,
|
|
24
|
+
accessKey: args.key,
|
|
25
|
+
client: {
|
|
26
|
+
name: (_c = args.name) !== null && _c !== void 0 ? _c : '@graphql-hive/apollo',
|
|
27
|
+
version: (_d = args.version) !== null && _d !== void 0 ? _d : version_js_1.version,
|
|
28
|
+
},
|
|
29
|
+
logger,
|
|
30
|
+
fetch: args.fetchImplementation,
|
|
31
|
+
circuitBreaker: args.circuitBreaker,
|
|
32
|
+
});
|
|
20
33
|
let timer = null;
|
|
21
34
|
return {
|
|
22
35
|
async initialize(hooks) {
|
|
23
|
-
const initialResult = await
|
|
36
|
+
const initialResult = await artifactsFetcher.fetch();
|
|
24
37
|
function poll() {
|
|
25
38
|
timer = setTimeout(async () => {
|
|
26
39
|
var _a;
|
|
27
40
|
try {
|
|
28
|
-
const result = await
|
|
29
|
-
if (result.
|
|
30
|
-
(_a = hooks.update) === null || _a === void 0 ? void 0 : _a.call(hooks, result.
|
|
41
|
+
const result = await artifactsFetcher.fetch();
|
|
42
|
+
if (result.contents) {
|
|
43
|
+
(_a = hooks.update) === null || _a === void 0 ? void 0 : _a.call(hooks, result.contents);
|
|
31
44
|
}
|
|
32
45
|
}
|
|
33
46
|
catch (error) {
|
|
34
|
-
|
|
47
|
+
logger.error({ error }, `Failed to update supergraph.`);
|
|
35
48
|
}
|
|
36
49
|
poll();
|
|
37
50
|
}, pollIntervalInMs);
|
|
38
51
|
}
|
|
39
52
|
poll();
|
|
40
53
|
return {
|
|
41
|
-
supergraphSdl: initialResult.
|
|
54
|
+
supergraphSdl: initialResult.contents,
|
|
42
55
|
cleanup: async () => {
|
|
43
56
|
if (timer) {
|
|
44
57
|
clearTimeout(timer);
|
|
45
58
|
}
|
|
59
|
+
artifactsFetcher.dispose();
|
|
46
60
|
},
|
|
47
61
|
};
|
|
48
62
|
},
|
package/cjs/version.js
CHANGED
package/esm/index.js
CHANGED
|
@@ -1,38 +1,52 @@
|
|
|
1
|
-
import { __rest } from "tslib";
|
|
2
1
|
import { GraphQLError } from 'graphql';
|
|
3
|
-
import { autoDisposeSymbol, createHive as createHiveClient,
|
|
2
|
+
import { autoDisposeSymbol, createCDNArtifactFetcher, createHive as createHiveClient, isHiveClient, joinUrl, } from '@graphql-hive/core';
|
|
3
|
+
import { Logger } from '@graphql-hive/logger';
|
|
4
4
|
import { version } from './version.js';
|
|
5
5
|
export { atLeastOnceSampler, createSchemaFetcher, createServicesFetcher, createSupergraphSDLFetcher, } from '@graphql-hive/core';
|
|
6
|
-
export function createSupergraphManager(
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
const
|
|
6
|
+
export function createSupergraphManager(args) {
|
|
7
|
+
var _a, _b, _c, _d;
|
|
8
|
+
const logger = (_a = args.logger) !== null && _a !== void 0 ? _a : new Logger({ level: false });
|
|
9
|
+
const pollIntervalInMs = (_b = args.pollIntervalInMs) !== null && _b !== void 0 ? _b : 30000;
|
|
10
|
+
let endpoints = Array.isArray(args.endpoint) ? args.endpoint : [args.endpoint];
|
|
11
|
+
const endpoint = endpoints.map(endpoint => endpoint.endsWith('/supergraph') ? endpoint : joinUrl(endpoint, 'supergraph'));
|
|
12
|
+
const artifactsFetcher = createCDNArtifactFetcher({
|
|
13
|
+
endpoint: endpoint,
|
|
14
|
+
accessKey: args.key,
|
|
15
|
+
client: {
|
|
16
|
+
name: (_c = args.name) !== null && _c !== void 0 ? _c : '@graphql-hive/apollo',
|
|
17
|
+
version: (_d = args.version) !== null && _d !== void 0 ? _d : version,
|
|
18
|
+
},
|
|
19
|
+
logger,
|
|
20
|
+
fetch: args.fetchImplementation,
|
|
21
|
+
circuitBreaker: args.circuitBreaker,
|
|
22
|
+
});
|
|
10
23
|
let timer = null;
|
|
11
24
|
return {
|
|
12
25
|
async initialize(hooks) {
|
|
13
|
-
const initialResult = await
|
|
26
|
+
const initialResult = await artifactsFetcher.fetch();
|
|
14
27
|
function poll() {
|
|
15
28
|
timer = setTimeout(async () => {
|
|
16
29
|
var _a;
|
|
17
30
|
try {
|
|
18
|
-
const result = await
|
|
19
|
-
if (result.
|
|
20
|
-
(_a = hooks.update) === null || _a === void 0 ? void 0 : _a.call(hooks, result.
|
|
31
|
+
const result = await artifactsFetcher.fetch();
|
|
32
|
+
if (result.contents) {
|
|
33
|
+
(_a = hooks.update) === null || _a === void 0 ? void 0 : _a.call(hooks, result.contents);
|
|
21
34
|
}
|
|
22
35
|
}
|
|
23
36
|
catch (error) {
|
|
24
|
-
|
|
37
|
+
logger.error({ error }, `Failed to update supergraph.`);
|
|
25
38
|
}
|
|
26
39
|
poll();
|
|
27
40
|
}, pollIntervalInMs);
|
|
28
41
|
}
|
|
29
42
|
poll();
|
|
30
43
|
return {
|
|
31
|
-
supergraphSdl: initialResult.
|
|
44
|
+
supergraphSdl: initialResult.contents,
|
|
32
45
|
cleanup: async () => {
|
|
33
46
|
if (timer) {
|
|
34
47
|
clearTimeout(timer);
|
|
35
48
|
}
|
|
49
|
+
artifactsFetcher.dispose();
|
|
36
50
|
},
|
|
37
51
|
};
|
|
38
52
|
},
|
package/esm/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '0.
|
|
1
|
+
export const version = '0.44.0';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-hive/apollo",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.44.0",
|
|
4
4
|
"description": "GraphQL Hive + Apollo Server",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"peerDependencies": {
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
"graphql": "^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@graphql-hive/
|
|
11
|
+
"@graphql-hive/logger": "^1.0.9",
|
|
12
|
+
"@graphql-hive/core": "0.17.0"
|
|
12
13
|
},
|
|
13
14
|
"repository": {
|
|
14
15
|
"type": "git",
|
package/typings/index.d.cts
CHANGED
|
@@ -1,10 +1,43 @@
|
|
|
1
1
|
import type { ApolloServerPlugin } from '@apollo/server';
|
|
2
|
-
import { HiveClient, HivePluginOptions,
|
|
2
|
+
import { HiveClient, HivePluginOptions, type CircuitBreakerConfiguration } from '@graphql-hive/core';
|
|
3
|
+
import { Logger } from '@graphql-hive/logger';
|
|
3
4
|
export { atLeastOnceSampler, createSchemaFetcher, createServicesFetcher, createSupergraphSDLFetcher, } from '@graphql-hive/core';
|
|
5
|
+
/** @deprecated Use {CreateSupergraphManagerArgs} instead */
|
|
4
6
|
export type { SupergraphSDLFetcherOptions } from '@graphql-hive/core';
|
|
5
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Configuration for {createSupergraphManager}.
|
|
9
|
+
*/
|
|
10
|
+
export type CreateSupergraphManagerArgs = {
|
|
11
|
+
/**
|
|
12
|
+
* The artifact endpoint to poll.
|
|
13
|
+
* E.g. `https://cdn.graphql-hive.com/<uuid>/supergraph`
|
|
14
|
+
*/
|
|
15
|
+
endpoint: string | [string, string];
|
|
16
|
+
/**
|
|
17
|
+
* The CDN access key for fetching artifact.
|
|
18
|
+
*/
|
|
19
|
+
key: string;
|
|
20
|
+
logger?: Logger;
|
|
21
|
+
/**
|
|
22
|
+
* The supergraph poll interval in milliseconds
|
|
23
|
+
* Default: 30_000
|
|
24
|
+
*/
|
|
6
25
|
pollIntervalInMs?: number;
|
|
7
|
-
|
|
26
|
+
/** Circuit breaker configuration override. */
|
|
27
|
+
circuitBreaker?: CircuitBreakerConfiguration;
|
|
28
|
+
fetchImplementation?: typeof fetch;
|
|
29
|
+
/**
|
|
30
|
+
* Client name override
|
|
31
|
+
* Default: `@graphql-hive/apollo`
|
|
32
|
+
*/
|
|
33
|
+
name?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Client version override
|
|
36
|
+
* Default: currents package version
|
|
37
|
+
*/
|
|
38
|
+
version?: string;
|
|
39
|
+
};
|
|
40
|
+
export declare function createSupergraphManager(args: CreateSupergraphManagerArgs): {
|
|
8
41
|
initialize(hooks: {
|
|
9
42
|
update(supergraphSdl: string): void;
|
|
10
43
|
}): Promise<{
|
package/typings/index.d.ts
CHANGED
|
@@ -1,10 +1,43 @@
|
|
|
1
1
|
import type { ApolloServerPlugin } from '@apollo/server';
|
|
2
|
-
import { HiveClient, HivePluginOptions,
|
|
2
|
+
import { HiveClient, HivePluginOptions, type CircuitBreakerConfiguration } from '@graphql-hive/core';
|
|
3
|
+
import { Logger } from '@graphql-hive/logger';
|
|
3
4
|
export { atLeastOnceSampler, createSchemaFetcher, createServicesFetcher, createSupergraphSDLFetcher, } from '@graphql-hive/core';
|
|
5
|
+
/** @deprecated Use {CreateSupergraphManagerArgs} instead */
|
|
4
6
|
export type { SupergraphSDLFetcherOptions } from '@graphql-hive/core';
|
|
5
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Configuration for {createSupergraphManager}.
|
|
9
|
+
*/
|
|
10
|
+
export type CreateSupergraphManagerArgs = {
|
|
11
|
+
/**
|
|
12
|
+
* The artifact endpoint to poll.
|
|
13
|
+
* E.g. `https://cdn.graphql-hive.com/<uuid>/supergraph`
|
|
14
|
+
*/
|
|
15
|
+
endpoint: string | [string, string];
|
|
16
|
+
/**
|
|
17
|
+
* The CDN access key for fetching artifact.
|
|
18
|
+
*/
|
|
19
|
+
key: string;
|
|
20
|
+
logger?: Logger;
|
|
21
|
+
/**
|
|
22
|
+
* The supergraph poll interval in milliseconds
|
|
23
|
+
* Default: 30_000
|
|
24
|
+
*/
|
|
6
25
|
pollIntervalInMs?: number;
|
|
7
|
-
|
|
26
|
+
/** Circuit breaker configuration override. */
|
|
27
|
+
circuitBreaker?: CircuitBreakerConfiguration;
|
|
28
|
+
fetchImplementation?: typeof fetch;
|
|
29
|
+
/**
|
|
30
|
+
* Client name override
|
|
31
|
+
* Default: `@graphql-hive/apollo`
|
|
32
|
+
*/
|
|
33
|
+
name?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Client version override
|
|
36
|
+
* Default: currents package version
|
|
37
|
+
*/
|
|
38
|
+
version?: string;
|
|
39
|
+
};
|
|
40
|
+
export declare function createSupergraphManager(args: CreateSupergraphManagerArgs): {
|
|
8
41
|
initialize(hooks: {
|
|
9
42
|
update(supergraphSdl: string): void;
|
|
10
43
|
}): Promise<{
|
package/typings/version.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "0.
|
|
1
|
+
export declare const version = "0.44.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/typings/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "0.
|
|
1
|
+
export declare const version = "0.44.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|