@graphql-box/connection-resolver 5.4.8 → 5.4.10

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@graphql-box/connection-resolver",
3
3
  "description": "The GraphQL Box connection resolver module.",
4
- "version": "5.4.8",
4
+ "version": "5.4.10",
5
5
  "author": "Dylan Aubrey",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/badbatch/graphql-box",
@@ -7,7 +7,7 @@ import { encode } from 'js-base64';
7
7
  import { generateCursorCache } from '../__testUtils__/generateCursorCache.ts';
8
8
  import { generatePageResponse } from '../__testUtils__/generatePageResponse.ts';
9
9
  import { removeConnectionInputOptions } from '../helpers/removeConnectionInputOptions.ts';
10
- import { type Getters, type Node, type ResourceResponse } from '../types.ts';
10
+ import { type Context, type Getters, type Node, type ResourceResponse } from '../types.ts';
11
11
  import { makeConnectionResolver } from './index.ts';
12
12
 
13
13
  const createMakeCursors = (_source: PlainObject, args: PlainObject) => ({
@@ -49,7 +49,7 @@ describe('connectionResolver', () => {
49
49
 
50
50
  const args = { before: 'abcdefg', first: 5, query: 'Hello world!' };
51
51
  const info = {};
52
- result = await connectionResolver({}, args, {}, info as GraphQLResolveInfo);
52
+ result = await connectionResolver({}, args, {} as Context, info as GraphQLResolveInfo);
53
53
  });
54
54
 
55
55
  it('should return the correct result', () => {
@@ -104,7 +104,7 @@ describe('connectionResolver', () => {
104
104
  };
105
105
 
106
106
  const info = {};
107
- result = await connectionResolver({}, args, {}, info as GraphQLResolveInfo);
107
+ result = await connectionResolver({}, args, {} as Context, info as GraphQLResolveInfo);
108
108
  });
109
109
 
110
110
  it('should return the correct result', () => {
@@ -151,7 +151,7 @@ describe('connectionResolver', () => {
151
151
  };
152
152
 
153
153
  const info = {};
154
- result = await connectionResolver({}, args, {}, info as GraphQLResolveInfo);
154
+ result = await connectionResolver({}, args, {} as Context, info as GraphQLResolveInfo);
155
155
  });
156
156
 
157
157
  it('should return the correct result', () => {
@@ -202,7 +202,7 @@ describe('connectionResolver', () => {
202
202
  };
203
203
 
204
204
  const info = {};
205
- result = await connectionResolver({}, args, {}, info as GraphQLResolveInfo);
205
+ result = await connectionResolver({}, args, {} as Context, info as GraphQLResolveInfo);
206
206
  });
207
207
 
208
208
  it('should return the correct result', () => {
@@ -248,7 +248,7 @@ describe('connectionResolver', () => {
248
248
  };
249
249
 
250
250
  const info = {};
251
- result = await connectionResolver({}, args, {}, info as GraphQLResolveInfo);
251
+ result = await connectionResolver({}, args, {} as Context, info as GraphQLResolveInfo);
252
252
  });
253
253
 
254
254
  it('should return the correct result', () => {
@@ -298,7 +298,7 @@ describe('connectionResolver', () => {
298
298
  };
299
299
 
300
300
  const info = {};
301
- result = await connectionResolver({}, args, {}, info as GraphQLResolveInfo);
301
+ result = await connectionResolver({}, args, {} as Context, info as GraphQLResolveInfo);
302
302
  });
303
303
 
304
304
  it('should return the correct result', () => {
@@ -349,7 +349,7 @@ describe('connectionResolver', () => {
349
349
  };
350
350
 
351
351
  const info = {};
352
- result = await connectionResolver({}, args, {}, info as GraphQLResolveInfo);
352
+ result = await connectionResolver({}, args, {} as Context, info as GraphQLResolveInfo);
353
353
  });
354
354
 
355
355
  it('should return the correct result', () => {
@@ -395,7 +395,7 @@ describe('connectionResolver', () => {
395
395
  };
396
396
 
397
397
  const info = {};
398
- result = await connectionResolver({}, args, {}, info as GraphQLResolveInfo);
398
+ result = await connectionResolver({}, args, {} as Context, info as GraphQLResolveInfo);
399
399
  });
400
400
 
401
401
  it('should return the correct result', () => {
@@ -445,7 +445,7 @@ describe('connectionResolver', () => {
445
445
  };
446
446
 
447
447
  const info = {};
448
- result = await connectionResolver({}, args, {}, info as GraphQLResolveInfo);
448
+ result = await connectionResolver({}, args, {} as Context, info as GraphQLResolveInfo);
449
449
  });
450
450
 
451
451
  it('should return the correct result', () => {
package/src/main/index.ts CHANGED
@@ -34,19 +34,22 @@ export const makeConnectionResolver =
34
34
  info: GraphQLResolveInfo,
35
35
  ): Promise<Connection> => {
36
36
  const { makeGroupCursor, makeIDCursor } = createMakeCursors(source, args, context, info);
37
- const resourceResolver = createResourceResolver(source, args, context, info);
38
37
  const groupCursor = makeGroupCursor();
39
- const { logger, operationName, requestID, setCacheMetadata } = context;
38
+ const { logger, setCacheMetadata } = context;
40
39
  const { fieldName: fieldPath } = info;
41
40
 
42
- const childLogger = logger?.child({
43
- args,
44
- fieldPath,
45
- groupCursor,
46
- operationName,
47
- requestID,
48
- });
41
+ const newCtx = {
42
+ ...context,
43
+ data: {
44
+ ...context.data,
45
+ args,
46
+ fieldPath,
47
+ groupCursor,
48
+ },
49
+ };
49
50
 
51
+ const resourceResolver = createResourceResolver(source, args, newCtx, info);
52
+ const childLogger = logger?.child(newCtx.data);
50
53
  childLogger?.info(`Resolving ${fieldPath}`);
51
54
 
52
55
  if (isCursorSupplied(args)) {
package/src/types.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { type Core } from '@cachemap/core';
2
- import { type PlainObject } from '@graphql-box/core';
2
+ import { type ExecutionContextValue, type PlainObject } from '@graphql-box/core';
3
3
  import { type GraphQLResolveInfo, type OperationTypeNode } from 'graphql';
4
4
  import { type SetOptional } from 'type-fest';
5
5
  import { type Logger } from 'winston';
@@ -64,9 +64,8 @@ export type ResourceResolver<Resource extends PlainObject> = (args: {
64
64
 
65
65
  export type SetCacheMetadata = (key: string, headers: Headers, operation?: OperationTypeNode) => void;
66
66
 
67
- export type Context = PlainObject & {
67
+ export type Context = ExecutionContextValue & {
68
68
  logger?: Logger;
69
- setCacheMetadata?: SetCacheMetadata;
70
69
  };
71
70
 
72
71
  export type CreateResourceResolver<