@graphql-hive/apollo 0.43.0-alpha-20251126120827-4cd3f3d3e095fb0017172ecbb78ef323a98e61ad → 0.43.0-alpha-20251126130019-38f4f6902b65b4a4da177b312ae99d968472b594

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 CHANGED
@@ -4,45 +4,60 @@ 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(_a) {
17
- var { pollIntervalInMs } = _a, superGraphFetcherOptions = tslib_1.__rest(_a, ["pollIntervalInMs"]);
18
- pollIntervalInMs = pollIntervalInMs !== null && pollIntervalInMs !== void 0 ? pollIntervalInMs : 30000;
19
- const fetchSupergraph = (0, core_1.createSupergraphSDLFetcher)(superGraphFetcherOptions);
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
+ const endpoint = args.endpoint.endsWith('/supergraph')
21
+ ? args.endpoint
22
+ : (0, core_1.joinUrl)(args.endpoint, 'supergraph');
23
+ const artifactsFetcher = (0, core_1.createCDNArtifactFetcher)({
24
+ endpoint,
25
+ accessKey: args.key,
26
+ client: {
27
+ name: (_c = args.name) !== null && _c !== void 0 ? _c : '@graphql-hive/apollo',
28
+ version: (_d = args.version) !== null && _d !== void 0 ? _d : version_js_1.version,
29
+ },
30
+ logger,
31
+ fetch: args.fetchImplementation,
32
+ circuitBreaker: args.circuitBreaker,
33
+ });
20
34
  let timer = null;
21
35
  return {
22
36
  async initialize(hooks) {
23
- const initialResult = await fetchSupergraph();
37
+ const initialResult = await artifactsFetcher.fetch();
24
38
  function poll() {
25
39
  timer = setTimeout(async () => {
26
40
  var _a;
27
41
  try {
28
- const result = await fetchSupergraph();
29
- if (result.supergraphSdl) {
30
- (_a = hooks.update) === null || _a === void 0 ? void 0 : _a.call(hooks, result.supergraphSdl);
42
+ const result = await artifactsFetcher.fetch();
43
+ if (result.contents) {
44
+ (_a = hooks.update) === null || _a === void 0 ? void 0 : _a.call(hooks, result.contents);
31
45
  }
32
46
  }
33
47
  catch (error) {
34
- console.error(`Failed to update supergraph: ${error instanceof Error ? error.message : error}`);
48
+ logger.error({ error }, `Failed to update supergraph.`);
35
49
  }
36
50
  poll();
37
51
  }, pollIntervalInMs);
38
52
  }
39
53
  poll();
40
54
  return {
41
- supergraphSdl: initialResult.supergraphSdl,
55
+ supergraphSdl: initialResult.contents,
42
56
  cleanup: async () => {
43
57
  if (timer) {
44
58
  clearTimeout(timer);
45
59
  }
60
+ artifactsFetcher.dispose();
46
61
  },
47
62
  };
48
63
  },
package/cjs/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = void 0;
4
- exports.version = '0.43.0-alpha-20251126120827-4cd3f3d3e095fb0017172ecbb78ef323a98e61ad';
4
+ exports.version = '0.43.0-alpha-20251126130019-38f4f6902b65b4a4da177b312ae99d968472b594';
package/esm/index.js CHANGED
@@ -1,38 +1,53 @@
1
- import { __rest } from "tslib";
2
1
  import { GraphQLError } from 'graphql';
3
- import { autoDisposeSymbol, createHive as createHiveClient, createSupergraphSDLFetcher, isHiveClient, } from '@graphql-hive/core';
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(_a) {
7
- var { pollIntervalInMs } = _a, superGraphFetcherOptions = __rest(_a, ["pollIntervalInMs"]);
8
- pollIntervalInMs = pollIntervalInMs !== null && pollIntervalInMs !== void 0 ? pollIntervalInMs : 30000;
9
- const fetchSupergraph = createSupergraphSDLFetcher(superGraphFetcherOptions);
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
+ const endpoint = args.endpoint.endsWith('/supergraph')
11
+ ? args.endpoint
12
+ : joinUrl(args.endpoint, 'supergraph');
13
+ const artifactsFetcher = createCDNArtifactFetcher({
14
+ endpoint,
15
+ accessKey: args.key,
16
+ client: {
17
+ name: (_c = args.name) !== null && _c !== void 0 ? _c : '@graphql-hive/apollo',
18
+ version: (_d = args.version) !== null && _d !== void 0 ? _d : version,
19
+ },
20
+ logger,
21
+ fetch: args.fetchImplementation,
22
+ circuitBreaker: args.circuitBreaker,
23
+ });
10
24
  let timer = null;
11
25
  return {
12
26
  async initialize(hooks) {
13
- const initialResult = await fetchSupergraph();
27
+ const initialResult = await artifactsFetcher.fetch();
14
28
  function poll() {
15
29
  timer = setTimeout(async () => {
16
30
  var _a;
17
31
  try {
18
- const result = await fetchSupergraph();
19
- if (result.supergraphSdl) {
20
- (_a = hooks.update) === null || _a === void 0 ? void 0 : _a.call(hooks, result.supergraphSdl);
32
+ const result = await artifactsFetcher.fetch();
33
+ if (result.contents) {
34
+ (_a = hooks.update) === null || _a === void 0 ? void 0 : _a.call(hooks, result.contents);
21
35
  }
22
36
  }
23
37
  catch (error) {
24
- console.error(`Failed to update supergraph: ${error instanceof Error ? error.message : error}`);
38
+ logger.error({ error }, `Failed to update supergraph.`);
25
39
  }
26
40
  poll();
27
41
  }, pollIntervalInMs);
28
42
  }
29
43
  poll();
30
44
  return {
31
- supergraphSdl: initialResult.supergraphSdl,
45
+ supergraphSdl: initialResult.contents,
32
46
  cleanup: async () => {
33
47
  if (timer) {
34
48
  clearTimeout(timer);
35
49
  }
50
+ artifactsFetcher.dispose();
36
51
  },
37
52
  };
38
53
  },
package/esm/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '0.43.0-alpha-20251126120827-4cd3f3d3e095fb0017172ecbb78ef323a98e61ad';
1
+ export const version = '0.43.0-alpha-20251126130019-38f4f6902b65b4a4da177b312ae99d968472b594';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-hive/apollo",
3
- "version": "0.43.0-alpha-20251126120827-4cd3f3d3e095fb0017172ecbb78ef323a98e61ad",
3
+ "version": "0.43.0-alpha-20251126130019-38f4f6902b65b4a4da177b312ae99d968472b594",
4
4
  "description": "GraphQL Hive + Apollo Server",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {
@@ -8,7 +8,7 @@
8
8
  "graphql": "^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"
9
9
  },
10
10
  "dependencies": {
11
- "@graphql-hive/core": "0.16.0-alpha-20251126120827-4cd3f3d3e095fb0017172ecbb78ef323a98e61ad"
11
+ "@graphql-hive/core": "0.16.0-alpha-20251126130019-38f4f6902b65b4a4da177b312ae99d968472b594"
12
12
  },
13
13
  "repository": {
14
14
  "type": "git",
@@ -1,10 +1,43 @@
1
1
  import type { ApolloServerPlugin } from '@apollo/server';
2
- import { HiveClient, HivePluginOptions, SupergraphSDLFetcherOptions } from '@graphql-hive/core';
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
- export declare function createSupergraphManager({ pollIntervalInMs, ...superGraphFetcherOptions }: {
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;
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
- } & SupergraphSDLFetcherOptions): {
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<{
@@ -1,10 +1,43 @@
1
1
  import type { ApolloServerPlugin } from '@apollo/server';
2
- import { HiveClient, HivePluginOptions, SupergraphSDLFetcherOptions } from '@graphql-hive/core';
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
- export declare function createSupergraphManager({ pollIntervalInMs, ...superGraphFetcherOptions }: {
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;
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
- } & SupergraphSDLFetcherOptions): {
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<{
@@ -1,2 +1,2 @@
1
- export declare const version = "0.43.0-alpha-20251126120827-4cd3f3d3e095fb0017172ecbb78ef323a98e61ad";
1
+ export declare const version = "0.43.0-alpha-20251126130019-38f4f6902b65b4a4da177b312ae99d968472b594";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1,2 +1,2 @@
1
- export declare const version = "0.43.0-alpha-20251126120827-4cd3f3d3e095fb0017172ecbb78ef323a98e61ad";
1
+ export declare const version = "0.43.0-alpha-20251126130019-38f4f6902b65b4a4da177b312ae99d968472b594";
2
2
  //# sourceMappingURL=version.d.ts.map