@graphql-mesh/plugin-jwt-auth 1.5.4 → 2.0.0-alpha-f3f43a13e2e907dc5acc4be8a23dc9870b2d6787

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