@pothos/selection-mapper 0.2.0 → 0.3.1

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,17 @@
1
1
  # @pothos/selection-mapper
2
2
 
3
+ ## 0.3.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 3f99569: Fix relations being reloaded for every row under graphql-yoga with graphql 17 (`@graphql-tools/executor` 2). Loader mappings were keyed on `info.getAbortSignal`, which that executor builds anew for every resolver, so no resolver found the mapping its parent recorded. Executions are now told apart by the root link of their path under every executor that shares path links, and by their `variableValues` under graphql-jit. This affects plugin-prisma, plugin-drizzle and plugin-prisma-next.
8
+
9
+ ## 0.3.0
10
+
11
+ ### Minor Changes
12
+
13
+ - b9fd6f2: Remove the `setFieldMapping` export, which no Pothos plugin uses any more.
14
+
3
15
  ## 0.2.0
4
16
 
5
17
  ### Minor Changes
package/README.md CHANGED
@@ -11,10 +11,9 @@ their own. Use the plugins.
11
11
 
12
12
  The surface is what those plugins import and nothing more: `Plan` (with the statics `Plan.fromInfo`
13
13
  and `Plan.forParentRow`), `Adapter` and `NodeAdapter`, the loader-map helpers (`cacheKey`,
14
- `forOperation`, `getLoaderMapping`, `setFieldMapping`, `setLoaderMappings`, `setRowFieldMapping`,
15
- `setRowMappings`), `mappingParentTypes`, `selectedFieldNames` and `deepEqual`. Turning a plan
16
- into the query a resolver is handed is each plugin's own job — prisma's `queryFromInfo` and
17
- drizzle's differ — so neither of them is here.
14
+ `forOperation`, `getLoaderMapping`, `setLoaderMappings`, `setRowFieldMapping`, `setRowMappings`),
15
+ `mappingParentTypes`, `selectedFieldNames` and `deepEqual`. Each plugin builds the query it passes
16
+ to a resolver itself. Prisma's `queryFromInfo` and drizzle's differ, so neither is here.
18
17
 
19
18
  ## Vocabulary
20
19
 
@@ -85,10 +84,12 @@ extends `Adapter` directly.
85
84
  this package and could only be copied by round-tripping it through the adapter on every field.
86
85
  - Every play records its loader mappings on the request context, which pothos requires to be an
87
86
  object, per execution: operations and subscription events sharing a context don't see each
88
- other's. An execution is told apart by the `getAbortSignal` graphql-js 17 passes, or by the
89
- root link of its path under graphql-js 16 and `@graphql-tools/executor` (Yoga). There each root
90
- field has a path chain, and so a cache, of its own, which is enough because a mapping is only
91
- read beneath the root field that recorded it. Under graphql-jit, which builds a new path for
87
+ other's. An execution is told apart by the root link of its path under graphql-js and
88
+ `@graphql-tools/executor` (Yoga), which build a path chain for each execution and subscription
89
+ event. There each root field has a path chain, and so a cache, of its own, which is enough
90
+ because a mapping is only read beneath the root field that recorded it. `getAbortSignal` can't
91
+ tell executions apart: `@graphql-tools/executor` 2 builds a new one for every resolver, and the
92
+ signal it returns is the caller's, shared by every event of a subscription. Under graphql-jit, which builds a new path for
92
93
  every resolver, it is told apart by its `variableValues`, coerced afresh for each execution and
93
94
  event. The plugins pass `getLoaderMapping` the resolver's `info`. An adapter whose resolvers
94
95
  read a loaded row another way simply never looks them up.
package/dts/index.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  */
6
6
  export { Adapter } from './adapter.js';
7
7
  export { deepEqual } from './deep-equal.js';
8
- export { cacheKey, fieldKey, forExecution, forOperation, getLoaderMapping, type Mapping, type Mappings, setFieldMapping, setLoaderMappings, setRowFieldMapping, setRowMappings, } from './loader-map.js';
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
11
  export { mappingParentTypes } from './parent-types.js';
@@ -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,SAA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,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"}
@@ -30,31 +30,31 @@ export declare function unionMappings(into: Mapping | undefined, from: Mapping):
30
30
  /**
31
31
  * The entries of `cache` for the operation `info` is in. Keyed on its `variableValues`, which
32
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 them, so a plan cached here runs its `select`
34
- * and `query` callbacks once for all of them; use `forExecution` where they read per-event state.
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.
35
36
  */
36
37
  export declare function forOperation<T>(cache: WeakMap<object, Map<string, T>>, info: GraphQLResolveInfo): Map<string, T>;
37
38
  /**
38
- * The entries of `cache` for the execution `info` is in, by `executionOf`, as mappings are kept:
39
- * each event of a subscription gets its own, and @defer and @stream payloads share their
40
- * execution's.
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
41
  */
42
42
  export declare function forExecution<T>(cache: WeakMap<object, Map<string, T>>, info: GraphQLResolveInfo): Map<string, T>;
43
43
  /** The string keys of a response path joined by `.`; list indices are dropped. */
44
44
  export declare function responsePath(path: GraphQLResolveInfo['path'] | undefined): string;
45
45
  export declare function cacheKey(type: string, path: GraphQLResolveInfo['path']): string;
46
46
  /**
47
- * `cacheKey(type, info.path)` and the identity of every node in `info.fieldNodes`. The path keeps
48
- * each place in the response apart, list indices aside, so the root fields of a mutation, which run
49
- * in turn and whose callbacks may read what an earlier one changed, never share a plan. The nodes
50
- * decide what a plan loads: fragments on different types can merge different nodes into one
51
- * response path, so a plan keyed on the path alone would be reused for a field asking for
52
- * something else.
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
53
  */
54
54
  export declare function fieldKey(type: string, info: GraphQLResolveInfo): string;
55
55
  /**
56
56
  * Records the mappings of a plan rooted at the field `info` resolves, under that field's path.
57
- * The plan loaded the whole field, so its mappings answer for everything resolved beneath this
57
+ * The plan loaded the whole field, so its mappings are used for everything resolved beneath this
58
58
  * execution of it. Multiple plans can contribute to one field (Relay nodes of different model
59
59
  * types share the list's path), so later contributions replace matching keys and retain others.
60
60
  */
