@pothos/selection-mapper 0.1.0 → 0.2.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.
Files changed (90) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +17 -6
  3. package/dts/deep-equal.d.ts +4 -0
  4. package/dts/deep-equal.d.ts.map +1 -1
  5. package/dts/errors.d.ts +7 -0
  6. package/dts/errors.d.ts.map +1 -0
  7. package/dts/index.d.ts +3 -2
  8. package/dts/index.d.ts.map +1 -1
  9. package/dts/loader-map.d.ts +36 -8
  10. package/dts/loader-map.d.ts.map +1 -1
  11. package/dts/matches.d.ts +5 -0
  12. package/dts/matches.d.ts.map +1 -1
  13. package/dts/parent-types.d.ts +9 -0
  14. package/dts/parent-types.d.ts.map +1 -0
  15. package/dts/plan.d.ts +36 -20
  16. package/dts/plan.d.ts.map +1 -1
  17. package/dts/shape.d.ts +8 -0
  18. package/dts/shape.d.ts.map +1 -0
  19. package/dts/types.d.ts +21 -1
  20. package/dts/types.d.ts.map +1 -1
  21. package/dts/walk.d.ts +20 -2
  22. package/dts/walk.d.ts.map +1 -1
  23. package/esm/deep-equal.d.ts +4 -0
  24. package/esm/deep-equal.d.ts.map +1 -1
  25. package/esm/deep-equal.js +60 -28
  26. package/esm/deep-equal.js.map +1 -1
  27. package/esm/errors.d.ts +7 -0
  28. package/esm/errors.d.ts.map +1 -0
  29. package/esm/errors.js +11 -0
  30. package/esm/errors.js.map +1 -0
  31. package/esm/index.d.ts +3 -2
  32. package/esm/index.d.ts.map +1 -1
  33. package/esm/index.js +2 -1
  34. package/esm/index.js.map +1 -1
  35. package/esm/loader-map.d.ts +36 -8
  36. package/esm/loader-map.d.ts.map +1 -1
  37. package/esm/loader-map.js +177 -60
  38. package/esm/loader-map.js.map +1 -1
  39. package/esm/matches.d.ts +5 -0
  40. package/esm/matches.d.ts.map +1 -1
  41. package/esm/matches.js +11 -3
  42. package/esm/matches.js.map +1 -1
  43. package/esm/parent-types.d.ts +9 -0
  44. package/esm/parent-types.d.ts.map +1 -0
  45. package/esm/parent-types.js +24 -0
  46. package/esm/parent-types.js.map +1 -0
  47. package/esm/plan.d.ts +36 -20
  48. package/esm/plan.d.ts.map +1 -1
  49. package/esm/plan.js +107 -71
  50. package/esm/plan.js.map +1 -1
  51. package/esm/shape.d.ts +8 -0
  52. package/esm/shape.d.ts.map +1 -0
  53. package/esm/shape.js +94 -0
  54. package/esm/shape.js.map +1 -0
  55. package/esm/types.d.ts +21 -1
  56. package/esm/types.d.ts.map +1 -1
  57. package/esm/types.js.map +1 -1
  58. package/esm/walk.d.ts +20 -2
  59. package/esm/walk.d.ts.map +1 -1
  60. package/esm/walk.js +199 -71
  61. package/esm/walk.js.map +1 -1
  62. package/lib/deep-equal.js +60 -28
  63. package/lib/deep-equal.js.map +1 -1
  64. package/lib/errors.js +18 -0
  65. package/lib/errors.js.map +1 -0
  66. package/lib/index.js +13 -0
  67. package/lib/index.js.map +1 -1
  68. package/lib/loader-map.js +157 -53
  69. package/lib/loader-map.js.map +1 -1
  70. package/lib/matches.js +14 -3
  71. package/lib/matches.js.map +1 -1
  72. package/lib/parent-types.js +29 -0
  73. package/lib/parent-types.js.map +1 -0
  74. package/lib/plan.js +107 -71
  75. package/lib/plan.js.map +1 -1
  76. package/lib/shape.js +109 -0
  77. package/lib/shape.js.map +1 -0
  78. package/lib/walk.js +186 -68
  79. package/lib/walk.js.map +1 -1
  80. package/package.json +4 -3
  81. package/src/deep-equal.ts +77 -34
  82. package/src/errors.ts +12 -0
  83. package/src/index.ts +6 -0
  84. package/src/loader-map.ts +261 -71
  85. package/src/matches.ts +15 -3
  86. package/src/parent-types.ts +33 -0
  87. package/src/plan.ts +145 -78
  88. package/src/shape.ts +126 -0
  89. package/src/types.ts +25 -1
  90. package/src/walk.ts +250 -83
