@pothos/selection-mapper 0.1.0 → 0.3.0
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 +30 -0
- package/README.md +16 -6
- package/dts/deep-equal.d.ts +4 -0
- package/dts/deep-equal.d.ts.map +1 -1
- package/dts/errors.d.ts +7 -0
- package/dts/errors.d.ts.map +1 -0
- package/dts/index.d.ts +3 -2
- package/dts/index.d.ts.map +1 -1
- package/dts/loader-map.d.ts +37 -16
- package/dts/loader-map.d.ts.map +1 -1
- package/dts/matches.d.ts +5 -0
- package/dts/matches.d.ts.map +1 -1
- package/dts/parent-types.d.ts +9 -0
- package/dts/parent-types.d.ts.map +1 -0
- package/dts/plan.d.ts +36 -20
- package/dts/plan.d.ts.map +1 -1
- package/dts/shape.d.ts +8 -0
- package/dts/shape.d.ts.map +1 -0
- package/dts/types.d.ts +21 -1
- package/dts/types.d.ts.map +1 -1
- package/dts/walk.d.ts +20 -2
- package/dts/walk.d.ts.map +1 -1
- package/esm/deep-equal.d.ts +4 -0
- package/esm/deep-equal.d.ts.map +1 -1
- package/esm/deep-equal.js +60 -28
- package/esm/deep-equal.js.map +1 -1
- package/esm/errors.d.ts +7 -0
- package/esm/errors.d.ts.map +1 -0
- package/esm/errors.js +11 -0
- package/esm/errors.js.map +1 -0
- package/esm/index.d.ts +3 -2
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +2 -1
- package/esm/index.js.map +1 -1
- package/esm/loader-map.d.ts +37 -16
- package/esm/loader-map.d.ts.map +1 -1
- package/esm/loader-map.js +165 -99
- package/esm/loader-map.js.map +1 -1
- package/esm/matches.d.ts +5 -0
- package/esm/matches.d.ts.map +1 -1
- package/esm/matches.js +11 -3
- package/esm/matches.js.map +1 -1
- package/esm/parent-types.d.ts +9 -0
- package/esm/parent-types.d.ts.map +1 -0
- package/esm/parent-types.js +24 -0
- package/esm/parent-types.js.map +1 -0
- package/esm/plan.d.ts +36 -20
- package/esm/plan.d.ts.map +1 -1
- package/esm/plan.js +107 -71
- package/esm/plan.js.map +1 -1
- package/esm/shape.d.ts +8 -0
- package/esm/shape.d.ts.map +1 -0
- package/esm/shape.js +94 -0
- package/esm/shape.js.map +1 -0
- package/esm/types.d.ts +21 -1
- package/esm/types.d.ts.map +1 -1
- package/esm/types.js.map +1 -1
- package/esm/walk.d.ts +20 -2
- package/esm/walk.d.ts.map +1 -1
- package/esm/walk.js +199 -71
- package/esm/walk.js.map +1 -1
- package/lib/deep-equal.js +60 -28
- package/lib/deep-equal.js.map +1 -1
- package/lib/errors.js +18 -0
- package/lib/errors.js.map +1 -0
- package/lib/index.js +13 -3
- package/lib/index.js.map +1 -1
- package/lib/loader-map.js +145 -90
- package/lib/loader-map.js.map +1 -1
- package/lib/matches.js +14 -3
- package/lib/matches.js.map +1 -1
- package/lib/parent-types.js +29 -0
- package/lib/parent-types.js.map +1 -0
- package/lib/plan.js +107 -71
- package/lib/plan.js.map +1 -1
- package/lib/shape.js +109 -0
- package/lib/shape.js.map +1 -0
- package/lib/walk.js +186 -68
- package/lib/walk.js.map +1 -1
- package/package.json +4 -3
- package/src/deep-equal.ts +77 -34
- package/src/errors.ts +12 -0
- package/src/index.ts +6 -1
- package/src/loader-map.ts +235 -125
- package/src/matches.ts +15 -3
- package/src/parent-types.ts +33 -0
- package/src/plan.ts +145 -78
- package/src/shape.ts +126 -0
- package/src/types.ts +25 -1
- package/src/walk.ts +250 -83
package/esm/deep-equal.js
CHANGED
|
@@ -2,49 +2,81 @@
|
|
|
2
2
|
* Structural equality for query arguments (`where`, `orderBy`, `take`, ...). Keys holding
|
|
3
3
|
* `undefined` are treated as absent, so `{ where: cond ? filter : undefined }` compares equal to
|
|
4
4
|
* `{}` when the condition is false.
|
|
5
|
+
*
|
|
6
|
+
* Plain objects and arrays compare by value, and Dates by their time. Any other object (a Temporal
|
|
7
|
+
* value, a `Decimal`, a `Buffer`, a typed array) equals only an object of the same prototype that
|
|
8
|
+
* its `equals` method accepts, or itself when it has none.
|
|
5
9
|
*/ export function deepEqual(left, right) {
|
|
6
10
|
if (left === right) {
|
|
7
11
|
return true;
|
|
8
12
|
}
|
|
9
|
-
if (left && right && typeof left === 'object' && typeof right === 'object') {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (right.length !== length) {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
for(let i = 0; i < length; i += 1){
|
|
19
|
-
if (!deepEqual(left[i], right[i])) {
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return true;
|
|
24
|
-
}
|
|
25
|
-
const lValue = left.valueOf?.();
|
|
26
|
-
const rValue = right.valueOf?.();
|
|
27
|
-
// A boxed value (a Date, a boxed primitive) compares by its primitive, whichever side it is
|
|
28
|
-
// on: a plain object's `valueOf` returns the object itself, and a null-prototype object has
|
|
29
|
-
// none at all, so neither is mistaken for one.
|
|
30
|
-
if (lValue != null && typeof lValue !== 'object' || rValue != null && typeof rValue !== 'object') {
|
|
31
|
-
return lValue === rValue;
|
|
13
|
+
if (!(left && right && typeof left === 'object' && typeof right === 'object')) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
if (Array.isArray(left) || Array.isArray(right)) {
|
|
17
|
+
if (!Array.isArray(left) || !Array.isArray(right)) {
|
|
18
|
+
return false;
|
|
32
19
|
}
|
|
33
|
-
const
|
|
34
|
-
if (
|
|
20
|
+
const { length } = left;
|
|
21
|
+
if (right.length !== length) {
|
|
35
22
|
return false;
|
|
36
23
|
}
|
|
37
|
-
for
|
|
38
|
-
if (!deepEqual(left[
|
|
24
|
+
for(let i = 0; i < length; i += 1){
|
|
25
|
+
if (!deepEqual(left[i], right[i])) {
|
|
39
26
|
return false;
|
|
40
27
|
}
|
|
41
28
|
}
|
|
42
29
|
return true;
|
|
43
30
|
}
|
|
44
|
-
|
|
31
|
+
// Two objects of `Object.prototype`, the common case, need no further check.
|
|
32
|
+
if (Object.getPrototypeOf(left) !== Object.prototype || Object.getPrototypeOf(right) !== Object.prototype) {
|
|
33
|
+
const leftPlain = isPlain(left);
|
|
34
|
+
if (leftPlain !== isPlain(right)) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
if (!leftPlain) {
|
|
38
|
+
return instancesEqual(left, right);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const keys = comparedKeys(left);
|
|
42
|
+
if (keys.length !== definedKeyCount(right)) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
for (const key of keys){
|
|
46
|
+
if (!deepEqual(left[key], right[key])) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
function isPlain(value) {
|
|
53
|
+
const proto = Object.getPrototypeOf(value);
|
|
54
|
+
return proto === null || proto === Object.prototype;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The shared prototype keeps the comparison symmetric, since Temporal's `equals` also accepts
|
|
58
|
+
* property bags and strings.
|
|
59
|
+
*/ function instancesEqual(left, right) {
|
|
60
|
+
if (Object.getPrototypeOf(left) !== Object.getPrototypeOf(right)) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
if (left instanceof Date) {
|
|
64
|
+
return left.getTime() === right.getTime();
|
|
65
|
+
}
|
|
66
|
+
const { equals } = left;
|
|
67
|
+
return typeof equals === 'function' && equals.call(left, right) === true;
|
|
45
68
|
}
|
|
46
69
|
function comparedKeys(value) {
|
|
47
70
|
return Object.keys(value).filter((key)=>value[key] !== undefined);
|
|
48
71
|
}
|
|
72
|
+
function definedKeyCount(value) {
|
|
73
|
+
let count = 0;
|
|
74
|
+
for (const key of Object.keys(value)){
|
|
75
|
+
if (value[key] !== undefined) {
|
|
76
|
+
count += 1;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return count;
|
|
80
|
+
}
|
|
49
81
|
|
|
50
82
|
//# sourceMappingURL=deep-equal.js.map
|
package/esm/deep-equal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/deep-equal.ts"],"names":["deepEqual","left","right","Array","isArray","length","i","
|
|
1
|
+
{"version":3,"sources":["../src/deep-equal.ts"],"names":["deepEqual","left","right","Array","isArray","length","i","Object","getPrototypeOf","prototype","leftPlain","isPlain","instancesEqual","keys","comparedKeys","definedKeyCount","key","value","proto","Date","getTime","equals","call","filter","undefined","count"],"mappings":"AAAA;;;;;;;;CAQC,GACD,OAAO,SAASA,UAAUC,IAAa,EAAEC,KAAc;IACrD,IAAID,SAASC,OAAO;QAClB,OAAO;IACT;IAEA,IAAI,CAAED,CAAAA,QAAQC,SAAS,OAAOD,SAAS,YAAY,OAAOC,UAAU,QAAO,GAAI;QAC7E,OAAO;IACT;IAEA,IAAIC,MAAMC,OAAO,CAACH,SAASE,MAAMC,OAAO,CAACF,QAAQ;QAC/C,IAAI,CAACC,MAAMC,OAAO,CAACH,SAAS,CAACE,MAAMC,OAAO,CAACF,QAAQ;YACjD,OAAO;QACT;QAEA,MAAM,EAAEG,MAAM,EAAE,GAAGJ;QAEnB,IAAIC,MAAMG,MAAM,KAAKA,QAAQ;YAC3B,OAAO;QACT;QAEA,IAAK,IAAIC,IAAI,GAAGA,IAAID,QAAQC,KAAK,EAAG;YAClC,IAAI,CAACN,UAAUC,IAAI,CAACK,EAAE,EAAEJ,KAAK,CAACI,EAAE,GAAG;gBACjC,OAAO;YACT;QACF;QAEA,OAAO;IACT;IAEA,6EAA6E;IAC7E,IACEC,OAAOC,cAAc,CAACP,UAAUM,OAAOE,SAAS,IAChDF,OAAOC,cAAc,CAACN,WAAWK,OAAOE,SAAS,EACjD;QACA,MAAMC,YAAYC,QAAQV;QAE1B,IAAIS,cAAcC,QAAQT,QAAQ;YAChC,OAAO;QACT;QAEA,IAAI,CAACQ,WAAW;YACd,OAAOE,eAAeX,MAAMC;QAC9B;IACF;IAEA,MAAMW,OAAOC,aAAab;IAE1B,IAAIY,KAAKR,MAAM,KAAKU,gBAAgBb,QAAmC;QACrE,OAAO;IACT;IAEA,KAAK,MAAMc,OAAOH,KAAM;QACtB,IACE,CAACb,UAAU,AAACC,IAAgC,CAACe,IAAI,EAAE,AAACd,KAAiC,CAACc,IAAI,GAC1F;YACA,OAAO;QACT;IACF;IAEA,OAAO;AACT;AAEA,SAASL,QAAQM,KAAa;IAC5B,MAAMC,QAAQX,OAAOC,cAAc,CAACS;IAEpC,OAAOC,UAAU,QAAQA,UAAUX,OAAOE,SAAS;AACrD;AAEA;;;CAGC,GACD,SAASG,eAAeX,IAAY,EAAEC,KAAa;IACjD,IAAIK,OAAOC,cAAc,CAACP,UAAUM,OAAOC,cAAc,CAACN,QAAQ;QAChE,OAAO;IACT;IAEA,IAAID,gBAAgBkB,MAAM;QACxB,OAAOlB,KAAKmB,OAAO,OAAO,AAAClB,MAAekB,OAAO;IACnD;IAEA,MAAM,EAAEC,MAAM,EAAE,GAAGpB;IAEnB,OAAO,OAAOoB,WAAW,cAAcA,OAAOC,IAAI,CAACrB,MAAMC,WAAW;AACtE;AAEA,SAASY,aAAaG,KAA8B;IAClD,OAAOV,OAAOM,IAAI,CAACI,OAAOM,MAAM,CAAC,CAACP,MAAQC,KAAK,CAACD,IAAI,KAAKQ;AAC3D;AAEA,SAAST,gBAAgBE,KAA8B;IACrD,IAAIQ,QAAQ;IAEZ,KAAK,MAAMT,OAAOT,OAAOM,IAAI,CAACI,OAAQ;QACpC,IAAIA,KAAK,CAACD,IAAI,KAAKQ,WAAW;YAC5BC,SAAS;QACX;IACF;IAEA,OAAOA;AACT"}
|
package/esm/errors.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PothosValidationError } from '@pothos/core';
|
|
2
|
+
/**
|
|
3
|
+
* An error raised while a request runs for a problem in the app's schema or code. Clients see only
|
|
4
|
+
* `Unexpected error.`; `detail` is the message of its `cause`, which responses leave out.
|
|
5
|
+
*/
|
|
6
|
+
export declare function unexpectedError(detail: string): PothosValidationError;
|
|
7
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAErD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,yBAK7C"}
|
package/esm/errors.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PothosValidationError } from '@pothos/core';
|
|
2
|
+
/**
|
|
3
|
+
* An error raised while a request runs for a problem in the app's schema or code. Clients see only
|
|
4
|
+
* `Unexpected error.`; `detail` is the message of its `cause`, which responses leave out.
|
|
5
|
+
*/ export function unexpectedError(detail) {
|
|
6
|
+
const error = new PothosValidationError('Unexpected error.');
|
|
7
|
+
error.cause = new PothosValidationError(detail);
|
|
8
|
+
return error;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts"],"names":["PothosValidationError","unexpectedError","detail","error","cause"],"mappings":"AAAA,SAASA,qBAAqB,QAAQ,eAAe;AAErD;;;CAGC,GACD,OAAO,SAASC,gBAAgBC,MAAc;IAC5C,MAAMC,QAAQ,IAAIH,sBAAsB;IACxCG,MAAMC,KAAK,GAAG,IAAIJ,sBAAsBE;IAExC,OAAOC;AACT"}
|
package/esm/index.d.ts
CHANGED
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export { Adapter } from './adapter.js';
|
|
7
7
|
export { deepEqual } from './deep-equal.js';
|
|
8
|
-
export { cacheKey, getLoaderMapping, type
|
|
8
|
+
export { cacheKey, fieldKey, forExecution, forOperation, getLoaderMapping, type Mapping, type Mappings, setLoaderMappings, setRowFieldMapping, setRowMappings, } from './loader-map.js';
|
|
9
9
|
export { type IndirectInclude, type IndirectPathSegment, type PathSegment, selectedFieldNames, } from './matches.js';
|
|
10
10
|
export { type Node, NodeAdapter, type QueryVisitor } from './node.js';
|
|
11
|
+
export { mappingParentTypes } from './parent-types.js';
|
|
11
12
|
export { Plan, type PlayedPlan } from './plan.js';
|
|
12
|
-
export type { MergeOptions, NestedSelection, Position, SelectedFieldNode, SelectFn, WalkedType, } from './types.js';
|
|
13
|
+
export type { MergeOptions, NestedSelection, ParentRowOptions, Position, SelectedFieldNode, SelectFn, WalkedType, } from './types.js';
|
|
13
14
|
//# sourceMappingURL=index.d.ts.map
|
package/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EACL,QAAQ,EACR,gBAAgB,EAChB,KAAK,QAAQ,EACb,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,KAAK,OAAO,EACZ,KAAK,QAAQ,EACb,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,GACf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,WAAW,EAChB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,KAAK,IAAI,EAAE,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,WAAW,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAClD,YAAY,EACV,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,QAAQ,EACR,iBAAiB,EACjB,QAAQ,EACR,UAAU,GACX,MAAM,YAAY,CAAC"}
|
package/esm/index.js
CHANGED
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
* adapters and loaders call. Everything else is module-private; see the README.
|
|
5
5
|
*/ export { Adapter } from './adapter.js';
|
|
6
6
|
export { deepEqual } from './deep-equal.js';
|
|
7
|
-
export { cacheKey,
|
|
7
|
+
export { cacheKey, fieldKey, forExecution, forOperation, getLoaderMapping, setLoaderMappings, setRowFieldMapping, setRowMappings } from './loader-map.js';
|
|
8
8
|
export { selectedFieldNames } from './matches.js';
|
|
9
9
|
export { NodeAdapter } from './node.js';
|
|
10
|
+
export { mappingParentTypes } from './parent-types.js';
|
|
10
11
|
export { Plan } from './plan.js';
|
|
11
12
|
|
|
12
13
|
//# sourceMappingURL=index.js.map
|
package/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":["Adapter","deepEqual","cacheKey","
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":["Adapter","deepEqual","cacheKey","fieldKey","forExecution","forOperation","getLoaderMapping","setLoaderMappings","setRowFieldMapping","setRowMappings","selectedFieldNames","NodeAdapter","mappingParentTypes","Plan"],"mappings":"AAAA;;;;CAIC,GACD,SAASA,OAAO,QAAQ,eAAe;AACvC,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SACEC,QAAQ,EACRC,QAAQ,EACRC,YAAY,EACZC,YAAY,EACZC,gBAAgB,EAGhBC,iBAAiB,EACjBC,kBAAkB,EAClBC,cAAc,QACT,kBAAkB;AACzB,SAIEC,kBAAkB,QACb,eAAe;AACtB,SAAoBC,WAAW,QAA2B,YAAY;AACtE,SAASC,kBAAkB,QAAQ,oBAAoB;AACvD,SAASC,IAAI,QAAyB,YAAY"}
|
package/esm/loader-map.d.ts
CHANGED
|
@@ -21,43 +21,64 @@ export declare const EMPTY_MAPPING: Mapping;
|
|
|
21
21
|
/**
|
|
22
22
|
* Adopts the first mapping recorded for a key; a later one deep-unions into a copy, so a recorded
|
|
23
23
|
* mapping is never changed after the fact (two plays may accept a different subset of the fields).
|
|
24
|
+
*
|
|
25
|
+
* Invocations of one field share what is beneath them (see `Plan.nested`), so a mapping is a DAG
|
|
26
|
+
* whose keys can all lead to one mapping. A pair is unioned once however many keys lead to it, or
|
|
27
|
+
* the union would take as long as the DAG written out as a tree.
|
|
24
28
|
*/
|
|
25
29
|
export declare function unionMappings(into: Mapping | undefined, from: Mapping): Mapping;
|
|
30
|
+
/**
|
|
31
|
+
* The entries of `cache` for the operation `info` is in. Keyed on its `variableValues`, which
|
|
32
|
+
* every executor coerces afresh for each operation, so operations sharing a context never share
|
|
33
|
+
* an entry. The events of a subscription may share one, so a plan cached here runs its `select`
|
|
34
|
+
* and `query` callbacks once for all of them. Use `forExecution` if the callbacks read per-event
|
|
35
|
+
* state.
|
|
36
|
+
*/
|
|
37
|
+
export declare function forOperation<T>(cache: WeakMap<object, Map<string, T>>, info: GraphQLResolveInfo): Map<string, T>;
|
|
38
|
+
/**
|
|
39
|
+
* The entries of `cache` for the execution `info` is in. Each event of a subscription gets its own
|
|
40
|
+
* entries, and `@defer` and `@stream` payloads share the entries of their execution.
|
|
41
|
+
*/
|
|
42
|
+
export declare function forExecution<T>(cache: WeakMap<object, Map<string, T>>, info: GraphQLResolveInfo): Map<string, T>;
|
|
26
43
|
/** The string keys of a response path joined by `.`; list indices are dropped. */
|
|
27
44
|
export declare function responsePath(path: GraphQLResolveInfo['path'] | undefined): string;
|
|
28
45
|
export declare function cacheKey(type: string, path: GraphQLResolveInfo['path']): string;
|
|
46
|
+
/**
|
|
47
|
+
* The key to cache a field's plan under: `cacheKey(type, info.path)` plus an id for each node in
|
|
48
|
+
* `info.fieldNodes`. The path leaves out list indices, so the items of a list share a plan. The
|
|
49
|
+
* root fields of a mutation run in turn, and a callback may read what an earlier field changed.
|
|
50
|
+
* Their paths differ, so each gets its own plan. The nodes are part of the key because fragments on
|
|
51
|
+
* different types can merge different nodes into one response path, and a plan keyed on the path
|
|
52
|
+
* alone would be reused for a field that selects something else.
|
|
53
|
+
*/
|
|
54
|
+
export declare function fieldKey(type: string, info: GraphQLResolveInfo): string;
|
|
29
55
|
/**
|
|
30
56
|
* Records the mappings of a plan rooted at the field `info` resolves, under that field's path.
|
|
31
|
-
* The plan loaded the whole field, so its mappings
|
|
32
|
-
*
|
|
57
|
+
* The plan loaded the whole field, so its mappings are used for everything resolved beneath this
|
|
58
|
+
* execution of it. Multiple plans can contribute to one field (Relay nodes of different model
|
|
33
59
|
* types share the list's path), so later contributions replace matching keys and retain others.
|
|
34
60
|
*/
|
|
35
61
|
export declare function setLoaderMappings(ctx: object, info: GraphQLResolveInfo, mappings: Mappings): void;
|
|
36
62
|
/**
|
|
37
63
|
* Records a row's mappings and scopes its descendants to this concrete field execution. A
|
|
38
64
|
* descendant's parent is a different object, so row identity alone cannot carry its plan through
|
|
39
|
-
* a relation, connection wrapper, or list. The
|
|
65
|
+
* a relation, connection wrapper, or list. The place keeps list indices to isolate siblings.
|
|
40
66
|
*/
|
|
41
67
|
export declare function setRowMappings(ctx: object, info: GraphQLResolveInfo, mappings: Mappings): void;
|
|
42
68
|
/**
|
|
43
|
-
* Records
|
|
44
|
-
*
|
|
45
|
-
* themselves up. `row` is the value the field is about to resolve with: the parent row when it
|
|
46
|
-
* was loaded by the planned query, and the reloaded row when the fallback loader fetched it.
|
|
47
|
-
*/
|
|
48
|
-
export declare function setFieldMapping(ctx: object, info: GraphQLResolveInfo, mapping: Mapping, row: unknown): void;
|
|
49
|
-
/**
|
|
50
|
-
* `setFieldMapping` for a plan that loaded `row` alone: the field's own mapping is recorded
|
|
51
|
-
* against `row` rather than claimed for the whole field, so a sibling row the plan never loaded
|
|
52
|
-
* keeps falling back instead of reading the entry and resolving against data it does not carry.
|
|
69
|
+
* Records a mapping for `row` only, for the field `info` resolves. Use it when the plan loaded
|
|
70
|
+
* `row` alone. The field's other rows don't use this mapping.
|
|
53
71
|
*
|
|
54
72
|
* Descendants inherit the mapping through this field's execution scope, even when their parent
|
|
55
73
|
* is a child object or a connection wrapper rather than the row that was reloaded.
|
|
56
74
|
*/
|
|
57
75
|
export declare function setRowFieldMapping(ctx: object, info: GraphQLResolveInfo, mapping: Mapping, row: unknown): void;
|
|
58
76
|
/**
|
|
59
|
-
* The mapping recorded for the field
|
|
60
|
-
* over the plan's. `row` is the value whose data the mapping describes — the resolver's
|
|
77
|
+
* The mapping recorded for the field `info` resolves on `row`, preferring one recorded for that
|
|
78
|
+
* row over the plan's. `row` is the value whose data the mapping describes — the resolver's
|
|
79
|
+
* parent. The plan's mapping comes from the nearest field execution above this one that recorded
|
|
80
|
+
* mappings. Returns `null` if there is none or it has no mapping for this field, even if a mapping
|
|
81
|
+
* was recorded for another row at the same path.
|
|
61
82
|
*/
|
|
62
|
-
export declare function getLoaderMapping(ctx: object,
|
|
83
|
+
export declare function getLoaderMapping(ctx: object, info: GraphQLResolveInfo, type: string, row?: unknown): Mapping | null;
|
|
63
84
|
//# sourceMappingURL=loader-map.d.ts.map
|
package/esm/loader-map.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader-map.d.ts","sourceRoot":"","sources":["../src/loader-map.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C;;;;;GAKG;AACH,MAAM,WAAW,OAAO;IACtB,MAAM,EAAE,QAAQ,CAAC;IACjB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AA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