@@ -66,16 +66,8 @@ export declare function setLoaderMappings(ctx: object, info: GraphQLResolveInfo,
66
66
  */
67
67
  export declare function setRowMappings(ctx: object, info: GraphQLResolveInfo, mappings: Mappings): void;
68
68
  /**
69
- * Records the mapping of the field `info` resolves (under its own parent type) along with the
70
- * mappings beneath it, so both the field's resolver and the resolvers below it can look
71
- * themselves up. `row` is the value the field is about to resolve with: the parent row when it
72
- * was loaded by the planned query, and the reloaded row when the fallback loader fetched it.
73
- */
74
- export declare function setFieldMapping(ctx: object, info: GraphQLResolveInfo, mapping: Mapping, row: unknown): void;
75
- /**
76
- * `setFieldMapping` for a plan that loaded `row` alone: the field's own mapping is recorded
77
- * against `row` rather than claimed for the whole field, so the field's lookup on `row` answers
78
- * from it whatever the field's other rows were loaded with.
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.
79
71
  *
80
72
  * Descendants inherit the mapping through this field's execution scope, even when their parent
81
73
  * is a child object or a connection wrapper rather than the row that was reloaded.
@@ -84,8 +76,9 @@ export declare function setRowFieldMapping(ctx: object, info: GraphQLResolveInfo
84
76
  /**
85
77
  * The mapping recorded for the field `info` resolves on `row`, preferring one recorded for that
86
78
  * row over the plan's. `row` is the value whose data the mapping describes — the resolver's
87
- * parent. The plan's comes from the nearest field execution above that recorded one: with none
88
- * above, no plan loaded `row`, whatever was recorded for another row at the same path.
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.
89
82
  */
90
83
  export declare function getLoaderMapping(ctx: object, info: GraphQLResolveInfo, type: string, row?: unknown): Mapping | null;
91
84
  //# sourceMappingURL=loader-map.d.ts.map
@@ -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;AAED;;;;GAIG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE/C,mFAAmF;AACnF,eAAO,MAAM,aAAa,EAAE,OAAkE,CAAC;AAK/F;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,SAAS,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAiC/E;AA8GD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAC5B,KAAK,EAAE,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EACtC,IAAI,EAAE,kBAAkB,GACvB,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAEhB;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAC5B,KAAK,EAAE,OAA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yBD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,kBAAkB,EAAE,QAAQ,EAAE,QAAQ,QAK1F;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,kBAAkB,EAAE,QAAQ,EAAE,QAAQ,QAIvF;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,kBAAkB,EACxB,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,OAAO,QAWb;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,kBAAkB,EACxB,IAAI,EAAE,MAAM,EACZ,GAAG,CAAC,EAAE,OAAO,GACZ,OAAO,GAAG,IAAI,CA+BhB"}
package/esm/index.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  */
6
6
  export { Adapter } from './adapter.js';
7
7
  export { deepEqual } from './deep-equal.js';
8
- export { cacheKey, fieldKey, forExecution, forOperation, getLoaderMapping, type Mapping, type Mappings, setFieldMapping, setLoaderMappings, setRowFieldMapping, setRowMappings, } from './loader-map.js';
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
11
  export { mappingParentTypes } from './parent-types.js';
@@ -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,EAC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,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,7 +4,7 @@
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, fieldKey, forExecution, forOperation, getLoaderMapping, setFieldMapping, setLoaderMappings, setRowFieldMapping, setRowMappings } from './loader-map.js';
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
10
  export { mappingParentTypes } from './parent-types.js';
package/esm/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":["Adapter","deepEqual","cacheKey","fieldKey","forExecution","forOperation","getLoaderMapping","setFieldMapping","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,eAAe,EACfC,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"}
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"}
@@ -30,31 +30,31 @@ export declare function unionMappings(into: Mapping | undefined, from: Mapping):
30
30
  /**
31
31
  * The entries of `cache` for the operation `info` is in. Keyed on its `variableValues`, which
32
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 them, so a plan cached here runs its `select`
34
- * and `query` callbacks once for all of them; use `forExecution` where they read per-event state.
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.
35
36
  */
36
37
  export declare function forOperation<T>(cache: WeakMap<object, Map<string, T>>, info: GraphQLResolveInfo): Map<string, T>;
37
38
  /**
38
- * The entries of `cache` for the execution `info` is in, by `executionOf`, as mappings are kept:
39
- * each event of a subscription gets its own, and @defer and @stream payloads share their
40
- * execution's.
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
41
  */
42
42
  export declare function forExecution<T>(cache: WeakMap<object, Map<string, T>>, info: GraphQLResolveInfo): Map<string, T>;
43
43
  /** The string keys of a response path joined by `.`; list indices are dropped. */
44
44
  export declare function responsePath(path: GraphQLResolveInfo['path'] | undefined): string;
45
45
  export declare function cacheKey(type: string, path: GraphQLResolveInfo['path']): string;
46
46
  /**
47
- * `cacheKey(type, info.path)` and the identity of every node in `info.fieldNodes`. The path keeps
48
- * each place in the response apart, list indices aside, so the root fields of a mutation, which run
49
- * in turn and whose callbacks may read what an earlier one changed, never share a plan. The nodes
50
- * decide what a plan loads: fragments on different types can merge different nodes into one
51
- * response path, so a plan keyed on the path alone would be reused for a field asking for
52
- * something else.
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
53
  */
54
54
  export declare function fieldKey(type: string, info: GraphQLResolveInfo): string;
55
55
  /**
56
56
  * Records the mappings of a plan rooted at the field `info` resolves, under that field's path.
57
- * The plan loaded the whole field, so its mappings answer for everything resolved beneath this
57
+ * The plan loaded the whole field, so its mappings are used for everything resolved beneath this
58
58
  * execution of it. Multiple plans can contribute to one field (Relay nodes of different model
59
59
  * types share the list's path), so later contributions replace matching keys and retain others.
60
60
  */
