@graphql-hive/apollo 0.46.0-rc-20260105123311-fb154a9fd8e97b2f31324676e815d3a1371fd4fa → 0.46.0-rc-20260107092124-82044efa0393d71d2eda1eedcc7c16e72e9334b5
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 +59 -6
- package/cjs/version.js +1 -1
- package/esm/index.js +59 -6
- package/esm/version.js +1 -1
- package/package.json +2 -2
- package/typings/index.d.cts +2 -2
- package/typings/index.d.ts +2 -2
- package/typings/version.d.cts +1 -1
- package/typings/version.d.ts +1 -1
package/cjs/index.js
CHANGED
|
@@ -70,12 +70,63 @@ function addRequestWithHeaders(context, http) {
|
|
|
70
70
|
}
|
|
71
71
|
return context;
|
|
72
72
|
}
|
|
73
|
-
function
|
|
74
|
-
|
|
73
|
+
function getLoggerFromContext(ctx) {
|
|
74
|
+
if (ctx === null || ctx === void 0 ? void 0 : ctx.logger) {
|
|
75
|
+
return new logger_1.Logger({
|
|
76
|
+
level: 'debug',
|
|
77
|
+
writers: [
|
|
78
|
+
{
|
|
79
|
+
write(level, attrs, msg) {
|
|
80
|
+
const payload = attrs ? Object.assign({ msg }, attrs) : msg;
|
|
81
|
+
switch (level) {
|
|
82
|
+
case 'trace':
|
|
83
|
+
case 'debug':
|
|
84
|
+
ctx.logger.debug(payload);
|
|
85
|
+
break;
|
|
86
|
+
case 'info':
|
|
87
|
+
ctx.logger.info(payload);
|
|
88
|
+
break;
|
|
89
|
+
case 'warn':
|
|
90
|
+
ctx.logger.warn(payload);
|
|
91
|
+
break;
|
|
92
|
+
case 'error':
|
|
93
|
+
ctx.logger.error(payload);
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
function getPersistedDocumentsCacheFromContext(ctx) {
|
|
104
|
+
if (ctx === null || ctx === void 0 ? void 0 : ctx.cache) {
|
|
105
|
+
return {
|
|
106
|
+
async get(key) {
|
|
107
|
+
const value = await ctx.cache.get(key);
|
|
108
|
+
return value != null ? value : null;
|
|
109
|
+
},
|
|
110
|
+
set(key, value, options) {
|
|
111
|
+
return ctx.cache.set(key, value, options);
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
return undefined;
|
|
116
|
+
}
|
|
117
|
+
function createHive(clientOrOptions, ctx) {
|
|
118
|
+
var _a;
|
|
119
|
+
const persistedDocumentsCache = getPersistedDocumentsCacheFromContext(ctx);
|
|
120
|
+
// Only use context logger if user didn't provide their own
|
|
121
|
+
const contextLogger = !clientOrOptions.logger && !((_a = clientOrOptions.agent) === null || _a === void 0 ? void 0 : _a.logger)
|
|
122
|
+
? getLoggerFromContext(ctx)
|
|
123
|
+
: undefined;
|
|
124
|
+
return (0, core_1.createHive)(Object.assign(Object.assign({ logger: contextLogger }, clientOrOptions), { agent: Object.assign({ name: 'hive-client-apollo', version: version_js_1.version }, clientOrOptions.agent), experimental__persistedDocuments: clientOrOptions.experimental__persistedDocuments
|
|
125
|
+
? Object.assign(Object.assign({}, clientOrOptions.experimental__persistedDocuments), { layer2Cache: persistedDocumentsCache || clientOrOptions.experimental__persistedDocuments.layer2Cache
|
|
126
|
+
? Object.assign({ cache: persistedDocumentsCache }, (clientOrOptions.experimental__persistedDocuments.layer2Cache || {})) : undefined }) : undefined }));
|
|
75
127
|
}
|
|
76
128
|
function useHive(clientOrOptions) {
|
|
77
|
-
|
|
78
|
-
void hive.info();
|
|
129
|
+
let hive;
|
|
79
130
|
return {
|
|
80
131
|
requestDidStart(context) {
|
|
81
132
|
var _a;
|
|
@@ -283,13 +334,15 @@ function useHive(clientOrOptions) {
|
|
|
283
334
|
})();
|
|
284
335
|
},
|
|
285
336
|
serverWillStart(ctx) {
|
|
337
|
+
hive = (0, core_1.isHiveClient)(clientOrOptions) ? clientOrOptions : createHive(clientOrOptions, ctx);
|
|
338
|
+
void hive.info();
|
|
286
339
|
// `engine` does not exist in v3
|
|
287
340
|
const isLegacyV0 = 'engine' in ctx;
|
|
288
341
|
hive.reportSchema({ schema: ctx.schema });
|
|
289
342
|
if (isLegacyV0) {
|
|
290
343
|
return {
|
|
291
344
|
async serverWillStop() {
|
|
292
|
-
if (hive[core_1.autoDisposeSymbol]) {
|
|
345
|
+
if (hive === null || hive === void 0 ? void 0 : hive[core_1.autoDisposeSymbol]) {
|
|
293
346
|
await hive.dispose();
|
|
294
347
|
}
|
|
295
348
|
},
|
|
@@ -298,7 +351,7 @@ function useHive(clientOrOptions) {
|
|
|
298
351
|
// Works on v3 and v4
|
|
299
352
|
return Promise.resolve({
|
|
300
353
|
async serverWillStop() {
|
|
301
|
-
if (hive[core_1.autoDisposeSymbol]) {
|
|
354
|
+
if (hive === null || hive === void 0 ? void 0 : hive[core_1.autoDisposeSymbol]) {
|
|
302
355
|
await hive.dispose();
|
|
303
356
|
}
|
|
304
357
|
},
|
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.46.0-rc-
|
|
4
|
+
exports.version = '0.46.0-rc-20260107092124-82044efa0393d71d2eda1eedcc7c16e72e9334b5';
|
package/esm/index.js
CHANGED
|
@@ -60,12 +60,63 @@ function addRequestWithHeaders(context, http) {
|
|
|
60
60
|
}
|
|
61
61
|
return context;
|
|
62
62
|
}
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
function getLoggerFromContext(ctx) {
|
|
64
|
+
if (ctx === null || ctx === void 0 ? void 0 : ctx.logger) {
|
|
65
|
+
return new Logger({
|
|
66
|
+
level: 'debug',
|
|
67
|
+
writers: [
|
|
68
|
+
{
|
|
69
|
+
write(level, attrs, msg) {
|
|
70
|
+
const payload = attrs ? Object.assign({ msg }, attrs) : msg;
|
|
71
|
+
switch (level) {
|
|
72
|
+
case 'trace':
|
|
73
|
+
case 'debug':
|
|
74
|
+
ctx.logger.debug(payload);
|
|
75
|
+
break;
|
|
76
|
+
case 'info':
|
|
77
|
+
ctx.logger.info(payload);
|
|
78
|
+
break;
|
|
79
|
+
case 'warn':
|
|
80
|
+
ctx.logger.warn(payload);
|
|
81
|
+
break;
|
|
82
|
+
case 'error':
|
|
83
|
+
ctx.logger.error(payload);
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
function getPersistedDocumentsCacheFromContext(ctx) {
|
|
94
|
+
if (ctx === null || ctx === void 0 ? void 0 : ctx.cache) {
|
|
95
|
+
return {
|
|
96
|
+
async get(key) {
|
|
97
|
+
const value = await ctx.cache.get(key);
|
|
98
|
+
return value != null ? value : null;
|
|
99
|
+
},
|
|
100
|
+
set(key, value, options) {
|
|
101
|
+
return ctx.cache.set(key, value, options);
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
return undefined;
|
|
106
|
+
}
|
|
107
|
+
export function createHive(clientOrOptions, ctx) {
|
|
108
|
+
var _a;
|
|
109
|
+
const persistedDocumentsCache = getPersistedDocumentsCacheFromContext(ctx);
|
|
110
|
+
// Only use context logger if user didn't provide their own
|
|
111
|
+
const contextLogger = !clientOrOptions.logger && !((_a = clientOrOptions.agent) === null || _a === void 0 ? void 0 : _a.logger)
|
|
112
|
+
? getLoggerFromContext(ctx)
|
|
113
|
+
: undefined;
|
|
114
|
+
return createHiveClient(Object.assign(Object.assign({ logger: contextLogger }, clientOrOptions), { agent: Object.assign({ name: 'hive-client-apollo', version }, clientOrOptions.agent), experimental__persistedDocuments: clientOrOptions.experimental__persistedDocuments
|
|
115
|
+
? Object.assign(Object.assign({}, clientOrOptions.experimental__persistedDocuments), { layer2Cache: persistedDocumentsCache || clientOrOptions.experimental__persistedDocuments.layer2Cache
|
|
116
|
+
? Object.assign({ cache: persistedDocumentsCache }, (clientOrOptions.experimental__persistedDocuments.layer2Cache || {})) : undefined }) : undefined }));
|
|
65
117
|
}
|
|
66
118
|
export function useHive(clientOrOptions) {
|
|
67
|
-
|
|
68
|
-
void hive.info();
|
|
119
|
+
let hive;
|
|
69
120
|
return {
|
|
70
121
|
requestDidStart(context) {
|
|
71
122
|
var _a;
|
|
@@ -273,13 +324,15 @@ export function useHive(clientOrOptions) {
|
|
|
273
324
|
})();
|
|
274
325
|
},
|
|
275
326
|
serverWillStart(ctx) {
|
|
327
|
+
hive = isHiveClient(clientOrOptions) ? clientOrOptions : createHive(clientOrOptions, ctx);
|
|
328
|
+
void hive.info();
|
|
276
329
|
// `engine` does not exist in v3
|
|
277
330
|
const isLegacyV0 = 'engine' in ctx;
|
|
278
331
|
hive.reportSchema({ schema: ctx.schema });
|
|
279
332
|
if (isLegacyV0) {
|
|
280
333
|
return {
|
|
281
334
|
async serverWillStop() {
|
|
282
|
-
if (hive[autoDisposeSymbol]) {
|
|
335
|
+
if (hive === null || hive === void 0 ? void 0 : hive[autoDisposeSymbol]) {
|
|
283
336
|
await hive.dispose();
|
|
284
337
|
}
|
|
285
338
|
},
|
|
@@ -288,7 +341,7 @@ export function useHive(clientOrOptions) {
|
|
|
288
341
|
// Works on v3 and v4
|
|
289
342
|
return Promise.resolve({
|
|
290
343
|
async serverWillStop() {
|
|
291
|
-
if (hive[autoDisposeSymbol]) {
|
|
344
|
+
if (hive === null || hive === void 0 ? void 0 : hive[autoDisposeSymbol]) {
|
|
292
345
|
await hive.dispose();
|
|
293
346
|
}
|
|
294
347
|
},
|
package/esm/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '0.46.0-rc-
|
|
1
|
+
export const version = '0.46.0-rc-20260107092124-82044efa0393d71d2eda1eedcc7c16e72e9334b5';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-hive/apollo",
|
|
3
|
-
"version": "0.46.0-rc-
|
|
3
|
+
"version": "0.46.0-rc-20260107092124-82044efa0393d71d2eda1eedcc7c16e72e9334b5",
|
|
4
4
|
"description": "GraphQL Hive + Apollo Server",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"peerDependencies": {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@graphql-hive/logger": "^1.0.9",
|
|
12
|
-
"@graphql-hive/core": "0.19.0-rc-
|
|
12
|
+
"@graphql-hive/core": "0.19.0-rc-20260107092124-82044efa0393d71d2eda1eedcc7c16e72e9334b5"
|
|
13
13
|
},
|
|
14
14
|
"repository": {
|
|
15
15
|
"type": "git",
|
package/typings/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ApolloServerPlugin } from '@apollo/server';
|
|
1
|
+
import type { ApolloServerPlugin, GraphQLServerContext } from '@apollo/server';
|
|
2
2
|
import { HiveClient, HivePluginOptions, type CircuitBreakerConfiguration } from '@graphql-hive/core';
|
|
3
3
|
import { Logger } from '@graphql-hive/logger';
|
|
4
4
|
export { atLeastOnceSampler, createSchemaFetcher, createServicesFetcher, createSupergraphSDLFetcher, } from '@graphql-hive/core';
|
|
@@ -45,6 +45,6 @@ export declare function createSupergraphManager(args: CreateSupergraphManagerArg
|
|
|
45
45
|
cleanup?: () => Promise<void>;
|
|
46
46
|
}>;
|
|
47
47
|
};
|
|
48
|
-
export declare function createHive(clientOrOptions: HivePluginOptions): HiveClient;
|
|
48
|
+
export declare function createHive(clientOrOptions: HivePluginOptions, ctx?: GraphQLServerContext): HiveClient;
|
|
49
49
|
export declare function useHive(clientOrOptions: HiveClient | HivePluginOptions): ApolloServerPlugin;
|
|
50
50
|
//# sourceMappingURL=index.d.ts.map
|
package/typings/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ApolloServerPlugin } from '@apollo/server';
|
|
1
|
+
import type { ApolloServerPlugin, GraphQLServerContext } from '@apollo/server';
|
|
2
2
|
import { HiveClient, HivePluginOptions, type CircuitBreakerConfiguration } from '@graphql-hive/core';
|
|
3
3
|
import { Logger } from '@graphql-hive/logger';
|
|
4
4
|
export { atLeastOnceSampler, createSchemaFetcher, createServicesFetcher, createSupergraphSDLFetcher, } from '@graphql-hive/core';
|
|
@@ -45,6 +45,6 @@ export declare function createSupergraphManager(args: CreateSupergraphManagerArg
|
|
|
45
45
|
cleanup?: () => Promise<void>;
|
|
46
46
|
}>;
|
|
47
47
|
};
|
|
48
|
-
export declare function createHive(clientOrOptions: HivePluginOptions): HiveClient;
|
|
48
|
+
export declare function createHive(clientOrOptions: HivePluginOptions, ctx?: GraphQLServerContext): HiveClient;
|
|
49
49
|
export declare function useHive(clientOrOptions: HiveClient | HivePluginOptions): ApolloServerPlugin;
|
|
50
50
|
//# sourceMappingURL=index.d.ts.map
|
package/typings/version.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "0.46.0-rc-
|
|
1
|
+
export declare const version = "0.46.0-rc-20260107092124-82044efa0393d71d2eda1eedcc7c16e72e9334b5";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/typings/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "0.46.0-rc-
|
|
1
|
+
export declare const version = "0.46.0-rc-20260107092124-82044efa0393d71d2eda1eedcc7c16e72e9334b5";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|