package/CHANGELOG.md ADDED
@@ -0,0 +1,24 @@
1
+ # @pothos/selection-mapper
2
+
3
+ ## 0.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - f42670b: - Fields in a fragment on an abstract type without a model (such as `... on Node` beneath a model interface) are now planned for each type the fragment covers, so the parent query loads them. If those types' type-level selections conflict, planning fails, as it does for fragments that name the types.
8
+ - Repeated selection sets are planned once and shared, so planning time grows linearly with the document's depth. Reading `Position.parent` turns off sharing for that walk. Use `Position.walkParent` to read the shared walk's parents instead. Beneath a fragment on an abstract type without a model, a field the implementations inherit from the model interface is planned once, on the interface, rather than once per implementation.
9
+ - `deepEqual` no longer throws on Temporal values. It compares plain objects, arrays and Dates by value, and any other object with its `equals` method, or by identity.
10
+ - `Plan.forParentRow` takes an options object: `forParentRow(adapter, { context, info, skipDeferredFragments, initial })`. The `Mapping` and `ParentRowOptions` types are exported.
11
+ - Errors raised while planning a request, such as a conflict between the type-level selections of two variants or a select that returned before its nested selection settled, now reach clients as `Unexpected error.`, still a `PothosValidationError`. The detail is in the error's `cause`.
12
+ - `mappingParentTypes` lists the types a field's resolver looks up loader mappings under: its parent type, and the interfaces with a model whose own field of that name it inherits.
13
+ - `getLoaderMapping` takes the resolver's `info` in place of its path: `getLoaderMapping(context, info, type, row)`.
14
+ - `forOperation(cache, info)` returns the entries of a `WeakMap` cache for the operation `info` is in, for plugins that cache plans per operation.
15
+ - 8686c06: `fieldKey(type, info)` keys a plan cached for a field on the type, the response path and the field nodes graphql merged for it, so fragments on different types that reach one response path get separate plans.
16
+
17
+ `forExecution(cache, info)` keeps entries per execution, as loader mappings are kept, so each subscription event gets its own.
18
+
19
+ ### Patch Changes
20
+
21
+ - 9fbe606: A `nestedSelection` path that doesn't fit the field's type (a field or pinned type the schema doesn't have, or a segment that isn't an object or interface) now reaches clients as `Unexpected error.`, with the detail in the error's `cause`.
22
+ - c2fa676: Loader mappings are recorded per execution, and per subscription event, under graphql-js, graphql-jit and `@graphql-tools/executor` (Yoga), so operations and events sharing a context don't read each other's. An execution is told apart by the `getAbortSignal` graphql-js 17 passes, by the root link of its path under graphql-js 16 and `@graphql-tools/executor`, and by its `variableValues` under graphql-jit. Under graphql-jit, planned relations no longer load again for every row.
23
+
24
+ `getLoaderMapping` returns `null` for a row with no plan recorded above it, instead of the mapping recorded for another row at the same response path.
package/README.md CHANGED
@@ -11,10 +11,10 @@ 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
- `getLoaderMapping`, `setFieldMapping`, `setLoaderMappings`, `setRowFieldMapping`,
15
- `setRowMappings`), `selectedFieldNames` and `deepEqual`. Turning a plan into the query a resolver
16
- is handed is each plugin's own job — prisma's `queryFromInfo` and drizzle's differ — so neither of
17
- them is here.
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.
18
18
 
19
19
  ## Vocabulary
20
20
 
@@ -43,7 +43,7 @@ them is here.
43
43
  find its data in the loaded row; absent means the resolver loads its own data.
44
44
  - **Position** — where a field is: a link of `{ parent, type, field, node }` running back to the