@@ -66,16 +66,8 @@ export declare function setLoaderMappings(ctx: object, info: GraphQLResolveInfo,
66
66
  */
67
67
  export declare function setRowMappings(ctx: object, info: GraphQLResolveInfo, mappings: Mappings): void;
68
68
  /**
69
- * Records the mapping of the field `info` resolves (under its own parent type) along with the
70
- * mappings beneath it, so both the field's resolver and the resolvers below it can look
71
- * themselves up. `row` is the value the field is about to resolve with: the parent row when it
72
- * was loaded by the planned query, and the reloaded row when the fallback loader fetched it.
73
- */
74
- export declare function setFieldMapping(ctx: object, info: GraphQLResolveInfo, mapping: Mapping, row: unknown): void;
75
- /**
76
- * `setFieldMapping` for a plan that loaded `row` alone: the field's own mapping is recorded
77
- * against `row` rather than claimed for the whole field, so the field's lookup on `row` answers
78
- * from it whatever the field's other rows were loaded with.
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.
79
71
  *
80
72
  * Descendants inherit the mapping through this field's execution scope, even when their parent
81
73
  * is a child object or a connection wrapper rather than the row that was reloaded.
@@ -84,8 +76,9 @@ export declare function setRowFieldMapping(ctx: object, info: GraphQLResolveInfo
84
76
  /**
85
77
  * The mapping recorded for the field `info` resolves on `row`, preferring one recorded for that
86
78
  * row over the plan's. `row` is the value whose data the mapping describes — the resolver's
87
- * parent. The plan's comes from the nearest field execution above that recorded one: with none
88
- * above, no plan loaded `row`, whatever was recorded for another row at the same path.
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.
89
82
  */
90
83
  export declare function getLoaderMapping(ctx: object, info: GraphQLResolveInfo, type: string, row?: unknown): Mapping | null;
91
84
  //# sourceMappingURL=loader-map.d.ts.map
@@ -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;AAED;;;;GAIG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE/C,mFAAmF;AACnF,eAAO,MAAM,aAAa,EAAE,OAAkE,CAAC;AAK/F;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,SAAS,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAiC/E;AA8GD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAC5B,KAAK,EAAE,OAAO,CAAC,MAAM,EAAE,GAAG,CAA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I,EAAE,MAAM,EAAE,IAAI,EAAE,kBAAkB,CAAC,MAAM,CAAC,UAEtE;AAMD;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,kBAAkB,GAAG,MAAM,CAevE;AAyBD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,kBAAkB,EAAE,QAAQ,EAAE,QAAQ,QAK1F;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,kBAAkB,EAAE,QAAQ,EAAE,QAAQ,QAIvF;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,kBAAkB,EACxB,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,OAAO,QAWb;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,kBAAkB,EACxB,IAAI,EAAE,MAAM,EACZ,GAAG,CAAC,EAAE,OAAO,GACZ,OAAO,GAAG,IAAI,CA+BhB"}
package/esm/loader-map.js CHANGED
@@ -46,19 +46,17 @@ import { createContextCache } from '@pothos/core';
46
46
  * An object the executor builds once per execution, and once per event of a subscription, and
47
47
  * hands to every resolver in it, @defer and @stream payloads included:
48
48
  *
49
- * - graphql-js 17: the `getAbortSignal` of the execution.
50
- * - graphql-js 16 and @graphql-tools/executor (Yoga): the root link of the path. They build one
49
+ * - graphql-js 16 and 17, @graphql-tools/executor (Yoga): the root link of the path. They build one
51
50
  * path chain per execution or event, linking each field to its parent's, so every resolver
52
51
  * beneath a root field shares its link, and the `subscribe` resolver has its own. Their fields'
53
52
  * links carry a `typename`. A root field doesn't share its link with the others, so each root
54
53
  * field has a cache of its own, which is all it reads.
55
54
  * - graphql-jit: the coerced `variableValues`. It builds a new path, without `typename`, for every
56
55
  * resolver, but coerces the variables afresh for every execution and event.
56
+ *
57
+ * Not `info.getAbortSignal`: @graphql-tools/executor 2 builds a new getter for every resolver, and
58
+ * the signal it returns is the caller's, absent or shared by every event of a subscription.
57
59
  */ function executionOf(info) {
58
- const signal = info.getAbortSignal;
59
- if (signal) {
60
- return signal;
61
- }
62
60
  let { path } = info;
63
61
  if (path.typename === undefined) {
64
62
  return info.variableValues;
@@ -74,9 +72,7 @@ function cache(ctx, info) {
74
72
  let cached = executions.get(execution);
75
73
  if (!cached) {
76
74
  cached = {
77
- mappings: new Map(),
78
75
  places: new Map(),
79
- rehomed: new Map(),
80
76
  rows: new WeakMap(),
81
77
  rowScoped: false,
82
78
  scopes: new WeakMap()
@@ -105,15 +101,15 @@ function cache(ctx, info) {
105
101
  /**
106
102
  * The entries of `cache` for the operation `info` is in. Keyed on its `variableValues`, which
107
103
  * every executor coerces afresh for each operation, so operations sharing a context never share
108
- * an entry. The events of a subscription may share them, so a plan cached here runs its `select`
109
- * and `query` callbacks once for all of them; use `forExecution` where they read per-event state.
104
+ * an entry. The events of a subscription may share one, so a plan cached here runs its `select`
105
+ * and `query` callbacks once for all of them. Use `forExecution` if the callbacks read per-event
106
+ * state.
110
107
  */ export function forOperation(cache, info) {
111
108
  return entriesFor(cache, info.variableValues);
112
109
  }
113
110
  /**
114
- * The entries of `cache` for the execution `info` is in, by `executionOf`, as mappings are kept:
115
- * each event of a subscription gets its own, and @defer and @stream payloads share their
116
- * execution's.
111
+ * The entries of `cache` for the execution `info` is in. Each event of a subscription gets its own
112
+ * entries, and `@defer` and `@stream` payloads share the entries of their execution.
117
113
  */ export function forExecution(cache, info) {
118
114
  return entriesFor(cache, executionOf(info));
119
115
  }
@@ -161,12 +157,12 @@ export function cacheKey(type, path) {
161
157
  /** A number for each field node seen, by identity. Weak, so the nodes go with their document. */ const fieldNodeIds = new WeakMap();
162
158
  let nextFieldNodeId = 0;
163
159
  /**
164
- * `cacheKey(type, info.path)` and the identity of every node in `info.fieldNodes`. The path keeps
165
- * each place in the response apart, list indices aside, so the root fields of a mutation, which run
166
- * in turn and whose callbacks may read what an earlier one changed, never share a plan. The nodes
167
- * decide what a plan loads: fragments on different types can merge different nodes into one
168
- * response path, so a plan keyed on the path alone would be reused for a field asking for
169
- * something else.
160
+ * The key to cache a field's plan under: `cacheKey(type, info.path)` plus an id for each node in
161
+ * `info.fieldNodes`. The path leaves out list indices, so the items of a list share a plan. The
162
+ * root fields of a mutation run in turn, and a callback may read what an earlier field changed.
163
+ * Their paths differ, so each gets its own plan. The nodes are part of the key because fragments on
164
+ * different types can merge different nodes into one response path, and a plan keyed on the path
165
+ * alone would be reused for a field that selects something else.
170
166
  */ export function fieldKey(type, info) {
171
167
  let key = cacheKey(type, info.path);
172
168
  for (const node of info.fieldNodes){
@@ -179,42 +175,9 @@ let nextFieldNodeId = 0;
179
175
  }
180
176
  return key;
181
177
  }
182
- /**
183
- * The keys `mappings` is recorded under when it is rehomed beneath `prefix`. Built once per
184
- * prefix: the strings depend on the path and the plan's own keys, never on which row is being
185
- * recorded for.
186
- */ function rehomedKeys(cached, prefix) {
187
- let keys = cached.rehomed.get(prefix);
188
- if (!keys) {
189
- keys = new Map();
190
- cached.rehomed.set(prefix, keys);
191
- }
192
- return keys;
193
- }
194
- /** `key`, a plan's own `Type@relative.path`, moved beneath `prefix`. Built once per prefix. */ function rehome(keys, key, prefix) {
195
- let under = keys.get(key);
196
- if (under === undefined) {
197
- const at = key.indexOf('@');
198
- under = `${key.slice(0, at)}@${prefix}.${key.slice(at + 1)}`;
199
- keys.set(key, under);
200
- }
201
- return under;
202
- }
203
178
  /** `row` if a mapping can be hung off it. A root field resolves with no parent value at all. */ function ownerOf(row) {
204
179
  return typeof row === 'object' && row !== null ? row : null;
205
180
  }
206
- /**
207
- * Records `mapping` at `key` for `row`. An unclaimed key takes it, and a key already holding this
208
- * very mapping needs no write, so the rows after the first write nothing. Only a key two plans
209
- * disagree about gives the row a mapping of its own — or, with no row to hang it off, nothing.
210
- */ function claim(cached, key, mapping, row, place) {
211
- const held = cached.mappings.get(key);
212
- if (held === undefined) {
213
- cached.mappings.set(key, mapping);
214
- } else if (held !== mapping && row) {
215
- claimForRow(cached, key.slice(0, key.indexOf('@')), mapping, row, place);
216
- }
217
- }
218
181
  /**
219
182
  * Records `mapping` for this field execution against `row` alone.
220
183
  */ function claimForRow(cached, type, mapping, row, place) {
@@ -233,22 +196,17 @@ let nextFieldNodeId = 0;
233
196
  }
234
197
  /**
235
198
  * Records the mappings of a plan rooted at the field `info` resolves, under that field's path.
236
- * The plan loaded the whole field, so its mappings answer for everything resolved beneath this
199
+ * The plan loaded the whole field, so its mappings are used for everything resolved beneath this
237
200
  * execution of it. Multiple plans can contribute to one field (Relay nodes of different model
238
201
  * types share the list's path), so later contributions replace matching keys and retain others.
239
202
  */ export function setLoaderMappings(ctx, info, mappings) {
240
203
  const cached = cache(ctx, info);
241
- const prefix = responsePath(info.path);
242
- const keys = rehomedKeys(cached, prefix);
243
204
  const place = placeOf(cached, info, info.path);
244
205
  const previous = cached.scopes.get(place);
245
206
  cached.scopes.set(place, previous ? {
246
207
  ...previous,
247
208
  ...mappings
248
209
  } : mappings);
249
- for (const key of Object.keys(mappings)){
250
- cached.mappings.set(rehome(keys, key, prefix), mappings[key]);
251
- }
252
210
  }
253
211
  /**
254
212
  * Records a row's mappings and scopes its descendants to this concrete field execution. A
@@ -259,20 +217,8 @@ let nextFieldNodeId = 0;
259
217
  cached.scopes.set(placeOf(cached, info, info.path), mappings);
260
218
  }
261
219
  /**
262
- * Records the mapping of the field `info` resolves (under its own parent type) along with the
263
- * mappings beneath it, so both the field's resolver and the resolvers below it can look
264
- * themselves up. `row` is the value the field is about to resolve with: the parent row when it
265
- * was loaded by the planned query, and the reloaded row when the fallback loader fetched it.
266
- */ export function setFieldMapping(ctx, info, mapping, row) {
267
- const cached = cache(ctx, info);
268
- const place = placeOf(cached, info, info.path);
269
- claim(cached, cacheKey(info.parentType.name, info.path), mapping, ownerOf(row), place);
270
- cached.scopes.set(place, mapping.nested);
271
- }
272
- /**
273
- * `setFieldMapping` for a plan that loaded `row` alone: the field's own mapping is recorded
274
- * against `row` rather than claimed for the whole field, so the field's lookup on `row` answers
275
- * from it whatever the field's other rows were loaded with.
220
+ * Records a mapping for `row` only, for the field `info` resolves. Use it when the plan loaded
221
+ * `row` alone. The field's other rows don't use this mapping.
276
222
  *
277
223
  * Descendants inherit the mapping through this field's execution scope, even when their parent
278
224
  * is a child object or a connection wrapper rather than the row that was reloaded.
@@ -288,8 +234,9 @@ let nextFieldNodeId = 0;
288
234
  /**
289
235
  * The mapping recorded for the field `info` resolves on `row`, preferring one recorded for that
290
236
  * row over the plan's. `row` is the value whose data the mapping describes — the resolver's
291
- * parent. The plan's comes from the nearest field execution above that recorded one: with none
292
- * above, no plan loaded `row`, whatever was recorded for another row at the same path.
237
+ * parent. The plan's mapping comes from the nearest field execution above this one that recorded
238
+ * mappings. Returns `null` if there is none or it has no mapping for this field, even if a mapping
239
+ * was recorded for another row at the same path.
293
240
  */ export function getLoaderMapping(ctx, info, type, row) {
294
241
  const { path } = info;
295
242
  const cached = cache(ctx, info);
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/loader-map.ts"],"names":["createContextCache","EMPTY_MAPPING","Object","freeze","nested","unions","WeakMap","unionMappings","into","from","byFrom","get","set","known","key","keys","union","position","undefined","contextCaches","executionOf","info","signal","getAbortSignal","path","typename","variableValues","prev","cache","ctx","executions","execution","cached","mappings","Map","places","rehomed","rows","rowScoped","scopes","placeOf","at","executionPath","place","forOperation","entriesFor","forExecution","entries","pathKeys","responsePath","prefix","executionPaths","String","cacheKey","type","fieldNodeIds","nextFieldNodeId","fieldKey","node","fieldNodes","id","rehomedKeys","rehome","under","indexOf","slice","ownerOf","row","claim","mapping","held","claimForRow","byPlace","own","setLoaderMappings","previous","setRowMappings","setFieldMapping","parentType","name","setRowFieldMapping","owner","getLoaderMapping","ancestor","scope","length"],"mappings":"AAAA,SAASA,kBAAkB,QAAQ,eAAe;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C,OAAO;YACT,wFAAwF;YACxF,0CAA0C;YAC1C,OACEA,KAAK,CAAC,GAAG9B,KAAK,CAAC,EAAEL,aAAazB,MAAMyC,KAAK,CAAChB,aAAakC,UAAUE,MAAM,GAAG,IAAI,CAAC,IAAI;QAEvF;IACF;IAEA,OAAO;AACT"}
1
+ {"version":3,"sources":["../src/loader-map.ts"],"names":["createContextCache","EMPTY_MAPPING","Object","freeze","nested","unions","WeakMap","unionMappings","into","from","byFrom","get","set","known","key","keys","union","position","undefined","contextCaches","executionOf","info","path","typename","variableValues","prev","cache","ctx","executions","execution","cached","places","Map","rows","rowScoped","scopes","placeOf","at","executionPath","place","forOperation","entriesFor","forExecution","entries","pathKeys","responsePath","prefix","executionPaths","String","cacheKey","type","fieldNodeIds","nextFieldNodeId","fieldKey","node","fieldNodes","id","ownerOf","row","claimForRow","mapping","byPlace","own","setLoaderMappings","mappings","previous","setRowMappings","setRowFieldMapping","owner","parentType","name","getLoaderMapping","ancestor","scope","slice","length"],"mappings":"AAAA,SAASA,kBAAkB,QAAQ,eAAe;AAsBlD,iFAAiF,GACjF,OAAO,MAAMC,gBAAyBC,OAAOC,MAAM,CAAC;IAAEC,QAAQF,OAAOC,MAAM,CAAC,CAAC;AAAe,GAAG;AAE/F,6FAA6F,GAC7F,MAAME,SAAS,IAAIC;AAEnB;;;;;;;CAOC,GACD,OAAO,SAASC,cAAcC,IAAyB,EAAEC,IAAa;IACpE,IAAI,CAACD,QAAQA,SAASP,eAAe;QACnC,OAAOQ;IACT;IAEA,IAAID,SAASC,QAAQA,SAASR,eAAe;QAC3C,OAAOO;IACT;IAEA,IAAIE,SAASL,OAAOM,GAAG,CAACH;IAExB,IAAI,CAACE,QAAQ;QACXA,SAAS,IAAIJ;QACbD,OAAOO,GAAG,CAACJ,MAAME;IACnB;IAEA,MAAMG,QAAQH,OAAOC,GAAG,CAACF;IAEzB,IAAII,OAAO;QACT,OAAOA;IACT;IAEA,MAAMT,SAAmB;QAAE,GAAGI,KAAK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AEA,IAAK,IAAIU,WAAWlD,KAAKG,IAAI,EAAE+C,UAAUA,WAAWA,SAAS/C,IAAI,CAAE;QACjE,MAAMgD,QAAQ3C,OAAOK,MAAM,CAACxB,GAAG,CAACyB,QAAQN,QAAQT,MAAMmD;QAEtD,IAAIC,OAAO;YACT,wFAAwF;YACxF,0CAA0C;YAC1C,OACEA,KAAK,CAAC,GAAGvB,KAAK,CAAC,EAAEL,aAAavB,MAAMoD,KAAK,CAAC7B,aAAa2B,UAAUG,MAAM,GAAG,IAAI,CAAC,IAAI;QAEvF;IACF;IAEA,OAAO;AACT"}
package/lib/index.js CHANGED
@@ -46,9 +46,6 @@ _export(exports, {
46
46
  get selectedFieldNames () {
47
47
  return _matches.selectedFieldNames;
48
48
  },
49
- get setFieldMapping () {
50
- return _loadermap.setFieldMapping;
51
- },
52
49
  get setLoaderMappings () {
53
50
  return _loadermap.setLoaderMappings;
54
51
  },
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":["Adapter","NodeAdapter","Plan","cacheKey","deepEqual","fieldKey","forExecution","forOperation","getLoaderMapping","mappingParentTypes","selectedFieldNames","setFieldMapping","setLoaderMappings","setRowFieldMapping","setRowMappings"],"mappings":"AAAA;;;;CAIC;;;;;;;;;;;QACQA;eAAAA,gBAAO;;QAqBIC;eAAAA,iBAAW;;QAEtBC;eAAAA,UAAI;;QApBXC;eAAAA,mBAAQ;;QAFDC;eAAAA,oBAAS;;QAGhBC;eAAAA,mBAAQ;;QACRC;eAAAA,uBAAY;;QACZC;eAAAA,uBAAY;;QACZC;eAAAA,2BAAgB;;QAeTC;eAAAA,+BAAkB;;QAHzBC;eAAAA,2BAAkB;;QATlBC;eAAAA,0BAAe;;QACfC;eAAAA,4BAAiB;;QACjBC;eAAAA,6BAAkB;;QAClBC;eAAAA,yBAAc;;;yBAbQ;2BACE;2BAanB;yBAMA;sBACmD;6BACvB;sBACG"}
1
+ {"version":3,"sources":["../src/index.ts"],"names":["Adapter","NodeAdapter","Plan","cacheKey","deepEqual","fieldKey","forExecution","forOperation","getLoaderMapping","mappingParentTypes","selectedFieldNames","setLoaderMappings","setRowFieldMapping","setRowMappings"],"mappings":"AAAA;;;;CAIC;;;;;;;;;;;QACQA;eAAAA,gBAAO;;QAoBIC;eAAAA,iBAAW;;QAEtBC;eAAAA,UAAI;;QAnBXC;eAAAA,mBAAQ;;QAFDC;eAAAA,oBAAS;;QAGhBC;eAAAA,mBAAQ;;QACRC;eAAAA,uBAAY;;QACZC;eAAAA,uBAAY;;QACZC;eAAAA,2BAAgB;;QAcTC;eAAAA,+BAAkB;;QAHzBC;eAAAA,2BAAkB;;QARlBC;eAAAA,4BAAiB;;QACjBC;eAAAA,6BAAkB;;QAClBC;eAAAA,yBAAc;;;yBAZQ;2BACE;2BAYnB;yBAMA;sBACmD;6BACvB;sBACG"}
package/lib/loader-map.js CHANGED
@@ -30,9 +30,6 @@ _export(exports, {
30
30
  get responsePath () {
31
31
  return responsePath;
32
32
  },
33
- get setFieldMapping () {
34
- return setFieldMapping;
35
- },
36
33
  get setLoaderMappings () {
37
34
  return setLoaderMappings;
38
35
  },
@@ -87,19 +84,17 @@ function unionMappings(into, from) {
87
84
  * An object the executor builds once per execution, and once per event of a subscription, and
88
85
  * hands to every resolver in it, @defer and @stream payloads included:
89
86
  *
90
- * - graphql-js 17: the `getAbortSignal` of the execution.
91
- * - graphql-js 16 and @graphql-tools/executor (Yoga): the root link of the path. They build one
87
+ * - graphql-js 16 and 17, @graphql-tools/executor (Yoga): the root link of the path. They build one
92
88
  * path chain per execution or event, linking each field to its parent's, so every resolver
93
89
  * beneath a root field shares its link, and the `subscribe` resolver has its own. Their fields'
94
90
  * links carry a `typename`. A root field doesn't share its link with the others, so each root
95
91
  * field has a cache of its own, which is all it reads.
96
92
  * - graphql-jit: the coerced `variableValues`. It builds a new path, without `typename`, for every
97
93
  * resolver, but coerces the variables afresh for every execution and event.
94
+ *
95
+ * Not `info.getAbortSignal`: @graphql-tools/executor 2 builds a new getter for every resolver, and
96
+ * the signal it returns is the caller's, absent or shared by every event of a subscription.
98
97
  */ function executionOf(info) {
99
- const signal = info.getAbortSignal;
100
- if (signal) {
101
- return signal;
102
- }
103
98
  let { path } = info;
104
99
  if (path.typename === undefined) {
105
100
  return info.variableValues;
@@ -115,9 +110,7 @@ function cache(ctx, info) {
115
110
  let cached = executions.get(execution);
116
111
  if (!cached) {
117
112
  cached = {
118
- mappings: new Map(),
119
113
  places: new Map(),
120
- rehomed: new Map(),
121
114
  rows: new WeakMap(),
122
115
  rowScoped: false,
123
116
  scopes: new WeakMap()
@@ -204,42 +197,9 @@ function fieldKey(type, info) {
204
197
  }
205
198
  return key;
206
199
  }
207
- /**
208
- * The keys `mappings` is recorded under when it is rehomed beneath `prefix`. Built once per
209
- * prefix: the strings depend on the path and the plan's own keys, never on which row is being
210
- * recorded for.
211
- */ function rehomedKeys(cached, prefix) {
212
- let keys = cached.rehomed.get(prefix);
213
- if (!keys) {
214
- keys = new Map();
215
- cached.rehomed.set(prefix, keys);
216
- }
217
- return keys;
218
- }
219
- /** `key`, a plan's own `Type@relative.path`, moved beneath `prefix`. Built once per prefix. */ function rehome(keys, key, prefix) {
220
- let under = keys.get(key);
221
- if (under === undefined) {
222
- const at = key.indexOf('@');
223
- under = `${key.slice(0, at)}@${prefix}.${key.slice(at + 1)}`;
224
- keys.set(key, under);
225
- }
226
- return under;
227
- }
228
200
  /** `row` if a mapping can be hung off it. A root field resolves with no parent value at all. */ function ownerOf(row) {
229
201
  return typeof row === 'object' && row !== null ? row : null;
230
202
  }
231
- /**
232
- * Records `mapping` at `key` for `row`. An unclaimed key takes it, and a key already holding this
233
- * very mapping needs no write, so the rows after the first write nothing. Only a key two plans
234
- * disagree about gives the row a mapping of its own — or, with no row to hang it off, nothing.
235
- */ function claim(cached, key, mapping, row, place) {
236
- const held = cached.mappings.get(key);
237
- if (held === undefined) {
238
- cached.mappings.set(key, mapping);
239
- } else if (held !== mapping && row) {
240
- claimForRow(cached, key.slice(0, key.indexOf('@')), mapping, row, place);
241
- }
242
- }
243
203
  /**
244
204
  * Records `mapping` for this field execution against `row` alone.
245
205
  */ function claimForRow(cached, type, mapping, row, place) {
@@ -258,28 +218,17 @@ function fieldKey(type, info) {
258
218
  }
259
219
  function setLoaderMappings(ctx, info, mappings) {
260
220
  const cached = cache(ctx, info);
261
- const prefix = responsePath(info.path);
262
- const keys = rehomedKeys(cached, prefix);
263
221
  const place = placeOf(cached, info, info.path);
264
222
  const previous = cached.scopes.get(place);
265
223
  cached.scopes.set(place, previous ? {
266
224
  ...previous,
267
225
  ...mappings
268
226
  } : mappings);
269
- for (const key of Object.keys(mappings)){
270
- cached.mappings.set(rehome(keys, key, prefix), mappings[key]);
271
- }
272
227
  }
273
228
  function setRowMappings(ctx, info, mappings) {
274
229
  const cached = cache(ctx, info);
275
230
  cached.scopes.set(placeOf(cached, info, info.path), mappings);
276
231
  }
277
- function setFieldMapping(ctx, info, mapping, row) {
278
- const cached = cache(ctx, info);
279
- const place = placeOf(cached, info, info.path);
280
- claim(cached, cacheKey(info.parentType.name, info.path), mapping, ownerOf(row), place);
281
- cached.scopes.set(place, mapping.nested);
282
- }
283
232
  function setRowFieldMapping(ctx, info, mapping, row) {
284
233
  const cached = cache(ctx, info);
285
234
  const owner = ownerOf(row);
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/loader-map.ts"],"names":["EMPTY_MAPPING","cacheKey","fieldKey","forExecution","forOperation","getLoaderMapping","responsePath","setFieldMapping","setLoaderMappings","setRowFieldMapping","setRowMappings","unionMappings","Object","freeze","nested","unions","WeakMap","into","from","byFrom","get","set","known","key","keys","union","position","undefined","contextCaches","createContextCache","executionOf","info","signal","getAbortSignal","path","typename","variableValues","prev","cache","ctx","executions","execution","cached","mappings","Map","places","rehomed","rows","rowScoped","scopes","placeOf","at","executionPath","place","entriesFor","entries","pathKeys","prefix","executionPaths","String","type","fieldNodeIds","nextFieldNodeId","node","fieldNodes","id","rehomedKeys","rehome","under","indexOf","slice","ownerOf","row","claim","mapping","held","claimForRow","byPlace","own","previous","parentType","name","owner","ancestor","scope","length"],"mappings":";;;;;;;;;;;QAuBaA;eAAAA;;QA4OGC;eAAAA;;QAgBAC;eAAAA;;QA9EAC;eAAAA;;QAZAC;eAAAA;;QA+PAC;eAAAA;;QAzNAC;eAAAA;;QA6KAC;eAAAA;;QA9BAC;eAAAA;;QAmDAC;eAAAA;;QAjCAC;eAAAA;;QA5VAC;eAAAA;;;sBApCmB;AAuB5B,MAAMX,gBAAyBY,OAAOC,MAAM,CAAC;IAAEC,QAAQF,OAAOC,MAAM,CAAC,CAAC;AAAe;AAE5F,6FAA6F,GAC7F,MAAME,SAAS,IAAIC;AAUZ,SAASL,cAAcM,IAAyB,EAAEC,IAAa;IACpE,IAAI,CAACD,QAAQA,SAASjB,eAAe;QACnC,OAAOkB;IACT;IAEA,IAAID,SAASC,QAAQA,SAASlB,eAAe;QAC3C,OAAOiB;IACT;IAEA,IAAIE,SAASJ,OAAOK,GAAG,CAACH;IAExB,IAAI,CAACE,QAAQ;QACXA,SAAS,IAAIH;QACbD,OAAOM,GAAG,CAACJ,MAAME;IACnB;IAEA,MAAMG,QAAQH,OAAOC,GAAG,CAACF;IAEzB,IAAII,OAAO;QACT,OAAOA;IACT;IAEA,MAAMR,SAAmB;QAAE,GAAGG,KAAKH,MAAM;IAAC;IAE1C,KAAK,MAAMS,OAAOX,OAAOY,IAAI,CAACN,KAAKJ,MAAM,EAAG;QAC1CA,MAAM,CAACS,IAAI,GAAGZ,cAAcG,MAAM,CAACS,IAAI,EAAEL,KAAKJ,MAAM,CAACS,IAAI;IAC3D;IAEA,MAAME,QAAQR,KAAKS,QAAQ,KAAKC,YAAY;QAAEb;IAAO,IAAI;QAAEA;QAAQY,UAAUT,KAAKS,QAAQ;IAAC;IAE3FP,OAAOE,GAAG,CAACH,MAAMO;IAEjB,OAAOA;AACT;AAgCA,gEAAgE,GAChE,MAAMG,gBAAgBC,IAAAA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E,MAAM+C,QAAQ1C,OAAOO,MAAM,CAAC7B,GAAG,CAAC8B,QAAQR,QAAQX,MAAMoD;QAEtD,IAAIC,OAAO;YACT,wFAAwF;YACxF,0CAA0C;YAC1C,OACEA,KAAK,CAAC,GAAGxB,KAAK,CAAC,EAAEtD,aAAa4B,MAAMoC,KAAK,CAAChE,aAAa6E,UAAUE,MAAM,GAAG,IAAI,CAAC,IAAI;QAEvF;IACF;IAEA,OAAO;AACT"}
1
+ {"version":3,"sources":["../src/loader-map.ts"],"names":["EMPTY_MAPPING","cacheKey","fieldKey","forExecution","forOperation","getLoaderMapping","responsePath","setLoaderMappings","setRowFieldMapping","setRowMappings","unionMappings","Object","freeze","nested","unions","WeakMap","into","from","byFrom","get","set","known","key","keys","union","position","undefined","contextCaches","createContextCache","executionOf","info","path","typename","variableValues","prev","cache","ctx","executions","execution","cached","places","Map","rows","rowScoped","scopes","placeOf","at","executionPath","place","entriesFor","entries","pathKeys","prefix","executionPaths","String","type","fieldNodeIds","nextFieldNodeId","node","fieldNodes","id","ownerOf","row","claimForRow","mapping","byPlace","own","mappings","previous","owner","parentType","name","ancestor","scope","slice","length"],"mappings":";;;;;;;;;;;QAuBaA;eAAAA;;QA8NGC;eAAAA;;QAgBAC;eAAAA;;QA9EAC;eAAAA;;QAXAC;eAAAA;;QAwLAC;eAAAA;;QAnJAC;eAAAA;;QAkGAC;eAAAA;;QAyBAC;eAAAA;;QAbAC;eAAAA;;QA3RAC;eAAAA;;;sBApCmB;AAuB5B,MAAMV,gBAAyBW,OAAOC,MAAM,CAAC;IAAEC,QAAQF,OAAOC,MAAM,CAAC,CAAC;AAAe;AAE5F,6FAA6F,GAC7F,MAAME,SAAS,IAAIC;AAUZ,SAASL,cAAcM,IAAyB,EAAEC,IAAa;IACpE,IAAI,CAACD,QAAQA,SAAShB,eAAe;QACnC,OAAOiB;IACT;IAEA,IAAID,SAASC,QAAQA,SAASjB,eAAe;QAC3C,OAAOgB;IACT;IAEA,IAAIE,SAASJ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Z,IAAIoC;QAEV,IAAIW,KAAK;YACP,OAAOA;QACT;IACF;IAEA,IAAK,IAAIM,WAAWzC,KAAKG,IAAI,EAAEsC,UAAUA,WAAWA,SAAStC,IAAI,CAAE;QACjE,MAAMuC,QAAQlC,OAAOK,MAAM,CAACzB,GAAG,CAAC0B,QAAQN,QAAQT,MAAM0C;QAEtD,IAAIC,OAAO;YACT,wFAAwF;YACxF,0CAA0C;YAC1C,OACEA,KAAK,CAAC,GAAGlB,KAAK,CAAC,EAAEjD,aAAayB,MAAM2C,KAAK,CAACpE,aAAakE,UAAUG,MAAM,GAAG,IAAI,CAAC,IAAI;QAEvF;IACF;IAEA,OAAO;AACT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pothos/selection-mapper",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "description": "shared selection-to-query walker for Pothos ORM plugins",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./dts/index.d.ts",
@@ -37,11 +37,11 @@
37
37
  "graphql": "^16.10.0 || ^17.0.0"
38
38
  },
39
39
  "devDependencies": {
40
- "@graphql-tools/executor": "^1.5.2",
40
+ "@graphql-tools/executor": "^2.0.1",
41
41
  "graphql": "^17.0.1",
42
42
  "graphql-tag": "^2.12.6",
43
43
  "vitest": "^4.1.4",
44
- "@pothos/core": "4.17.0",
44
+ "@pothos/core": "4.18.1",
45
45
  "@pothos/test-utils": "2.3.0"
46
46
  },
47
47
  "scripts": {
package/src/index.ts CHANGED
@@ -13,7 +13,6 @@ export {
13
13
  getLoaderMapping,
14
14
  type Mapping,
15
15
  type Mappings,
16
- setFieldMapping,
17
16
  setLoaderMappings,
18
17
  setRowFieldMapping,
19
18
  setRowMappings,
package/src/loader-map.ts CHANGED
@@ -70,30 +70,22 @@ export function unionMappings(into: Mapping | undefined, from: Mapping): Mapping
70
70
  }
71
71
 
72
72
  /**
73
- * Per execution: the mappings recorded so far, and the keys they were recorded under, by
74
- * the path prefix that rehomed them. `responsePath` drops list indices, so every row of a list
75
- * rebuilds the same key strings; a prefix builds them once.
73
+ * Per execution: the mappings recorded so far.
76
74
  *
77
- * `scopes` holds what a plan recorded beneath a field execution: everything resolved beneath it
78
- * was loaded by that plan, so it answers for all of it, and for nothing else. `rows` holds a
79
- * mapping that answers for one row only — because two plans disagreed about a key, or because the
80
- * plan loaded that row alone. A mapping carries the position a connection pages with, so a row
81
- * answering from another row's mapping would page with arguments its own data was never fetched
82
- * with. `rowScoped` stays false while nothing has been recorded there, so a request whose rows
83
- * were all loaded the same way pays nothing for the row tier.
84
- *
85
- * `mappings` holds a mapping recorded for each path, list indices dropped. It tells whether
86
- * the plans of a path's rows agree (see `claim`), and never answers a lookup: a row at the same
87
- * path that no plan loaded would read it as proof that one had.
75
+ * `scopes` holds what a plan recorded beneath a field execution: everything resolved beneath it was
76
+ * loaded by that plan, so it answers for all of it, and for nothing else. `rows` holds a mapping
77
+ * from a plan that loaded one row alone, and answers for that row only. A mapping carries the
78
+ * position a connection pages with, so a row answering from another row's mapping would page with
79
+ * arguments its own data was never fetched with. `rowScoped` stays false while nothing has been
80
+ * recorded there, so a request whose rows were all loaded the same way pays nothing for the row
81
+ * tier.
88
82
  *
89
83
  * `scopes` and `rows` are keyed by a field execution's place (see `placeOf`), which tells sibling
90
84
  * rows apart, in weak maps: a `Map` holding every path link of a request tripled the time spent
91
85
  * collecting garbage.
92
86
  */
93
87
  interface Cache {
94
- mappings: Map<string, Mapping>;
95
88
  places: Map<string, object>;
96
- rehomed: Map<string, Map<string, string>>;
97
89
  rows: WeakMap<object, WeakMap<object, Map<string, Mapping>>>;
98
90
  rowScoped: boolean;
99
91
  scopes: WeakMap<object, Mappings>;
@@ -106,22 +98,18 @@ const contextCaches = createContextCache(() => new WeakMap<object, Cache>());
106
98
  * An object the executor builds once per execution, and once per event of a subscription, and
107
99
  * hands to every resolver in it, @defer and @stream payloads included:
108
100
  *
109
- * - graphql-js 17: the `getAbortSignal` of the execution.
110
- * - graphql-js 16 and @graphql-tools/executor (Yoga): the root link of the path. They build one
101
+ * - graphql-js 16 and 17, @graphql-tools/executor (Yoga): the root link of the path. They build one
111
102
  * path chain per execution or event, linking each field to its parent's, so every resolver
112
103
  * beneath a root field shares its link, and the `subscribe` resolver has its own. Their fields'
113
104
  * links carry a `typename`. A root field doesn't share its link with the others, so each root
114
105
  * field has a cache of its own, which is all it reads.
115
106
  * - graphql-jit: the coerced `variableValues`. It builds a new path, without `typename`, for every
116
107
  * resolver, but coerces the variables afresh for every execution and event.
108
+ *
109
+ * Not `info.getAbortSignal`: @graphql-tools/executor 2 builds a new getter for every resolver, and
110
+ * the signal it returns is the caller's, absent or shared by every event of a subscription.
117
111
  */
118
112
  function executionOf(info: GraphQLResolveInfo): object {
119
- const signal = (info as { getAbortSignal?: object }).getAbortSignal;
120
-
121
- if (signal) {
122
- return signal;
123
- }
124
-
125
113
  let { path } = info;
126
114
 
127
115
  if (path.typename === undefined) {
@@ -142,9 +130,7 @@ function cache(ctx: object, info: GraphQLResolveInfo): Cache {
142
130
 
143
131
  if (!cached) {
144
132
  cached = {
145
- mappings: new Map(),
146
133
  places: new Map(),
147
- rehomed: new Map(),
148
134
  rows: new WeakMap(),
149
135
  rowScoped: false,
150
136
  scopes: new WeakMap(),
@@ -180,8 +166,9 @@ function placeOf(cached: Cache, info: GraphQLResolveInfo, path: GraphQLResolveIn
180
166
  /**
181
167
  * The entries of `cache` for the operation `info` is in. Keyed on its `variableValues`, which
182
168
  * every executor coerces afresh for each operation, so operations sharing a context never share
183
- * an entry. The events of a subscription may share them, so a plan cached here runs its `select`
184
- * and `query` callbacks once for all of them; use `forExecution` where they read per-event state.
169
+ * an entry. The events of a subscription may share one, so a plan cached here runs its `select`
170
+ * and `query` callbacks once for all of them. Use `forExecution` if the callbacks read per-event
171
+ * state.
185
172
  */
186
173
  export function forOperation<T>(
187
174
  cache: WeakMap<object, Map<string, T>>,
@@ -191,9 +178,8 @@ export function forOperation<T>(
191
178
  }
192
179
 
193
180
  /**
194
- * The entries of `cache` for the execution `info` is in, by `executionOf`, as mappings are kept:
195
- * each event of a subscription gets its own, and @defer and @stream payloads share their
196
- * execution's.
181
+ * The entries of `cache` for the execution `info` is in. Each event of a subscription gets its own
182
+ * entries, and `@defer` and `@stream` payloads share the entries of their execution.
197
183
  */
198
184
  export function forExecution<T>(
199
185
  cache: WeakMap<object, Map<string, T>>,
@@ -266,12 +252,12 @@ const fieldNodeIds = new WeakMap<object, number>();
266
252
  let nextFieldNodeId = 0;
267
253
 
268
254
  /**
269
- * `cacheKey(type, info.path)` and the identity of every node in `info.fieldNodes`. The path keeps
270
- * each place in the response apart, list indices aside, so the root fields of a mutation, which run
271
- * in turn and whose callbacks may read what an earlier one changed, never share a plan. The nodes
272
- * decide what a plan loads: fragments on different types can merge different nodes into one
273
- * response path, so a plan keyed on the path alone would be reused for a field asking for
274
- * something else.
255
+ * The key to cache a field's plan under: `cacheKey(type, info.path)` plus an id for each node in
256
+ * `info.fieldNodes`. The path leaves out list indices, so the items of a list share a plan. The
257
+ * root fields of a mutation run in turn, and a callback may read what an earlier field changed.
258
+ * Their paths differ, so each gets its own plan. The nodes are part of the key because fragments on
259
+ * different types can merge different nodes into one response path, and a plan keyed on the path
260
+ * alone would be reused for a field that selects something else.
275
261
  */
276
262
  export function fieldKey(type: string, info: GraphQLResolveInfo): string {
277
263
  let key = cacheKey(type, info.path);
@@ -290,56 +276,11 @@ export function fieldKey(type: string, info: GraphQLResolveInfo): string {
290
276
  return key;
291
277
  }
292
278
 
293
- /**
294
- * The keys `mappings` is recorded under when it is rehomed beneath `prefix`. Built once per
295
- * prefix: the strings depend on the path and the plan's own keys, never on which row is being
296
- * recorded for.
297
- */
298
- function rehomedKeys(cached: Cache, prefix: string) {
299
- let keys = cached.rehomed.get(prefix);
300
-
301
- if (!keys) {
302
- keys = new Map();
303
- cached.rehomed.set(prefix, keys);
304
- }
305
-
306
- return keys;
307
- }
308
-
309
- /** `key`, a plan's own `Type@relative.path`, moved beneath `prefix`. Built once per prefix. */
310
- function rehome(keys: Map<string, string>, key: string, prefix: string) {
311
- let under = keys.get(key);
312
-
313
- if (under === undefined) {
314
- const at = key.indexOf('@');
315
-
316
- under = `${key.slice(0, at)}@${prefix}.${key.slice(at + 1)}`;
317
- keys.set(key, under);
318
- }
319
-
320
- return under;
321
- }
322
-
323
279
  /** `row` if a mapping can be hung off it. A root field resolves with no parent value at all. */
324
280
  function ownerOf(row: unknown): object | null {
325
281
  return typeof row === 'object' && row !== null ? row : null;
326
282
  }
327
283
 
328
- /**
329
- * Records `mapping` at `key` for `row`. An unclaimed key takes it, and a key already holding this
330
- * very mapping needs no write, so the rows after the first write nothing. Only a key two plans
331
- * disagree about gives the row a mapping of its own — or, with no row to hang it off, nothing.
332
- */
333
- function claim(cached: Cache, key: string, mapping: Mapping, row: object | null, place: object) {
334
- const held = cached.mappings.get(key);
335
-
336
- if (held === undefined) {
337
- cached.mappings.set(key, mapping);
338
- } else if (held !== mapping && row) {
339
- claimForRow(cached, key.slice(0, key.indexOf('@')), mapping, row, place);
340
- }
341
- }
342
-
343
284
  /**
344
285
  * Records `mapping` for this field execution against `row` alone.
345
286
  */
@@ -360,21 +301,15 @@ function claimForRow(cached: Cache, type: string, mapping: Mapping, row: object,
360
301
 
361
302
  /**
362
303
  * Records the mappings of a plan rooted at the field `info` resolves, under that field's path.
363
- * The plan loaded the whole field, so its mappings answer for everything resolved beneath this
304
+ * The plan loaded the whole field, so its mappings are used for everything resolved beneath this
364
305
  * execution of it. Multiple plans can contribute to one field (Relay nodes of different model
365
306
  * types share the list's path), so later contributions replace matching keys and retain others.
366
307
  */
367
308
  export function setLoaderMappings(ctx: object, info: GraphQLResolveInfo, mappings: Mappings) {
368
309
  const cached = cache(ctx, info);
369
- const prefix = responsePath(info.path);
370
- const keys = rehomedKeys(cached, prefix);
371
310
  const place = placeOf(cached, info, info.path);
372
311
  const previous = cached.scopes.get(place);
373
312
  cached.scopes.set(place, previous ? { ...previous, ...mappings } : mappings);
374
-
375
- for (const key of Object.keys(mappings)) {
376
- cached.mappings.set(rehome(keys, key, prefix), mappings[key]);
377
- }
378
313
  }
379
314
 
380
315
  /**
@@ -389,28 +324,8 @@ export function setRowMappings(ctx: object, info: GraphQLResolveInfo, mappings:
389
324
  }
390
325
 
391
326
  /**
392
- * Records the mapping of the field `info` resolves (under its own parent type) along with the
393
- * mappings beneath it, so both the field's resolver and the resolvers below it can look
394
- * themselves up. `row` is the value the field is about to resolve with: the parent row when it
395
- * was loaded by the planned query, and the reloaded row when the fallback loader fetched it.
396
- */
397
- export function setFieldMapping(
398
- ctx: object,
399
- info: GraphQLResolveInfo,
400
- mapping: Mapping,
401
- row: unknown,
402
- ) {
403
- const cached = cache(ctx, info);
404
- const place = placeOf(cached, info, info.path);
405
-
406
- claim(cached, cacheKey(info.parentType.name, info.path), mapping, ownerOf(row), place);
407
- cached.scopes.set(place, mapping.nested);
408
- }
409
-
410
- /**
411
- * `setFieldMapping` for a plan that loaded `row` alone: the field's own mapping is recorded
412
- * against `row` rather than claimed for the whole field, so the field's lookup on `row` answers
413
- * from it whatever the field's other rows were loaded with.
327
+ * Records a mapping for `row` only, for the field `info` resolves. Use it when the plan loaded
328
+ * `row` alone. The field's other rows don't use this mapping.
414
329
  *
415
330
  * Descendants inherit the mapping through this field's execution scope, even when their parent
416
331
  * is a child object or a connection wrapper rather than the row that was reloaded.
@@ -435,8 +350,9 @@ export function setRowFieldMapping(
435
350
  /**
436
351
  * The mapping recorded for the field `info` resolves on `row`, preferring one recorded for that
437
352
  * row over the plan's. `row` is the value whose data the mapping describes — the resolver's
438
- * parent. The plan's comes from the nearest field execution above that recorded one: with none
439
- * above, no plan loaded `row`, whatever was recorded for another row at the same path.
353
+ * parent. The plan's mapping comes from the nearest field execution above this one that recorded
354
+ * mappings. Returns `null` if there is none or it has no mapping for this field, even if a mapping
355
+ * was recorded for another row at the same path.
440
356
  */
441
357
  export function getLoaderMapping(
442
358
  ctx: object,