@graphql-hive/plugin-deduplicate-request 1.0.1 → 2.0.0-alpha-a15385b922de3f08a097b3e2539e21e758bd362f
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/CHANGELOG.md +8 -0
- package/dist/index.d.cts +128 -14
- package/dist/index.d.ts +128 -14
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @graphql-hive/plugin-deduplicate-request
|
|
2
2
|
|
|
3
|
+
## 2.0.0-alpha-a15385b922de3f08a097b3e2539e21e758bd362f
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#956](https://github.com/graphql-hive/gateway/pull/956) [`2e5d9e3`](https://github.com/graphql-hive/gateway/commit/2e5d9e3c89569ace0d40e2fabd06c61808fed3b0) Thanks [@EmrysMyrddin](https://github.com/EmrysMyrddin)! - Drop Node 18 support
|
|
8
|
+
|
|
9
|
+
Least supported Node version is now v20.
|
|
10
|
+
|
|
3
11
|
## 1.0.1
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/dist/index.d.cts
CHANGED
|
@@ -1,13 +1,99 @@
|
|
|
1
1
|
import { DisposableSymbols } from '@whatwg-node/disposablestack';
|
|
2
2
|
import { ExecutionRequest, ExecutionResult, Executor, MaybePromise as MaybePromise$1, Maybe } from '@graphql-tools/utils';
|
|
3
3
|
import { GraphQLSchema, OperationTypeNode, GraphQLFieldResolver, GraphQLResolveInfo, GraphQLOutputType, GraphQLError, SelectionSetNode, FragmentDefinitionNode, FieldNode, ExecutionResult as ExecutionResult$1, SelectionNode } from 'graphql';
|
|
4
|
-
import { Logger, MeshFetch, KeyValueCache, OnFetchHook } from '@graphql-mesh/types';
|
|
5
4
|
import DataLoader from 'dataloader';
|
|
6
5
|
import { GraphQLResolveInfo as GraphQLResolveInfo$1, GraphQLOutputType as GraphQLOutputType$1 } from 'graphql/type';
|
|
7
6
|
import { MaybePromise } from '@whatwg-node/promise-helpers';
|
|
8
7
|
import { Plugin, YogaInitialContext, Instrumentation as Instrumentation$2 } from 'graphql-yoga';
|
|
8
|
+
import { MeshFetch, KeyValueCache, MeshFetchRequestInit, Logger as Logger$1 } from '@graphql-mesh/types';
|
|
9
9
|
import { FetchInstrumentation } from '@graphql-mesh/utils';
|
|
10
10
|
|
|
11
|
+
type MaybeLazy<T> = T | (() => T);
|
|
12
|
+
type AttributeValue = any;
|
|
13
|
+
type Attributes = AttributeValue[] | {
|
|
14
|
+
[key: string | number]: AttributeValue;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
interface LogWriter {
|
|
18
|
+
write(level: LogLevel, attrs: Attributes | null | undefined, msg: string | null | undefined): void | Promise<void>;
|
|
19
|
+
flush?(): void | Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error';
|
|
23
|
+
interface LoggerOptions {
|
|
24
|
+
/**
|
|
25
|
+
* The minimum log level to log.
|
|
26
|
+
*
|
|
27
|
+
* Providing `false` will disable all logging.
|
|
28
|
+
*
|
|
29
|
+
* Provided function will always be invoked to get the current log level.
|
|
30
|
+
*
|
|
31
|
+
* @default env.LOG_LEVEL || env.DEBUG ? 'debug' : 'info'
|
|
32
|
+
*/
|
|
33
|
+
level?: MaybeLazy<LogLevel | false>;
|
|
34
|
+
/** A prefix to include in every log's message. */
|
|
35
|
+
prefix?: string;
|
|
36
|
+
/**
|
|
37
|
+
* The attributes to include in all logs. Is mainly used to pass the parent
|
|
38
|
+
* attributes when creating {@link Logger.child child loggers}.
|
|
39
|
+
*/
|
|
40
|
+
attrs?: Attributes;
|
|
41
|
+
/**
|
|
42
|
+
* The log writers to use when writing logs.
|
|
43
|
+
*
|
|
44
|
+
* @default env.LOG_JSON ? [new JSONLogWriter()] : [new ConsoleLogWriter()]
|
|
45
|
+
*/
|
|
46
|
+
writers?: [LogWriter, ...LogWriter[]];
|
|
47
|
+
}
|
|
48
|
+
declare class Logger implements AsyncDisposable {
|
|
49
|
+
#private;
|
|
50
|
+
constructor(opts?: LoggerOptions);
|
|
51
|
+
/** The prefix that's prepended to each log message. */
|
|
52
|
+
get prefix(): string | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* The attributes that are added to each log. If the log itself contains
|
|
55
|
+
* attributes with keys existing in {@link attrs}, the log's attributes will
|
|
56
|
+
* override.
|
|
57
|
+
*/
|
|
58
|
+
get attrs(): Attributes | undefined;
|
|
59
|
+
/** The current {@link LogLevel} of the logger. You can change the level using the {@link setLevel} method. */
|
|
60
|
+
get level(): false | LogLevel;
|
|
61
|
+
/**
|
|
62
|
+
* Sets the new {@link LogLevel} of the logger. All subsequent logs, and {@link child child loggers} whose
|
|
63
|
+
* level did not change, will respect the new level.
|
|
64
|
+
*/
|
|
65
|
+
setLevel(level: MaybeLazy<LogLevel | false>): void;
|
|
66
|
+
write(level: LogLevel, attrs: Attributes | null | undefined, msg: string | null | undefined): void;
|
|
67
|
+
flush(): Promise<void> | undefined;
|
|
68
|
+
[DisposableSymbols.asyncDispose](): Promise<void | undefined>;
|
|
69
|
+
child(prefix: string): Logger;
|
|
70
|
+
child(attrs: Attributes, prefix?: string): Logger;
|
|
71
|
+
log(level: LogLevel): void;
|
|
72
|
+
log(level: LogLevel, attrs: MaybeLazy<Attributes>): void;
|
|
73
|
+
log(level: LogLevel, msg: string, ...interpol: unknown[]): void;
|
|
74
|
+
log(level: LogLevel, attrs: MaybeLazy<Attributes>, msg: string, ...interpol: unknown[]): void;
|
|
75
|
+
trace(): void;
|
|
76
|
+
trace(attrs: MaybeLazy<Attributes>): void;
|
|
77
|
+
trace(msg: string, ...interpol: unknown[]): void;
|
|
78
|
+
trace(attrs: MaybeLazy<Attributes>, msg: string, ...interpol: unknown[]): void;
|
|
79
|
+
debug(): void;
|
|
80
|
+
debug(attrs: MaybeLazy<Attributes>): void;
|
|
81
|
+
debug(msg: string, ...interpol: unknown[]): void;
|
|
82
|
+
debug(attrs: MaybeLazy<Attributes>, msg: string, ...interpol: unknown[]): void;
|
|
83
|
+
info(): void;
|
|
84
|
+
info(attrs: MaybeLazy<Attributes>): void;
|
|
85
|
+
info(msg: string, ...interpol: unknown[]): void;
|
|
86
|
+
info(attrs: MaybeLazy<Attributes>, msg: string, ...interpol: unknown[]): void;
|
|
87
|
+
warn(): void;
|
|
88
|
+
warn(attrs: MaybeLazy<Attributes>): void;
|
|
89
|
+
warn(msg: string, ...interpol: unknown[]): void;
|
|
90
|
+
warn(attrs: MaybeLazy<Attributes>, msg: string, ...interpol: unknown[]): void;
|
|
91
|
+
error(): void;
|
|
92
|
+
error(attrs: MaybeLazy<Attributes>): void;
|
|
93
|
+
error(msg: string, ...interpol: unknown[]): void;
|
|
94
|
+
error(attrs: MaybeLazy<Attributes>, msg: string, ...interpol: unknown[]): void;
|
|
95
|
+
}
|
|
96
|
+
|
|
11
97
|
type TopicDataMap = Record<string, any>;
|
|
12
98
|
interface HivePubSub<Data extends TopicDataMap = TopicDataMap> {
|
|
13
99
|
/** @deprecated Please use {@link subscribedTopics} if implemented instead. This method will be removed in next major release. */
|
|
@@ -128,7 +214,14 @@ type Instrumentation$1 = {
|
|
|
128
214
|
*/
|
|
129
215
|
subgraphExecute?: (payload: {
|
|
130
216
|
executionRequest: ExecutionRequest;
|
|
217
|
+
subgraphName: string;
|
|
131
218
|
}, wrapped: () => MaybePromise<void>) => MaybePromise<void>;
|
|
219
|
+
/**
|
|
220
|
+
* Wrap each supergraph schema loading.
|
|
221
|
+
*
|
|
222
|
+
* Note: this span is only available when an Async compatible context manager is available
|
|
223
|
+
*/
|
|
224
|
+
schema?: (payload: null, wrapped: () => MaybePromise<void>) => MaybePromise<void>;
|
|
132
225
|
};
|
|
133
226
|
|
|
134
227
|
declare module 'graphql' {
|
|
@@ -150,8 +243,7 @@ interface OnSubgraphExecutePayload<TContext> {
|
|
|
150
243
|
setExecutionRequest(executionRequest: ExecutionRequest): void;
|
|
151
244
|
executor: Executor;
|
|
152
245
|
setExecutor(executor: Executor): void;
|
|
153
|
-
|
|
154
|
-
logger?: Logger;
|
|
246
|
+
log: Logger;
|
|
155
247
|
}
|
|
156
248
|
interface OnSubgraphExecuteDonePayload {
|
|
157
249
|
result: AsyncIterable<ExecutionResult$1> | ExecutionResult$1;
|
|
@@ -178,8 +270,7 @@ interface OnDelegationPlanHookPayload<TContext> {
|
|
|
178
270
|
fragments: Record<string, FragmentDefinitionNode>;
|
|
179
271
|
fieldNodes: SelectionNode[];
|
|
180
272
|
context: TContext;
|
|
181
|
-
|
|
182
|
-
logger?: Logger;
|
|
273
|
+
log: Logger;
|
|
183
274
|
info?: GraphQLResolveInfo$1;
|
|
184
275
|
delegationPlanBuilder: DelegationPlanBuilder;
|
|
185
276
|
setDelegationPlanBuilder(delegationPlanBuilder: DelegationPlanBuilder): void;
|
|
@@ -202,8 +293,7 @@ interface OnDelegationStageExecutePayload<TContext> {
|
|
|
202
293
|
resolver: MergedTypeResolver<TContext>;
|
|
203
294
|
setResolver: (resolver: MergedTypeResolver<TContext>) => void;
|
|
204
295
|
typeName: string;
|
|
205
|
-
|
|
206
|
-
logger?: Logger;
|
|
296
|
+
log: Logger;
|
|
207
297
|
}
|
|
208
298
|
type OnDelegationStageExecuteDoneHook = (payload: OnDelegationStageExecuteDonePayload) => void;
|
|
209
299
|
interface OnDelegationStageExecuteDonePayload {
|
|
@@ -217,9 +307,9 @@ interface GatewayConfigContext {
|
|
|
217
307
|
*/
|
|
218
308
|
fetch: MeshFetch;
|
|
219
309
|
/**
|
|
220
|
-
* The logger to use throught
|
|
310
|
+
* The logger to use throught Hive and its plugins.
|
|
221
311
|
*/
|
|
222
|
-
|
|
312
|
+
log: Logger;
|
|
223
313
|
/**
|
|
224
314
|
* Current working directory.
|
|
225
315
|
*/
|
|
@@ -244,7 +334,7 @@ interface GatewayContext extends GatewayConfigContext, YogaInitialContext {
|
|
|
244
334
|
connectionParams: Record<string, string>;
|
|
245
335
|
}
|
|
246
336
|
type GatewayPlugin<TPluginContext extends Record<string, any> = Record<string, any>, TContext extends Record<string, any> = Record<string, any>> = Plugin<Partial<TPluginContext> & GatewayContext & TContext> & UnifiedGraphPlugin<Partial<TPluginContext> & GatewayContext & TContext> & {
|
|
247
|
-
onFetch?: OnFetchHook<Partial<TPluginContext> &
|
|
337
|
+
onFetch?: OnFetchHook<Partial<TPluginContext> & TContext>;
|
|
248
338
|
onCacheGet?: OnCacheGetHook;
|
|
249
339
|
onCacheSet?: OnCacheSetHook;
|
|
250
340
|
onCacheDelete?: OnCacheDeleteHook;
|
|
@@ -257,6 +347,34 @@ type GatewayPlugin<TPluginContext extends Record<string, any> = Record<string, a
|
|
|
257
347
|
*/
|
|
258
348
|
instrumentation?: Instrumentation<TPluginContext & TContext & GatewayContext>;
|
|
259
349
|
};
|
|
350
|
+
interface OnFetchHookPayload<TContext> {
|
|
351
|
+
url: string;
|
|
352
|
+
setURL(url: URL | string): void;
|
|
353
|
+
options: MeshFetchRequestInit;
|
|
354
|
+
setOptions(options: MeshFetchRequestInit): void;
|
|
355
|
+
/**
|
|
356
|
+
* The context is not available in cases where "fetch" is done in
|
|
357
|
+
* order to pull a supergraph or do some internal work.
|
|
358
|
+
*
|
|
359
|
+
* The logger will be available in all cases.
|
|
360
|
+
*/
|
|
361
|
+
context: (GatewayContext & TContext) | {
|
|
362
|
+
log: Logger;
|
|
363
|
+
};
|
|
364
|
+
/** @deprecated Please use `log` from the {@link context} instead. */
|
|
365
|
+
logger: Logger$1;
|
|
366
|
+
info: GraphQLResolveInfo$1;
|
|
367
|
+
fetchFn: MeshFetch;
|
|
368
|
+
setFetchFn: (fetchFn: MeshFetch) => void;
|
|
369
|
+
executionRequest?: ExecutionRequest;
|
|
370
|
+
endResponse: (response$: MaybePromise$1<Response>) => void;
|
|
371
|
+
}
|
|
372
|
+
interface OnFetchHookDonePayload {
|
|
373
|
+
response: Response;
|
|
374
|
+
setResponse: (response: Response) => void;
|
|
375
|
+
}
|
|
376
|
+
type OnFetchHookDone = (payload: OnFetchHookDonePayload) => MaybePromise$1<void>;
|
|
377
|
+
type OnFetchHook<TContext> = (payload: OnFetchHookPayload<TContext>) => MaybePromise$1<void | OnFetchHookDone>;
|
|
260
378
|
type OnCacheGetHook = (payload: OnCacheGetHookEventPayload) => MaybePromise$1<OnCacheGetHookResult | void>;
|
|
261
379
|
interface OnCacheGetHookEventPayload {
|
|
262
380
|
cache: KeyValueCache;
|
|
@@ -299,10 +417,6 @@ interface OnCacheDeleteHookEventPayload {
|
|
|
299
417
|
}
|
|
300
418
|
type Instrumentation<TContext extends Record<string, any>> = Instrumentation$2<TContext> & Instrumentation$1 & FetchInstrumentation;
|
|
301
419
|
|
|
302
|
-
declare global {
|
|
303
|
-
var DEBUG: string;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
420
|
declare function useDeduplicateRequest(): GatewayPlugin;
|
|
307
421
|
|
|
308
422
|
export { useDeduplicateRequest };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,99 @@
|
|
|
1
1
|
import { DisposableSymbols } from '@whatwg-node/disposablestack';
|
|
2
2
|
import { ExecutionRequest, ExecutionResult, Executor, MaybePromise as MaybePromise$1, Maybe } from '@graphql-tools/utils';
|
|
3
3
|
import { GraphQLSchema, OperationTypeNode, GraphQLFieldResolver, GraphQLResolveInfo, GraphQLOutputType, GraphQLError, SelectionSetNode, FragmentDefinitionNode, FieldNode, ExecutionResult as ExecutionResult$1, SelectionNode } from 'graphql';
|
|
4
|
-
import { Logger, MeshFetch, KeyValueCache, OnFetchHook } from '@graphql-mesh/types';
|
|
5
4
|
import DataLoader from 'dataloader';
|
|
6
5
|
import { GraphQLResolveInfo as GraphQLResolveInfo$1, GraphQLOutputType as GraphQLOutputType$1 } from 'graphql/type';
|
|
7
6
|
import { MaybePromise } from '@whatwg-node/promise-helpers';
|
|
8
7
|
import { Plugin, YogaInitialContext, Instrumentation as Instrumentation$2 } from 'graphql-yoga';
|
|
8
|
+
import { MeshFetch, KeyValueCache, MeshFetchRequestInit, Logger as Logger$1 } from '@graphql-mesh/types';
|
|
9
9
|
import { FetchInstrumentation } from '@graphql-mesh/utils';
|
|
10
10
|
|
|
11
|
+
type MaybeLazy<T> = T | (() => T);
|
|
12
|
+
type AttributeValue = any;
|
|
13
|
+
type Attributes = AttributeValue[] | {
|
|
14
|
+
[key: string | number]: AttributeValue;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
interface LogWriter {
|
|
18
|
+
write(level: LogLevel, attrs: Attributes | null | undefined, msg: string | null | undefined): void | Promise<void>;
|
|
19
|
+
flush?(): void | Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error';
|
|
23
|
+
interface LoggerOptions {
|
|
24
|
+
/**
|
|
25
|
+
* The minimum log level to log.
|
|
26
|
+
*
|
|
27
|
+
* Providing `false` will disable all logging.
|
|
28
|
+
*
|
|
29
|
+
* Provided function will always be invoked to get the current log level.
|
|
30
|
+
*
|
|
31
|
+
* @default env.LOG_LEVEL || env.DEBUG ? 'debug' : 'info'
|
|
32
|
+
*/
|
|
33
|
+
level?: MaybeLazy<LogLevel | false>;
|
|
34
|
+
/** A prefix to include in every log's message. */
|
|
35
|
+
prefix?: string;
|
|
36
|
+
/**
|
|
37
|
+
* The attributes to include in all logs. Is mainly used to pass the parent
|
|
38
|
+
* attributes when creating {@link Logger.child child loggers}.
|
|
39
|
+
*/
|
|
40
|
+
attrs?: Attributes;
|
|
41
|
+
/**
|
|
42
|
+
* The log writers to use when writing logs.
|
|
43
|
+
*
|
|
44
|
+
* @default env.LOG_JSON ? [new JSONLogWriter()] : [new ConsoleLogWriter()]
|
|
45
|
+
*/
|
|
46
|
+
writers?: [LogWriter, ...LogWriter[]];
|
|
47
|
+
}
|
|
48
|
+
declare class Logger implements AsyncDisposable {
|
|
49
|
+
#private;
|
|
50
|
+
constructor(opts?: LoggerOptions);
|
|
51
|
+
/** The prefix that's prepended to each log message. */
|
|
52
|
+
get prefix(): string | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* The attributes that are added to each log. If the log itself contains
|
|
55
|
+
* attributes with keys existing in {@link attrs}, the log's attributes will
|
|
56
|
+
* override.
|
|
57
|
+
*/
|
|
58
|
+
get attrs(): Attributes | undefined;
|
|
59
|
+
/** The current {@link LogLevel} of the logger. You can change the level using the {@link setLevel} method. */
|
|
60
|
+
get level(): false | LogLevel;
|
|
61
|
+
/**
|
|
62
|
+
* Sets the new {@link LogLevel} of the logger. All subsequent logs, and {@link child child loggers} whose
|
|
63
|
+
* level did not change, will respect the new level.
|
|
64
|
+
*/
|
|
65
|
+
setLevel(level: MaybeLazy<LogLevel | false>): void;
|
|
66
|
+
write(level: LogLevel, attrs: Attributes | null | undefined, msg: string | null | undefined): void;
|
|
67
|
+
flush(): Promise<void> | undefined;
|
|
68
|
+
[DisposableSymbols.asyncDispose](): Promise<void | undefined>;
|
|
69
|
+
child(prefix: string): Logger;
|
|
70
|
+
child(attrs: Attributes, prefix?: string): Logger;
|
|
71
|
+
log(level: LogLevel): void;
|
|
72
|
+
log(level: LogLevel, attrs: MaybeLazy<Attributes>): void;
|
|
73
|
+
log(level: LogLevel, msg: string, ...interpol: unknown[]): void;
|
|
74
|
+
log(level: LogLevel, attrs: MaybeLazy<Attributes>, msg: string, ...interpol: unknown[]): void;
|
|
75
|
+
trace(): void;
|
|
76
|
+
trace(attrs: MaybeLazy<Attributes>): void;
|
|
77
|
+
trace(msg: string, ...interpol: unknown[]): void;
|
|
78
|
+
trace(attrs: MaybeLazy<Attributes>, msg: string, ...interpol: unknown[]): void;
|
|
79
|
+
debug(): void;
|
|
80
|
+
debug(attrs: MaybeLazy<Attributes>): void;
|
|
81
|
+
debug(msg: string, ...interpol: unknown[]): void;
|
|
82
|
+
debug(attrs: MaybeLazy<Attributes>, msg: string, ...interpol: unknown[]): void;
|
|
83
|
+
info(): void;
|
|
84
|
+
info(attrs: MaybeLazy<Attributes>): void;
|
|
85
|
+
info(msg: string, ...interpol: unknown[]): void;
|
|
86
|
+
info(attrs: MaybeLazy<Attributes>, msg: string, ...interpol: unknown[]): void;
|
|
87
|
+
warn(): void;
|
|
88
|
+
warn(attrs: MaybeLazy<Attributes>): void;
|
|
89
|
+
warn(msg: string, ...interpol: unknown[]): void;
|
|
90
|
+
warn(attrs: MaybeLazy<Attributes>, msg: string, ...interpol: unknown[]): void;
|
|
91
|
+
error(): void;
|
|
92
|
+
error(attrs: MaybeLazy<Attributes>): void;
|
|
93
|
+
error(msg: string, ...interpol: unknown[]): void;
|
|
94
|
+
error(attrs: MaybeLazy<Attributes>, msg: string, ...interpol: unknown[]): void;
|
|
95
|
+
}
|
|
96
|
+
|
|
11
97
|
type TopicDataMap = Record<string, any>;
|
|
12
98
|
interface HivePubSub<Data extends TopicDataMap = TopicDataMap> {
|
|
13
99
|
/** @deprecated Please use {@link subscribedTopics} if implemented instead. This method will be removed in next major release. */
|
|
@@ -128,7 +214,14 @@ type Instrumentation$1 = {
|
|
|
128
214
|
*/
|
|
129
215
|
subgraphExecute?: (payload: {
|
|
130
216
|
executionRequest: ExecutionRequest;
|
|
217
|
+
subgraphName: string;
|
|
131
218
|
}, wrapped: () => MaybePromise<void>) => MaybePromise<void>;
|
|
219
|
+
/**
|
|
220
|
+
* Wrap each supergraph schema loading.
|
|
221
|
+
*
|
|
222
|
+
* Note: this span is only available when an Async compatible context manager is available
|
|
223
|
+
*/
|
|
224
|
+
schema?: (payload: null, wrapped: () => MaybePromise<void>) => MaybePromise<void>;
|
|
132
225
|
};
|
|
133
226
|
|
|
134
227
|
declare module 'graphql' {
|
|
@@ -150,8 +243,7 @@ interface OnSubgraphExecutePayload<TContext> {
|
|
|
150
243
|
setExecutionRequest(executionRequest: ExecutionRequest): void;
|
|
151
244
|
executor: Executor;
|
|
152
245
|
setExecutor(executor: Executor): void;
|
|
153
|
-
|
|
154
|
-
logger?: Logger;
|
|
246
|
+
log: Logger;
|
|
155
247
|
}
|
|
156
248
|
interface OnSubgraphExecuteDonePayload {
|
|
157
249
|
result: AsyncIterable<ExecutionResult$1> | ExecutionResult$1;
|
|
@@ -178,8 +270,7 @@ interface OnDelegationPlanHookPayload<TContext> {
|
|
|
178
270
|
fragments: Record<string, FragmentDefinitionNode>;
|
|
179
271
|
fieldNodes: SelectionNode[];
|
|
180
272
|
context: TContext;
|
|
181
|
-
|
|
182
|
-
logger?: Logger;
|
|
273
|
+
log: Logger;
|
|
183
274
|
info?: GraphQLResolveInfo$1;
|
|
184
275
|
delegationPlanBuilder: DelegationPlanBuilder;
|
|
185
276
|
setDelegationPlanBuilder(delegationPlanBuilder: DelegationPlanBuilder): void;
|
|
@@ -202,8 +293,7 @@ interface OnDelegationStageExecutePayload<TContext> {
|
|
|
202
293
|
resolver: MergedTypeResolver<TContext>;
|
|
203
294
|
setResolver: (resolver: MergedTypeResolver<TContext>) => void;
|
|
204
295
|
typeName: string;
|
|
205
|
-
|
|
206
|
-
logger?: Logger;
|
|
296
|
+
log: Logger;
|
|
207
297
|
}
|
|
208
298
|
type OnDelegationStageExecuteDoneHook = (payload: OnDelegationStageExecuteDonePayload) => void;
|
|
209
299
|
interface OnDelegationStageExecuteDonePayload {
|
|
@@ -217,9 +307,9 @@ interface GatewayConfigContext {
|
|
|
217
307
|
*/
|
|
218
308
|
fetch: MeshFetch;
|
|
219
309
|
/**
|
|
220
|
-
* The logger to use throught
|
|
310
|
+
* The logger to use throught Hive and its plugins.
|
|
221
311
|
*/
|
|
222
|
-
|
|
312
|
+
log: Logger;
|
|
223
313
|
/**
|
|
224
314
|
* Current working directory.
|
|
225
315
|
*/
|
|
@@ -244,7 +334,7 @@ interface GatewayContext extends GatewayConfigContext, YogaInitialContext {
|
|
|
244
334
|
connectionParams: Record<string, string>;
|
|
245
335
|
}
|
|
246
336
|
type GatewayPlugin<TPluginContext extends Record<string, any> = Record<string, any>, TContext extends Record<string, any> = Record<string, any>> = Plugin<Partial<TPluginContext> & GatewayContext & TContext> & UnifiedGraphPlugin<Partial<TPluginContext> & GatewayContext & TContext> & {
|
|
247
|
-
onFetch?: OnFetchHook<Partial<TPluginContext> &
|
|
337
|
+
onFetch?: OnFetchHook<Partial<TPluginContext> & TContext>;
|
|
248
338
|
onCacheGet?: OnCacheGetHook;
|
|
249
339
|
onCacheSet?: OnCacheSetHook;
|
|
250
340
|
onCacheDelete?: OnCacheDeleteHook;
|
|
@@ -257,6 +347,34 @@ type GatewayPlugin<TPluginContext extends Record<string, any> = Record<string, a
|
|
|
257
347
|
*/
|
|
258
348
|
instrumentation?: Instrumentation<TPluginContext & TContext & GatewayContext>;
|
|
259
349
|
};
|
|
350
|
+
interface OnFetchHookPayload<TContext> {
|
|
351
|
+
url: string;
|
|
352
|
+
setURL(url: URL | string): void;
|
|
353
|
+
options: MeshFetchRequestInit;
|
|
354
|
+
setOptions(options: MeshFetchRequestInit): void;
|
|
355
|
+
/**
|
|
356
|
+
* The context is not available in cases where "fetch" is done in
|
|
357
|
+
* order to pull a supergraph or do some internal work.
|
|
358
|
+
*
|
|
359
|
+
* The logger will be available in all cases.
|
|
360
|
+
*/
|
|
361
|
+
context: (GatewayContext & TContext) | {
|
|
362
|
+
log: Logger;
|
|
363
|
+
};
|
|
364
|
+
/** @deprecated Please use `log` from the {@link context} instead. */
|
|
365
|
+
logger: Logger$1;
|
|
366
|
+
info: GraphQLResolveInfo$1;
|
|
367
|
+
fetchFn: MeshFetch;
|
|
368
|
+
setFetchFn: (fetchFn: MeshFetch) => void;
|
|
369
|
+
executionRequest?: ExecutionRequest;
|
|
370
|
+
endResponse: (response$: MaybePromise$1<Response>) => void;
|
|
371
|
+
}
|
|
372
|
+
interface OnFetchHookDonePayload {
|
|
373
|
+
response: Response;
|
|
374
|
+
setResponse: (response: Response) => void;
|
|
375
|
+
}
|
|
376
|
+
type OnFetchHookDone = (payload: OnFetchHookDonePayload) => MaybePromise$1<void>;
|
|
377
|
+
type OnFetchHook<TContext> = (payload: OnFetchHookPayload<TContext>) => MaybePromise$1<void | OnFetchHookDone>;
|
|
260
378
|
type OnCacheGetHook = (payload: OnCacheGetHookEventPayload) => MaybePromise$1<OnCacheGetHookResult | void>;
|
|
261
379
|
interface OnCacheGetHookEventPayload {
|
|
262
380
|
cache: KeyValueCache;
|
|
@@ -299,10 +417,6 @@ interface OnCacheDeleteHookEventPayload {
|
|
|
299
417
|
}
|
|
300
418
|
type Instrumentation<TContext extends Record<string, any>> = Instrumentation$2<TContext> & Instrumentation$1 & FetchInstrumentation;
|
|
301
419
|
|
|
302
|
-
declare global {
|
|
303
|
-
var DEBUG: string;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
420
|
declare function useDeduplicateRequest(): GatewayPlugin;
|
|
307
421
|
|
|
308
422
|
export { useDeduplicateRequest };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-hive/plugin-deduplicate-request",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-alpha-a15385b922de3f08a097b3e2539e21e758bd362f",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"engines": {
|
|
17
|
-
"node": ">=
|
|
17
|
+
"node": ">=20.0.0"
|
|
18
18
|
},
|
|
19
19
|
"main": "./dist/index.js",
|
|
20
20
|
"types": "./dist/index.d.ts",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"@whatwg-node/promise-helpers": "^1.3.1"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@graphql-hive/gateway-runtime": "
|
|
50
|
+
"@graphql-hive/gateway-runtime": "2.0.0-alpha-a15385b922de3f08a097b3e2539e21e758bd362f",
|
|
51
51
|
"@graphql-mesh/types": "^0.104.5",
|
|
52
52
|
"@whatwg-node/fetch": "^0.10.8",
|
|
53
53
|
"graphql": "^16.9.0",
|