45
45
  field an entry point was called for, handed to a select function and recorded with the field's
46
- mapping.
46
+ mapping. `walkParent` is the same link as the shared walk holds it.
47
47
 
48
48
  ## The adapter contract
49
49
 
@@ -84,9 +84,20 @@ extends `Adapter` directly.
84
84
  mutates it changes what a later play builds. Nothing copies it, because a query is opaque to
85
85
  this package and could only be copied by round-tripping it through the adapter on every field.
86
86
  - Every play records its loader mappings on the request context, which pothos requires to be an
87
- object; an adapter whose resolvers read a loaded row another way simply never looks them up.
87
+ 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
92
+ every resolver, it is told apart by its `variableValues`, coerced afresh for each execution and
93
+ event. The plugins pass `getLoaderMapping` the resolver's `info`. An adapter whose resolvers
94
+ read a loaded row another way simply never looks them up.
88
95
  - Every select function is handed the `Position` of the field it plans: the field's node, the type
89
96
  it was walked on, and a link to the position of the field the plan hangs beneath. The walker
90
97
  reads none of it — an adapter that wants a path or a list of segments walks `parent` and
91
98
  materializes its own — and records it with the field's mapping, so a resolver can ask the same
92
99
  question the select path asked.
100
+ - Reading `parent` during planning stops the walk it reads through from being shared, so each
101
+ place the field appears is walked again with its own path. `walkParent` reads the shared walk's
102
+ parents without that cost; they are the first invocation's, so use it only for a name that must
103
+ agree with itself, not for where a field really is.
@@ -2,6 +2,10 @@
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
  */
6
10
  export declare function deepEqual(left: unknown, right: unknown): boolean;
7
11
  //# sourceMappingURL=deep-equal.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"deep-equal.d.ts","sourceRoot":"","sources":["../src/deep-equal.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAyDhE"}
