@graphql-box/connection-resolver 5.4.23-unstable-12345.4 → 5.4.23-unstable-12345.5

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.23-unstable-12345.4",
4
+ "version": "5.4.23-unstable-12345.5",
5
5
  "author": "miami-man",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/badbatch/graphql-box",
@@ -38,7 +38,7 @@
38
38
  "js-base64": "^3.7.7",
39
39
  "lodash-es": "^4.17.23",
40
40
  "type-fest": "^4.41.0",
41
- "@graphql-box/core": "5.4.14-unstable-12345.4"
41
+ "@graphql-box/core": "5.4.14-unstable-12345.5"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "graphql": "<17",
@@ -1,22 +1,22 @@
1
1
  import { type Core } from '@cachemap/core';
2
- import { type PlainObject } from '@graphql-box/core';
2
+ import { type PlainObject, type SetCacheMetadata } from '@graphql-box/core';
3
+ import { type GraphQLResolveInfo } from 'graphql';
3
4
  import {
4
5
  type CachedEdges,
5
6
  type CursorGroupMetadata,
6
7
  type Getters,
7
8
  type Node,
8
9
  type ResourceResolver,
9
- type SetCacheMetadata,
10
10
  } from '../types.ts';
11
11
  import { cacheCursors } from './cacheCursors.ts';
12
12
  import { makeEdges } from './makeEdges.ts';
13
13
 
14
14
  export type Context<Resource extends PlainObject, ResourceNode extends Node> = {
15
15
  cursorCache: Core;
16
- fieldPath: string;
17
16
  getters: Getters<Resource, ResourceNode>;
18
17
  groupCursor: string;
19
18
  makeIDCursor: (id: string | number) => string;
19
+ resolverInfo: GraphQLResolveInfo;
20
20
  resourceResolver: ResourceResolver<Resource>;
21
21
  setCacheMetadata: SetCacheMetadata | undefined;
22
22
  };
@@ -29,10 +29,10 @@ export const requestAndCachePages = async <Resource extends PlainObject, Resourc
29
29
  pages: number[],
30
30
  {
31
31
  cursorCache,
32
- fieldPath,
33
32
  getters,
34
33
  groupCursor,
35
34
  makeIDCursor,
35
+ resolverInfo,
36
36
  resourceResolver,
37
37
  setCacheMetadata,
38
38
  }: Context<Resource, ResourceNode>,
@@ -52,7 +52,7 @@ export const requestAndCachePages = async <Resource extends PlainObject, Resourc
52
52
  });
53
53
 
54
54
  if (pageResultData) {
55
- setCacheMetadata?.(fieldPath, pageResultHeaders);
55
+ setCacheMetadata?.(pageResultData, resolverInfo, pageResultHeaders);
56
56
  }
57
57
 
58
58
  if (pageResultData && !pageResultErrors?.length) {
@@ -1,12 +1,7 @@
1
1
  import { type Core } from '@cachemap/core';
2
- import { type PlainObject } from '@graphql-box/core';
3
- import {
4
- type ConnectionInputOptions,
5
- type Getters,
6
- type Node,
7
- type ResourceResolver,
8
- type SetCacheMetadata,
9
- } from '../types.ts';
2
+ import { type PlainObject, type SetCacheMetadata } from '@graphql-box/core';
3
+ import { type GraphQLResolveInfo } from 'graphql';
4
+ import { type ConnectionInputOptions, type Getters, type Node, type ResourceResolver } from '../types.ts';
10
5
  import { extractEdges } from './extractEdges.ts';
11
6
  import { extractNodes } from './extractNodes.ts';
12
7
  import { getInRangeCachedEdges } from './getInRangeCachedEdges.ts';
@@ -17,10 +12,10 @@ import { retrieveCachedConnection } from './retrieveCachedConnection.ts';
17
12
 
18
13
  export type Context<Resource extends PlainObject, ResourceNode extends Node> = {
19
14
  cursorCache: Core;
20
- fieldPath: string;
21
15
  getters: Getters<Resource, ResourceNode>;
22
16
  groupCursor: string;
23
17
  makeIDCursor: (id: string | number) => string;
18
+ resolverInfo: GraphQLResolveInfo;
24
19
  resourceResolver: ResourceResolver<Resource>;
25
20
  resultsPerPage: number;
26
21
  setCacheMetadata: SetCacheMetadata | undefined;
@@ -30,10 +25,10 @@ export const resolveConnection = async <Resource extends PlainObject, ResourceNo
30
25
  args: PlainObject & ConnectionInputOptions,
31
26
  {
32
27
  cursorCache,
33
- fieldPath,
34
28
  getters,
35
29
  groupCursor,
36
30
  makeIDCursor,
31
+ resolverInfo,
37
32
  resourceResolver,
38
33
  resultsPerPage,
39
34
  setCacheMetadata,
@@ -65,10 +60,10 @@ export const resolveConnection = async <Resource extends PlainObject, ResourceNo
65
60
 
66
61
  const { cachedEdges: missingCachedEdges, errors } = await requestAndCachePages<Resource, ResourceNode>(missingPages, {
67
62
  cursorCache,
68
- fieldPath,
69
63
  getters,
70
64
  groupCursor,
71
65
  makeIDCursor,
66
+ resolverInfo,
72
67
  resourceResolver,
73
68
  setCacheMetadata,
74
69
  });
package/src/main/index.ts CHANGED
@@ -83,10 +83,10 @@ export const makeConnectionResolver =
83
83
  return resolver(
84
84
  await resolveConnection(args, {
85
85
  cursorCache,
86
- fieldPath,
87
86
  getters,
88
87
  groupCursor,
89
88
  makeIDCursor,
89
+ resolverInfo: info,
90
90
  resourceResolver,
91
91
  resultsPerPage,
92
92
  setCacheMetadata,
@@ -98,10 +98,10 @@ export const makeConnectionResolver =
98
98
  return resolver(
99
99
  await resolveConnection(args, {
100
100
  cursorCache,
101
- fieldPath,
102
101
  getters,
103
102
  groupCursor,
104
103
  makeIDCursor,
104
+ resolverInfo: info,
105
105
  resourceResolver,
106
106
  resultsPerPage,
107
107
  setCacheMetadata,
@@ -111,10 +111,10 @@ export const makeConnectionResolver =
111
111
 
112
112
  await requestAndCachePages<Resource, ResourceNode>([1], {
113
113
  cursorCache,
114
- fieldPath,
115
114
  getters,
116
115
  groupCursor,
117
116
  makeIDCursor,
117
+ resolverInfo: info,
118
118
  resourceResolver,
119
119
  setCacheMetadata,
120
120
  });
@@ -122,10 +122,10 @@ export const makeConnectionResolver =
122
122
  return resolver(
123
123
  await resolveConnection(args, {
124
124
  cursorCache,
125
- fieldPath,
126
125
  getters,
127
126
  groupCursor,
128
127
  makeIDCursor,
128
+ resolverInfo: info,
129
129
  resourceResolver,
130
130
  resultsPerPage,
131
131
  setCacheMetadata,
package/src/types.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { type Core } from '@cachemap/core';
2
2
  import { type ExecutionContextValue, type PlainObject } from '@graphql-box/core';
3
- import { type GraphQLResolveInfo, type OperationTypeNode } from 'graphql';
3
+ import { type GraphQLResolveInfo } from 'graphql';
4
4
  import { type SetOptional } from 'type-fest';
5
5
  import { type Logger } from 'winston';
6
6
 
@@ -63,8 +63,6 @@ export type ResourceResolver<Resource extends PlainObject> = (args: {
63
63
  page: number;
64
64
  }) => Promise<ResourceResponse<Resource>>;
65
65
 
66
- export type SetCacheMetadata = (key: string, headers: Headers, operation?: OperationTypeNode) => void;
67
-
68
66
  export type Context = ExecutionContextValue & {
69
67
  logger?: Logger;
70
68
  };