1
+ {"version":3,"file":"deep-equal.d.ts","sourceRoot":"","sources":["../src/deep-equal.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CA4DhE"}
@@ -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/dts/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 Mappings, setFieldMapping, setLoaderMappings, setRowFieldMapping, setRowMappings, } from './loader-map.js';
8
+ export { cacheKey, fieldKey, forExecution, forOperation, getLoaderMapping, type Mapping, type Mappings, setFieldMapping, 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
@@ -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,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B,QAAQ,EACR,iBAAiB,EACjB,QAAQ,EACR,UAAU,GACX,MAAM,YAAY,CAAC"}
@@ -21,22 +21,48 @@ 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 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.
35
+ */
36
+ export declare function forOperation<T>(cache: WeakMap<object, Map<string, T>>, info: GraphQLResolveInfo): Map<string, T>;
37
+ /**
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.
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
+ * `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.
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 answer for every row of it: they go to the
32
- * shared tier. Multiple plans can contribute to one field (Relay nodes of different model
57
+ * The plan loaded the whole field, so its mappings answer 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 execution path retains indices to isolate siblings.
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
  /**
@@ -48,16 +74,18 @@ export declare function setRowMappings(ctx: object, info: GraphQLResolveInfo, ma
48
74
  export declare function setFieldMapping(ctx: object, info: GraphQLResolveInfo, mapping: Mapping, row: unknown): void;
49
75
  /**
50
76
  * `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.
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.
53
79
  *
54
80
  * Descendants inherit the mapping through this field's execution scope, even when their parent
55
81
  * is a child object or a connection wrapper rather than the row that was reloaded.
56
82
  */
57
83
  export declare function setRowFieldMapping(ctx: object, info: GraphQLResolveInfo, mapping: Mapping, row: unknown): void;
58
84
  /**
59
- * The mapping recorded for the field at `path` on `row`, preferring one recorded for that row
60
- * over the plan's. `row` is the value whose data the mapping describes — the resolver's parent.
85
+ * The mapping recorded for the field `info` resolves on `row`, preferring one recorded for that
86
+ * 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.
61
89
  */
62
- export declare function getLoaderMapping(ctx: object, path: GraphQLResolveInfo['path'], type: string, row?: unknown): Mapping | null;
90
+ export declare function getLoaderMapping(ctx: object, info: GraphQLResolveInfo, type: string, row?: unknown): Mapping | null;
63
91
  //# 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;AAE/F;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,SAAS,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAY/E;AAgCD,kFAAkF;AAClF,wBAAgB,YAAY,CAAC,IAAI,EAAE,kBAAkB,CAAC,MAAM,CAAC,GAAG,SAAS,GAAG,MAAM,CAgBjF;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,kBAAkB,CAAC,MAAM,CAAC,UAEtE;AAuFD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,kBAAkB,EAAE,QAAQ,EAAE,QAAQ,QAU1F;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,G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B,EACxB,IAAI,EAAE,MAAM,EACZ,GAAG,CAAC,EAAE,OAAO,GACZ,OAAO,GAAG,IAAI,CA+BhB"}
package/dts/matches.d.ts CHANGED
@@ -13,6 +13,11 @@ export interface IndirectInclude {
13
13
  path?: IndirectPathSegment[];
14
14
  paths?: IndirectPathSegment[][];
15
15
  }
16
+ /** The paths an include follows: `paths` when it has any, else `path`, else none. */
17
+ export declare function includePaths<Segment>(include: {
18
+ path?: Segment[];
19
+ paths?: Segment[][];
20
+ }): Segment[][] | undefined;
16
21
  export interface Match {
17
22
  /** The GraphQL type of the matched field's return type */
18
23
  type: GraphQLNamedType;
@@ -1 +1 @@
1
- {"version":3,"file":"matches.d.ts","sourceRoot":"","sources":["../src/matches.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,EAGvB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAIlB,KAAK,kBAAkB,EAKxB,MAAM,SAAS,CAAC;AAEjB,MAAM,WAAW,mBAAmB;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,mBAAmB,CAAC;AAEvD;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,mBAAmB,EAAE,CAAC;IAC7B,KAAK,CAAC,EAAE,mBAAmB,EAAE,EAAE,CAAC;CACjC;AAED,MAAM,WAAW,KAAK;IACpB,0DAA0D;IAC1D,IAAI,EAAE,gBAAgB,CAAC;IACvB,KAAK,EAAE,SAAS,CAAC;IACjB,2EAA2E;IAC3E,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,YAAY;IAC3B,iDAAiD;IACjD,MAAM,CAAC,EAAE,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,YAAY,EAAE,QAAQ,CAAM,GAC5C,KAAK,GAAG,SAAS,CAUnB;AAgBD;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,kBAAkB,GAAG,WAAW,CAAC,MAAM,CAAC,CAkBjG;AAgBD,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,kBAAkB,EACxB,UAAU,2CAAgC,EAC1C,UAAU,GAAE,SAAS,SAAS,EAAoB,GACjD,WAAW,CAAC,MAAM,CAAC,CA4BrB;AAuED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,WAAW,EAAE,EACnB,IAAI,EAAE,gBAAgB,EACtB,YAAY,EAAE,gBAAgB,GAAG,SAAS,EAC1C,MAAM,EAAE,aAAa,GACpB,eAAe,CAiDjB;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,kBAAkB,EACxB,SAAS,EAAE,SAAS,GAAG,kBAAkB,GAAG,kBAAkB,WAiB/D;AAED,qFAAqF;AACrF,wBAAgB,UAAU,CACxB,IAAI,EAAE,kBAAkB,EACxB,IAAI,EAAE,kBAAkB,GAAG,kBAAkB,WAa9C"}
@@ -0,0 +1,9 @@
1
+ import type { BuildCache, PothosOutputFieldConfig, SchemaTypes } from '@pothos/core';
2
+ /**
3
+ * The types whose loader mappings answer for a field: its parent type, and each interface of it
4
+ * that has a model and declares the same field. Pothos builds an inherited field from the
5
+ * interface's options, so an implementation that redefines the field (other relation arguments,
6
+ * say) does not read what the interface's field loaded.
7
+ */
8
+ export declare function mappingParentTypes<Types extends SchemaTypes>(buildCache: BuildCache<Types>, fieldConfig: PothosOutputFieldConfig<Types>, modelExtension: string): Set<string>;
9
+ //# sourceMappingURL=parent-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parent-types.d.ts","sourceRoot":"","sources":["../src/parent-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAErF;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,SAAS,WAAW,EAC1D,UAAU,EAAE,UAAU,CAAC,KAAK,CAAC,EAC7B,WAAW,EAAE,uBAAuB,CAAC,KAAK,CAAC,EAC3C,cAAc,EAAE,MAAM,GACrB,GAAG,CAAC,MAAM,CAAC,CAoBb"}
package/dts/plan.d.ts CHANGED
@@ -2,11 +2,11 @@ import { type GraphQLNamedType, type GraphQLResolveInfo } from 'graphql';
2
2
  import type { Adapter, NodeBase } from './adapter.js';
3
3
  import { type Mapping, type Mappings } from './loader-map.js';
4
4
  import type { Node } from './node.js';
5
- import type { EntryOptions, Position, WalkedType } from './types.js';
5
+ import type { EntryOptions, ParentRowOptions, Position, WalkedType } from './types.js';
6
6
  /**
7
7
  * One merge a traversal collected, in the order it happened: a type's selection, a same-model
8
- * variant's, a nested selection's relation query, or a field's. A play folds the list into a
9
- * node; nothing is merged, accepted or rejected before then.
8
+ * variant's, or a field's. A play folds the list into a node; nothing is merged, accepted or
9
+ * rejected before then.
10
10
  *
11
11
  * A record holds its query by reference, so a select function that mutates the query it returned
12
12
  * after returning it changes what a later play builds — a bug in the select function. Nothing
@@ -16,9 +16,6 @@ import type { EntryOptions, Position, WalkedType } from './types.js';
16
16
  export type RootMerge<Query> = {
17
17
  kind: 'type';
18
18
  query: Query;
19
- } | {
20
- kind: 'query';
21
- query: Query;
22
19
  } | {
23
20
  kind: 'variant';
24
21
  type: WalkedType;
@@ -68,6 +65,17 @@ export declare class Plan<Model, Query, NodeType extends NodeBase<Model> = Node<
68
65
  pending?: Promise<void>;
69
66
  /** The traversal's whole output: every merge it collected, in the order it collected them. */
70
67
  private readonly merges;
68
+ /** The plan whose merges a play folds: this one, or a walk shared with other invocations. */
69
+ private walk;
70
+ /** The relation query of the nested selection this plan was made for, merged ahead of `walk`. */
71
+ private relationQuery?;
72
+ /** Whether a select function in this walk read the position above its own field. */
73
+ positionRead: boolean;
74
+ /**
75
+ * The walks beneath every field of the plans hanging from one root, by `nested`'s `key`. Shared
76
+ * with the plan this one was created from, so the root creates it and every nested plan reads it.
77
+ */
78
+ private readonly walks;
71
79
  /**
72
80
  * The play `settle` ran, which a later play takes whole when the seed conflicts with none of
73
81
  * it. Never handed out: a play that reuses it copies it into a node of its own.
@@ -86,8 +94,9 @@ export declare class Plan<Model, Query, NodeType extends NodeBase<Model> = Node<
86
94
  * replaces the parent the field resolver sees, so besides the field's own selection it
87
95
  * carries the parent type's type-level selection. The field is what the row is loaded for, so
88
96
  * it is merged first and a type-level relation whose arguments conflict with it is left out.
97
+ * `initial` is merged before anything else.
89
98
  */
90
- static forParentRow<Model, Query, NodeType extends NodeBase<Model> = Node<Model>>(adapter: Adapter<Model, Query, NodeType>, context: object, info: GraphQLResolveInfo, skipDeferredFragments?: boolean): PlayedPlan<Model, Query, NodeType>;
99
+ static forParentRow<Model, Query, NodeType extends NodeBase<Model> = Node<Model>>(adapter: Adapter<Model, Query, NodeType>, options: ParentRowOptions<Query>): PlayedPlan<Model, Query, NodeType>;
91
100
  /**
92
101
  * `source` is an entry point's options for a root plan and the parent plan for a nested one,
93
102
  * which is why `initial` is passed beside it: it belongs to the root alone and a nested plan
@@ -99,15 +108,28 @@ export declare class Plan<Model, Query, NodeType extends NodeBase<Model> = Node<
99
108
  initial?: Query | undefined);
100
109
  /**
101
110
  * The plan beneath one nested selection: this plan's adapter, context, info and deferred
102
- * setting, with merges of its own. It hangs beneath the field whose select function made it.
103
- */
104
- nested(type: GraphQLNamedType, position: Position): Plan<Model, Query, NodeType>;
111
+ * setting. It holds the invocation's relation query and plays over a walk of the selection
112
+ * beneath the field, which `walk` collects the first time this plan needs it.
113
+ *
114
+ * One field node is invoked once per type it is reached on in a walk (see `walkField`). A named
115
+ * fragment spread at every level reaches the same selection set beneath several field nodes,
116
+ * which may hang beneath different plans, so a walk per invocation is exponential in the
117
+ * document's depth.
118
+ *
119
+ * What a walk collects depends only on `key`, which names the selection set by its shape (see
120
+ * shape.ts) and holds everything else the walk reads, unless a select function reads the
121
+ * position above it: `positionRead` says it did. Every other invocation with the same key, under
122
+ * any plan from the same root, shares a walk that did not. A walk that is still pending may yet
123
+ * read it, so it is not shared. A walk that throws is not kept, so a select function that catches
124
+ * the failure can retry it.
125
+ */
126
+ nested(type: GraphQLNamedType, position: Position, key: string, walk: (plan: Plan<Model, Query, NodeType>) => void): Plan<Model, Query, NodeType>;
105
127
  /** Appends one merge to the list a play folds. The traversal's only way to add to a plan. */
106
128
  collect(merge: RootMerge<Query>): void;
107
129
  /**
108
- * The relation query of the nested selection this plan was made for. It takes the head of the
109
- * list, so it is merged before the fields walked beneath it whether the callback that produced
110
- * it answered at once or resolved after the walk. A nested plan has at most one.
130
+ * The relation query of the nested selection this plan was made for. It is merged ahead of the
131
+ * walk, whether the callback that produced it answered at once or resolved after the walk. A
132
+ * nested plan has at most one.
111
133
  */
112
134
  collectQuery(query: Query): void;
113
135
  /**
@@ -142,7 +164,7 @@ export declare class Plan<Model, Query, NodeType extends NodeBase<Model> = Node<
142
164
  /**
143
165
  * The plan played behind `seed`, its mappings recorded for the resolvers beneath it, and its
144
166
  * node serialized. A cached plan accepts the current resolver info to scope each execution.
145
- * Every play records its mappings on the request context; an adapter whose
167
+ * Every play records its mappings for the execution on the request context; an adapter whose
146
168
  * resolvers read a loaded row another way simply never looks them up.
147
169
  */
148
170
  query(seed?: Query, info?: GraphQLResolveInfo): Query;
@@ -166,11 +188,5 @@ export declare class Plan<Model, Query, NodeType extends NodeBase<Model> = Node<
166
188
  * `initial`, which the settled play already merged.
167
189
  */
168
190
  private reusable;
169
- /**
170
- * Unlike a field-level select, a type-level selection has no per-field fallback, so a relation
171
- * argument or a computed value that conflicts with what is already in the node is an error
172
- * rather than a rejection.
173
- */
174
- private mergeVariant;
175
191
  }
176
192
  //# sourceMappingURL=plan.d.ts.map
package/dts/plan.d.ts.map CHANGED
@@ -1 +1 @@
1
- {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Q,CAAC,KAAK,IAAI,GACjD,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,CA6B9B;IAED,6FAA6F;IAC7F,OAAO,CAAC,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,QAE9B;IAED;;;;OAIG;IACH,YAAY,CAAC,KAAK,EAAE,KAAK,QAExB;IAED;;;;;OAKG;IACH,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI,QAMpD;IAED;;;OAGG;IACH,OAAO,SAEN;IAED;;;;OAIG;IACH,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;IACtC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;IAOzD;;;;;;;;OAQG;IACH,IAAI,CAAC,IAAI,CAAC,EAAE,KAAK,GAAG,UAAU,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,CAsErD;IAED;;;;;OAKG;IACH,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,qBAAY,GAAG,KAAK,CAQ3C;IAED;;;;;OAKG;IACH,MAAM,IAAI,IAAI,CAIb;IAED;;;;OAIG;IACH,eAAe,CAAC,IAAI,EAAE,gBAAgB,GAAG,UAAU,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,CAS1E;IAED;;;;;OAKG;IACH,OAAO,CAAC,QAAQ;CASjB"}
package/dts/shape.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ import { type FieldNode, type GraphQLResolveInfo, type SelectionSetNode } from 'graphql';
2
+ export declare function selectionShape(info: GraphQLResolveInfo, selectionSet: SelectionSetNode | undefined): number;
3
+ /**
4
+ * The shape of a field selection: its alias, name, arguments, directives and the shape of its
5
+ * selection set. Two field nodes with one shape select the same thing under the same response key.
6
+ */
7
+ export declare function fieldShape(info: GraphQLResolveInfo, field: FieldNode): number;
8
+ //# sourceMappingURL=shape.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shape.d.ts","sourceRoot":"","sources":["../src/shape.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,kBAAkB,EAIvB,KAAK,gBAAgB,EACtB,MAAM,SAAS,CAAC;AAgBjB,wBAAgB,cAAc,CAC5B,IAAI,EAAE,kBAAkB,EACxB,YAAY,EAAE,gBAAgB,GAAG,SAAS,GACzC,MAAM,CAER;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,GAAG,MAAM,CAU7E"}
package/dts/types.d.ts CHANGED
@@ -16,8 +16,26 @@ export type WalkedType = GraphQLInterfaceType | GraphQLObjectType;
16
16
  * about costs one link per select function and no arrays at all.
17
17
  */
18
18
  export interface Position {
19
- /** The field this one is selected beneath, or undefined at the field the plan started from. */
19
+ /**
20
+ * The field this one is selected beneath, or undefined at the field the plan started from.
21
+ * Reading it during planning has a cost. Invocations of a field at different places normally
22
+ * share the walk beneath it; a read keeps every walk it reads through from being shared, so
23
+ * each invocation is walked with its own path, which a document whose fragments branch at every
24
+ * level makes exponential in its depth. A fragment expanding to the implementations of a model
25
+ * interface walks its fields as each implementation, which adds an invocation, and a path, per
26
+ * implementation, except for a field the implementation inherits unchanged from that interface
27
+ * and no fragment narrows to the implementation: it is invoked once, on the interface, and its
28
+ * path names the interface. Read after planning, it is the first invocation's.
29
+ */
20
30
  readonly parent: Position | undefined;
31
+ /**
32
+ * The same link as `parent`, read without keeping the walk beneath from being shared. Its chain
33
+ * is the one the shared walk holds, the first invocation's, and not always the true path, so it
34
+ * is only for a name that needs to agree with itself: one a plan writes into its query and a
35
+ * resolver beneath the same walk reads back through its mapping. Anything that depends on where
36
+ * a field really is reads `parent`.
37
+ */
38
+ readonly walkParent: Position | undefined;
21
39
  /** The type the field was walked on: its parent type, or a same-model type the plan moved to. */
22
40
  readonly type: WalkedType;
23
41
  readonly field: GraphQLField<unknown, unknown>;
@@ -61,6 +79,8 @@ export interface EntryOptions<Query> {
61
79
  */
62
80
  skipDeferredFragments?: boolean;
63
81
  }
82
+ /** The options of `Plan.forParentRow`, which plans the field `info` resolves on its own. */
83
+ export type ParentRowOptions<Query> = Pick<EntryOptions<Query>, 'context' | 'info' | 'initial' | 'skipDeferredFragments'>;
64
84
  /** How one merge into an adapter's node differs from a plain one. */
65
85
  export interface MergeOptions {
66
86
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EACV,SAAS,EACT,YAAY,EACZ,oBAAoB,EACpB,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEjE,MAAM,MAAM,UAAU,GAAG,oBAAoB,GAAG,iBAAiB,CAAC;AAElE;;;;;;;;GAQG;AACH,MAAM,WAAW,QAAQ;IACvB,+FAA+F;IAC/F,QAAQ,CAAC,MAAM,EAAE,QAAQ,GAAG,SAAS,CAAC;IACtC,iGAAiG;IACjG,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC/C,+EAA+E;IAC/E,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;CAC1B;AAED,wFAAwF;AACxF,MAAM,MAAM,WAAW,CAAC,KAAK,IACzB,YAAY,CAAC,KAAK,GAAG,IAAI,G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CAAC;AAEF,qEAAqE;AACrE,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,OAAO,GAAG,UAAU,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC;CACd"}
package/dts/walk.d.ts CHANGED
@@ -2,6 +2,13 @@ import { type FieldNode, type GraphQLNamedType } from 'graphql';
2
2
  import type { NodeBase } from './adapter.js';
3
3
  import type { Plan } from './plan.js';
4
4
  import type { WalkedType } from './types.js';
5
+ /**
6
+ * The select invocations of one walk, by the shape of the field node (see `fieldShape`) and the
7
+ * mapping key: two nodes of one shape at one place select the same thing under the same response
8
+ * key, so the first invocation answers for both, and the second is neither invoked nor collected.
9
+ * Local to a walk, so what it holds goes with it.
10
+ */
11
+ type Invocations = Set<string>;
5
12
  /**
6
13
  * One selection to walk into a plan, before any indirect include on `type` is followed: the
7
14
  * selection sets of `fieldNodes` (every node selecting one field), walked as `type`.
@@ -19,6 +26,17 @@ export interface Branch {
19
26
  * match, came first in the document.
20
27
  */
21
28
  export declare function walkBranches<Model, Query, NodeType extends NodeBase<Model>>(plan: Plan<Model, Query, NodeType>, branches: Branch[]): void;
22
- /** Collects what `fieldNode` (a field of `type`) selects. */
23
- export declare function walkField<Model, Query, NodeType extends NodeBase<Model>>(plan: Plan<Model, Query, NodeType>, type: WalkedType, fieldNode: FieldNode, indirectPath: string[]): void;
29
+ /**
30
+ * Collects what `fieldNode` (a field of `type`) selects. A select function is invoked once per
31
+ * place in a walk; `invocations` holds the walk's, and without it every call invokes.
32
+ *
33
+ * Beneath an expansion of the model interface `expandedFrom`, a field an implementation inherits
34
+ * unchanged (see `definitionOf`) is planned on the interface: invoked once rather than once per
35
+ * implementation, so a select function reading `Position.parent` sees one path per level. A
36
+ * resolver on an implementation accepts the interface's mapping for the same definition. A
37
+ * redefined field, or one under a fragment narrowing to the implementation, is planned as the
38
+ * implementation.
39
+ */
40
+ export declare function walkField<Model, Query, NodeType extends NodeBase<Model>>(plan: Plan<Model, Query, NodeType>, walkedType: WalkedType, fieldNode: FieldNode, indirectPath: string[], invocations?: Invocations, expandedFrom?: WalkedType): void;
41
+ export {};
24
42
  //# sourceMappingURL=walk.d.ts.map
package/dts/walk.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"walk.d.ts","sourceRoot":"","sources":["../src/walk.ts"],"names":[],"mappings":"AAYA,OAAO,EACL,KAAK,SAAS,EAGd,KAAK,gBAAgB,EAOtB,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAc7C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,KAAK,EAAuC,UAAU,EAAE,MAAM,YAAY,CAAC;AAwClF;;;GAGG;AACH,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,gBAAgB,CAAC;IACvB,UAAU,EAAE,SAAS,SAAS,EAAE,CAAC;IACjC,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAYD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,SAAS,QAAQ,CAAC,KAAK,CAAC,EACzE,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,EAClC,QAAQ,EAAE,MAAM,EAAE,QAoCnB;AA4ND,6DAA6D;AAC7D,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,SAAS,QAAQ,CAAC,KAAK,CAAC,EACtE,IAAI,EAAE,IAAI,CAAC,KAAK,EAA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6 +2,10 @@
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
  */
6
10
  export declare function deepEqual(left: unknown, right: unknown): boolean;
7
11
  //# sourceMappingURL=deep-equal.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"deep-equal.d.ts","sourceRoot":"","sources":["../src/deep-equal.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAyDhE"}
1
+ {"version":3,"file":"deep-equal.d.ts","sourceRoot":"","sources":["../src/deep-equal.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CA4DhE"}