houdini 1.0.0-next.1 → 1.0.0-next.3
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/build/cmd/generate.d.ts +0 -1
- package/build/cmd-cjs/index.js +1400 -2836
- package/build/cmd-esm/index.js +1400 -2836
- package/build/codegen/generators/artifacts/fieldKey.d.ts +1 -1
- package/build/codegen/generators/artifacts/index.d.ts +1 -1
- package/build/codegen/generators/artifacts/indexFile.d.ts +1 -1
- package/build/codegen/generators/artifacts/inputs.d.ts +2 -2
- package/build/codegen/generators/artifacts/operations.d.ts +2 -2
- package/build/codegen/generators/artifacts/selection.d.ts +1 -1
- package/build/codegen/generators/artifacts/utils.d.ts +1 -1
- package/build/codegen/generators/definitions/enums.d.ts +1 -1
- package/build/codegen/generators/definitions/index.d.ts +1 -1
- package/build/codegen/generators/indexFile/index.d.ts +1 -1
- package/build/codegen/generators/persistedQueries/index.d.ts +1 -1
- package/build/codegen/generators/runtime/graphqlFunction.d.ts +2 -0
- package/build/codegen/generators/runtime/index.d.ts +1 -1
- package/build/codegen/generators/runtime/injectPlugins.d.ts +7 -0
- package/build/codegen/generators/runtime/pluginIndex.d.ts +5 -0
- package/build/codegen/generators/typescript/addReferencedInputTypes.d.ts +1 -1
- package/build/codegen/generators/typescript/documentTypes.d.ts +2 -0
- package/build/codegen/generators/typescript/{imperativeCache.d.ts → imperativeTypeDef.d.ts} +1 -1
- package/build/codegen/generators/typescript/index.d.ts +1 -1
- package/build/codegen/generators/typescript/inlineType.d.ts +1 -1
- package/build/codegen/generators/typescript/typeReference.d.ts +1 -1
- package/build/codegen/generators/typescript/types.d.ts +1 -1
- package/build/codegen/index.d.ts +1 -1
- package/build/codegen/transforms/addID.d.ts +1 -1
- package/build/codegen/transforms/composeQueries.d.ts +2 -2
- package/build/codegen/transforms/fragmentVariables.d.ts +3 -2
- package/build/codegen/transforms/list.d.ts +1 -1
- package/build/codegen/transforms/paginate.d.ts +1 -1
- package/build/codegen/transforms/schema.d.ts +1 -1
- package/build/codegen/transforms/typename.d.ts +1 -1
- package/build/codegen/utils/commonjs.d.ts +2 -0
- package/build/codegen/utils/flattenSelections.d.ts +2 -2
- package/build/codegen/utils/moduleExport.d.ts +1 -1
- package/build/codegen/utils/objectIdentificationSelection.d.ts +1 -1
- package/build/codegen/validators/noIDAlias.d.ts +1 -1
- package/build/codegen/validators/typeCheck.d.ts +1 -1
- package/build/codegen-cjs/index.js +1320 -2779
- package/build/codegen-esm/index.js +1320 -2779
- package/build/lib/config.d.ts +9 -4
- package/build/lib/fs.d.ts +1 -1
- package/build/lib/graphql.d.ts +1 -1
- package/build/lib/imports.d.ts +1 -1
- package/build/lib/types.d.ts +3 -3
- package/build/lib/walk.d.ts +8 -5
- package/build/lib-cjs/index.js +155 -1856
- package/build/lib-esm/index.js +155 -1856
- package/build/runtime/cache/cache.d.ts +10 -8
- package/build/runtime/cache/gc.d.ts +1 -1
- package/build/runtime/cache/lists.d.ts +3 -2
- package/build/runtime/cache/schema.d.ts +2 -2
- package/build/runtime/cache/stuff.d.ts +2 -2
- package/build/runtime/cache/subscription.d.ts +19 -11
- package/build/runtime/client/documentStore.d.ts +87 -0
- package/build/runtime/client/index.d.ts +25 -0
- package/build/runtime/client/plugins/cache.d.ts +8 -0
- package/build/runtime/client/plugins/fetch.d.ts +37 -0
- package/build/runtime/client/plugins/fetchParams.d.ts +9 -0
- package/build/runtime/client/plugins/index.d.ts +7 -0
- package/build/runtime/client/plugins/injectedPlugins.d.ts +3 -0
- package/build/runtime/client/plugins/mutation.d.ts +1 -0
- package/build/runtime/client/plugins/query.d.ts +2 -0
- package/build/runtime/client/plugins/subscription.d.ts +18 -0
- package/build/runtime/client/plugins/throwOnError.d.ts +7 -0
- package/build/runtime/client/utils/documentPlugins.d.ts +3 -0
- package/build/runtime/client/utils/index.d.ts +1 -0
- package/build/runtime/generated.d.ts +1 -0
- package/build/runtime/imports/config.d.ts +3 -0
- package/build/runtime/index.d.ts +3 -2
- package/build/runtime/lib/config.d.ts +26 -25
- package/build/runtime/lib/index.d.ts +1 -2
- package/build/runtime/lib/scalars.d.ts +6 -5
- package/build/runtime/lib/selection.d.ts +1 -1
- package/build/runtime/lib/store.d.ts +19 -0
- package/build/runtime/lib/types.d.ts +22 -9
- package/build/runtime/public/cache.d.ts +20 -7
- package/build/runtime/public/list.d.ts +2 -2
- package/build/runtime/public/record.d.ts +18 -18
- package/build/runtime/public/tests/test.d.ts +44 -1
- package/build/runtime/public/types.d.ts +8 -0
- package/build/runtime-cjs/cache/cache.d.ts +10 -8
- package/build/runtime-cjs/cache/cache.js +5 -11
- package/build/runtime-cjs/cache/gc.d.ts +1 -1
- package/build/runtime-cjs/cache/lists.d.ts +3 -2
- package/build/runtime-cjs/cache/lists.js +5 -2
- package/build/runtime-cjs/cache/schema.d.ts +2 -2
- package/build/runtime-cjs/cache/stuff.d.ts +2 -2
- package/build/runtime-cjs/cache/subscription.d.ts +19 -11
- package/build/runtime-cjs/cache/subscription.js +95 -56
- package/build/runtime-cjs/client/documentStore.d.ts +87 -0
- package/build/runtime-cjs/client/documentStore.js +360 -0
- package/build/runtime-cjs/client/index.d.ts +25 -0
- package/build/runtime-cjs/client/index.js +87 -0
- package/build/runtime-cjs/client/plugins/cache.d.ts +8 -0
- package/build/runtime-cjs/client/plugins/cache.js +99 -0
- package/build/runtime-cjs/client/plugins/fetch.d.ts +37 -0
- package/build/runtime-cjs/{lib/networkUtils.js → client/plugins/fetch.js} +95 -3
- package/build/runtime-cjs/client/plugins/fetchParams.d.ts +9 -0
- package/build/runtime-cjs/client/plugins/fetchParams.js +40 -0
- package/build/runtime-cjs/client/plugins/index.d.ts +7 -0
- package/build/runtime-cjs/client/plugins/index.js +24 -0
- package/build/runtime-cjs/client/plugins/injectedPlugins.d.ts +3 -0
- package/build/runtime-cjs/{lib/errors.js → client/plugins/injectedPlugins.js} +7 -15
- package/build/runtime-cjs/client/plugins/mutation.d.ts +1 -0
- package/build/runtime-cjs/client/plugins/mutation.js +86 -0
- package/build/runtime-cjs/client/plugins/query.d.ts +2 -0
- package/build/runtime-cjs/client/plugins/query.js +83 -0
- package/build/runtime-cjs/client/plugins/subscription.d.ts +18 -0
- package/build/runtime-cjs/client/plugins/subscription.js +98 -0
- package/build/runtime-cjs/client/plugins/throwOnError.d.ts +7 -0
- package/build/runtime-cjs/client/plugins/throwOnError.js +47 -0
- package/build/runtime-cjs/client/utils/documentPlugins.d.ts +3 -0
- package/build/runtime-cjs/client/utils/documentPlugins.js +56 -0
- package/build/runtime-cjs/client/utils/index.d.ts +1 -0
- package/build/runtime-cjs/client/utils/index.js +18 -0
- package/build/runtime-cjs/generated.d.ts +1 -0
- package/build/runtime-cjs/imports/config.d.ts +3 -0
- package/build/runtime-cjs/imports/config.js +26 -0
- package/build/runtime-cjs/index.d.ts +3 -2
- package/build/runtime-cjs/index.js +1 -0
- package/build/runtime-cjs/lib/config.d.ts +26 -25
- package/build/runtime-cjs/lib/config.js +5 -4
- package/build/runtime-cjs/lib/index.d.ts +1 -2
- package/build/runtime-cjs/lib/index.js +1 -2
- package/build/runtime-cjs/lib/scalars.d.ts +6 -5
- package/build/runtime-cjs/lib/scalars.js +20 -24
- package/build/runtime-cjs/lib/selection.d.ts +1 -1
- package/build/runtime-cjs/lib/store.d.ts +19 -0
- package/build/runtime-cjs/lib/store.js +81 -0
- package/build/runtime-cjs/lib/types.d.ts +22 -9
- package/build/runtime-cjs/public/cache.d.ts +20 -7
- package/build/runtime-cjs/public/cache.js +29 -32
- package/build/runtime-cjs/public/list.d.ts +2 -2
- package/build/runtime-cjs/public/list.js +6 -28
- package/build/runtime-cjs/public/record.d.ts +18 -18
- package/build/runtime-cjs/public/record.js +23 -189
- package/build/runtime-cjs/public/tests/test.d.ts +44 -1
- package/build/runtime-cjs/public/tests/test.js +27 -2
- package/build/runtime-cjs/public/types.d.ts +8 -0
- package/build/runtime-esm/cache/cache.d.ts +10 -8
- package/build/runtime-esm/cache/cache.js +5 -11
- package/build/runtime-esm/cache/gc.d.ts +1 -1
- package/build/runtime-esm/cache/lists.d.ts +3 -2
- package/build/runtime-esm/cache/lists.js +5 -2
- package/build/runtime-esm/cache/schema.d.ts +2 -2
- package/build/runtime-esm/cache/stuff.d.ts +2 -2
- package/build/runtime-esm/cache/subscription.d.ts +19 -11
- package/build/runtime-esm/cache/subscription.js +95 -56
- package/build/runtime-esm/client/documentStore.d.ts +87 -0
- package/build/runtime-esm/client/documentStore.js +336 -0
- package/build/runtime-esm/client/index.d.ts +25 -0
- package/build/runtime-esm/client/index.js +58 -0
- package/build/runtime-esm/client/plugins/cache.d.ts +8 -0
- package/build/runtime-esm/client/plugins/cache.js +69 -0
- package/build/runtime-esm/client/plugins/fetch.d.ts +37 -0
- package/build/runtime-esm/client/plugins/fetch.js +151 -0
- package/build/runtime-esm/client/plugins/fetchParams.d.ts +9 -0
- package/build/runtime-esm/client/plugins/fetchParams.js +16 -0
- package/build/runtime-esm/client/plugins/index.d.ts +7 -0
- package/build/runtime-esm/client/plugins/index.js +7 -0
- package/build/runtime-esm/client/plugins/injectedPlugins.d.ts +3 -0
- package/build/runtime-esm/client/plugins/injectedPlugins.js +5 -0
- package/build/runtime-esm/client/plugins/mutation.d.ts +1 -0
- package/build/runtime-esm/client/plugins/mutation.js +56 -0
- package/build/runtime-esm/client/plugins/query.d.ts +2 -0
- package/build/runtime-esm/client/plugins/query.js +53 -0
- package/build/runtime-esm/client/plugins/subscription.d.ts +18 -0
- package/build/runtime-esm/client/plugins/subscription.js +74 -0
- package/build/runtime-esm/client/plugins/throwOnError.d.ts +7 -0
- package/build/runtime-esm/client/plugins/throwOnError.js +23 -0
- package/build/runtime-esm/client/utils/documentPlugins.d.ts +3 -0
- package/build/runtime-esm/client/utils/documentPlugins.js +32 -0
- package/build/runtime-esm/client/utils/index.d.ts +1 -0
- package/build/runtime-esm/client/utils/index.js +1 -0
- package/build/runtime-esm/generated.d.ts +1 -0
- package/build/runtime-esm/imports/config.d.ts +3 -0
- package/build/runtime-esm/imports/config.js +4 -0
- package/build/runtime-esm/index.d.ts +3 -2
- package/build/runtime-esm/index.js +1 -0
- package/build/runtime-esm/lib/config.d.ts +26 -25
- package/build/runtime-esm/lib/config.js +5 -4
- package/build/runtime-esm/lib/index.d.ts +1 -2
- package/build/runtime-esm/lib/index.js +1 -2
- package/build/runtime-esm/lib/scalars.d.ts +6 -5
- package/build/runtime-esm/lib/scalars.js +20 -24
- package/build/runtime-esm/lib/selection.d.ts +1 -1
- package/build/runtime-esm/lib/store.d.ts +19 -0
- package/build/runtime-esm/lib/store.js +57 -0
- package/build/runtime-esm/lib/types.d.ts +22 -9
- package/build/runtime-esm/public/cache.d.ts +20 -7
- package/build/runtime-esm/public/cache.js +28 -30
- package/build/runtime-esm/public/list.d.ts +2 -2
- package/build/runtime-esm/public/list.js +6 -28
- package/build/runtime-esm/public/record.d.ts +18 -18
- package/build/runtime-esm/public/record.js +22 -185
- package/build/runtime-esm/public/tests/test.d.ts +44 -1
- package/build/runtime-esm/public/tests/test.js +26 -1
- package/build/runtime-esm/public/types.d.ts +8 -0
- package/build/test/index.d.ts +4 -3
- package/build/test-cjs/index.js +1334 -2766
- package/build/test-esm/index.js +1334 -2766
- package/build/vite/ast.d.ts +1 -1
- package/build/vite/houdini.d.ts +1 -1
- package/build/vite/imports.d.ts +3 -3
- package/build/vite/index.d.ts +1 -1
- package/build/vite/schema.d.ts +1 -1
- package/build/vite-cjs/index.js +1395 -2821
- package/build/vite-esm/index.js +1395 -2821
- package/package.json +1 -1
- package/build/runtime/lib/errors.d.ts +0 -3
- package/build/runtime/lib/network.d.ts +0 -79
- package/build/runtime/lib/networkUtils.d.ts +0 -8
- package/build/runtime-cjs/lib/errors.d.ts +0 -3
- package/build/runtime-cjs/lib/network.d.ts +0 -79
- package/build/runtime-cjs/lib/network.js +0 -200
- package/build/runtime-cjs/lib/networkUtils.d.ts +0 -8
- package/build/runtime-esm/lib/errors.d.ts +0 -3
- package/build/runtime-esm/lib/errors.js +0 -11
- package/build/runtime-esm/lib/network.d.ts +0 -79
- package/build/runtime-esm/lib/network.js +0 -170
- package/build/runtime-esm/lib/networkUtils.d.ts +0 -8
- package/build/runtime-esm/lib/networkUtils.js +0 -60
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { rootID } from "../cache/cache";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { marshalInputs } from "../lib";
|
|
3
|
+
import { keyFieldsForType } from "../lib/config";
|
|
4
4
|
class Record {
|
|
5
5
|
#id;
|
|
6
6
|
#cache;
|
|
@@ -24,199 +24,36 @@ class Record {
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
value
|
|
27
|
+
read({
|
|
28
|
+
fragment,
|
|
29
|
+
variables
|
|
31
30
|
}) {
|
|
32
|
-
this.#cache.
|
|
33
|
-
|
|
34
|
-
const typeInfo = _typeInfo(this.#cache, this.type, field);
|
|
35
|
-
let newValue;
|
|
36
|
-
if (typeInfo.link) {
|
|
37
|
-
const keys = keyFieldsForType(this.#cache.config, typeInfo.type);
|
|
38
|
-
typeInfo.selection = {
|
|
39
|
-
fields: keys.reduce(
|
|
40
|
-
(acc, key2) => {
|
|
41
|
-
const keyInfo = _typeInfo(this.#cache, typeInfo.type, key2);
|
|
42
|
-
return {
|
|
43
|
-
...acc,
|
|
44
|
-
[key2]: {
|
|
45
|
-
type: keyInfo.type,
|
|
46
|
-
keyRaw: key2
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
__typename: {
|
|
52
|
-
type: "String",
|
|
53
|
-
keyRaw: "__typename"
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
)
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
if (!typeInfo.link) {
|
|
60
|
-
const fnMarshal = this.#cache.config.scalars?.[typeInfo.type]?.marshal;
|
|
61
|
-
if (fnMarshal) {
|
|
62
|
-
newValue = fnMarshal(value);
|
|
63
|
-
} else {
|
|
64
|
-
newValue = value;
|
|
65
|
-
}
|
|
66
|
-
} else if (value instanceof Record) {
|
|
67
|
-
newValue = {
|
|
68
|
-
...value.idFields,
|
|
69
|
-
__typename: value.type
|
|
70
|
-
};
|
|
71
|
-
} else if (Array.isArray(value)) {
|
|
72
|
-
newValue = marshalNestedList(value);
|
|
73
|
-
} else if (value !== null) {
|
|
74
|
-
throw new Error("Value must be a RecordProxy if the field is a link to another record");
|
|
75
|
-
}
|
|
76
|
-
this.#cache._internal_unstable._internal_unstable.lifetimes.resetLifetime(this.#id, key);
|
|
77
|
-
this.#cache._internal_unstable.write({
|
|
31
|
+
return this.#cache._internal_unstable.read({
|
|
32
|
+
selection: fragment.artifact.selection,
|
|
78
33
|
parent: this.#id,
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
data: {
|
|
88
|
-
[field]: newValue
|
|
89
|
-
}
|
|
34
|
+
variables: marshalInputs({
|
|
35
|
+
config: this.#cache.config,
|
|
36
|
+
artifact: fragment.artifact,
|
|
37
|
+
input: variables
|
|
38
|
+
}) ?? void 0
|
|
90
39
|
});
|
|
91
40
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
this.#cache.validateInstabilityWarning();
|
|
97
|
-
const key = computeKey({ field, args });
|
|
98
|
-
const typeInfo = _typeInfo(this.#cache, this.type, field);
|
|
99
|
-
if (typeInfo.link) {
|
|
100
|
-
const keys = keyFieldsForType(this.#cache.config, typeInfo.type);
|
|
101
|
-
typeInfo.selection = {
|
|
102
|
-
fields: keys.reduce(
|
|
103
|
-
(acc, key2) => {
|
|
104
|
-
const keyInfo = _typeInfo(this.#cache, typeInfo.type, key2);
|
|
105
|
-
return {
|
|
106
|
-
...acc,
|
|
107
|
-
[key2]: {
|
|
108
|
-
type: keyInfo.type,
|
|
109
|
-
keyRaw: key2
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
__typename: {
|
|
115
|
-
type: "String",
|
|
116
|
-
keyRaw: "__typename"
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
)
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
const result = this.#cache._internal_unstable.read({
|
|
41
|
+
write(args) {
|
|
42
|
+
this.#cache._internal_unstable.write({
|
|
43
|
+
data: args.data,
|
|
44
|
+
selection: args.fragment.artifact.selection,
|
|
123
45
|
parent: this.#id,
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
46
|
+
variables: marshalInputs({
|
|
47
|
+
config: this.#cache.config,
|
|
48
|
+
artifact: args.fragment.artifact,
|
|
49
|
+
input: args.variables
|
|
50
|
+
}) ?? void 0
|
|
132
51
|
});
|
|
133
|
-
if (!typeInfo.link) {
|
|
134
|
-
return result.data?.[field] ?? (typeInfo.nullable ? null : void 0);
|
|
135
|
-
}
|
|
136
|
-
const data = result.data?.[field] || {};
|
|
137
|
-
let finalResult = unmarshalNestedList(
|
|
138
|
-
this.#cache,
|
|
139
|
-
!Array.isArray(data) ? [data] : data
|
|
140
|
-
).map((val) => {
|
|
141
|
-
if (typeInfo.nullable && (val === null || Object.keys(val).length === 0)) {
|
|
142
|
-
return null;
|
|
143
|
-
}
|
|
144
|
-
return val;
|
|
145
|
-
});
|
|
146
|
-
return Array.isArray(data) ? finalResult : finalResult[0];
|
|
147
52
|
}
|
|
148
53
|
delete() {
|
|
149
54
|
this.#cache._internal_unstable.delete(this.#id);
|
|
150
55
|
}
|
|
151
56
|
}
|
|
152
|
-
function computeKey({ field, args }) {
|
|
153
|
-
const keys = Object.keys(args ?? {});
|
|
154
|
-
keys.sort();
|
|
155
|
-
return args && keys.length > 0 ? `${field}(${keys.map((key) => `${key}: ${stringifyObjectWithNoQuotesOnKeys(args[key])}`).join(", ")})` : field;
|
|
156
|
-
}
|
|
157
|
-
const stringifyObjectWithNoQuotesOnKeys = (obj_from_json) => {
|
|
158
|
-
if (Array.isArray(obj_from_json)) {
|
|
159
|
-
return `[${obj_from_json.map((obj) => `${stringifyObjectWithNoQuotesOnKeys(obj)}`).join(", ")}]`;
|
|
160
|
-
}
|
|
161
|
-
if (typeof obj_from_json !== "object" || obj_from_json instanceof Date || obj_from_json === null) {
|
|
162
|
-
return JSON.stringify(obj_from_json).replace(/"([^"]+)":/g, "$1: ");
|
|
163
|
-
}
|
|
164
|
-
return `{${Object.keys(obj_from_json).map((key) => `${key}: ${stringifyObjectWithNoQuotesOnKeys(obj_from_json[key])}`).join(", ")}}`;
|
|
165
|
-
};
|
|
166
|
-
function marshalNestedList(list) {
|
|
167
|
-
const newValue = [];
|
|
168
|
-
for (const inner of list) {
|
|
169
|
-
if (Array.isArray(inner)) {
|
|
170
|
-
newValue.push(marshalNestedList(inner));
|
|
171
|
-
} else if (inner instanceof Record) {
|
|
172
|
-
newValue.push({ ...inner.idFields, __typename: inner.type });
|
|
173
|
-
} else {
|
|
174
|
-
newValue.push(inner);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
return newValue;
|
|
178
|
-
}
|
|
179
|
-
function unmarshalNestedList(cache, list) {
|
|
180
|
-
const newValue = [];
|
|
181
|
-
for (const inner of list) {
|
|
182
|
-
if (Array.isArray(inner)) {
|
|
183
|
-
newValue.push(unmarshalNestedList(cache, inner));
|
|
184
|
-
} else if (inner === null) {
|
|
185
|
-
newValue.push(null);
|
|
186
|
-
} else if (inner.__typename) {
|
|
187
|
-
const type = inner.__typename;
|
|
188
|
-
let recordID = cache._internal_unstable._internal_unstable.id(type, inner);
|
|
189
|
-
if (!recordID) {
|
|
190
|
-
throw new Error("todo");
|
|
191
|
-
}
|
|
192
|
-
const typename = cache._internal_unstable.read({
|
|
193
|
-
selection: {
|
|
194
|
-
fields: {
|
|
195
|
-
__typename: {
|
|
196
|
-
keyRaw: "__typename",
|
|
197
|
-
type: "String"
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
},
|
|
201
|
-
parent: recordID
|
|
202
|
-
}).data?.__typename;
|
|
203
|
-
newValue.push(
|
|
204
|
-
new Record({
|
|
205
|
-
cache,
|
|
206
|
-
type: type || typename,
|
|
207
|
-
idFields: inner,
|
|
208
|
-
id: recordID
|
|
209
|
-
})
|
|
210
|
-
);
|
|
211
|
-
} else {
|
|
212
|
-
newValue.push(inner);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
return newValue;
|
|
216
|
-
}
|
|
217
57
|
export {
|
|
218
|
-
Record
|
|
219
|
-
computeKey,
|
|
220
|
-
marshalNestedList,
|
|
221
|
-
stringifyObjectWithNoQuotesOnKeys
|
|
58
|
+
Record
|
|
222
59
|
};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { type SubscriptionSelection, type FragmentArtifact, type QueryArtifact } from '../../lib';
|
|
1
2
|
import { Cache } from '../cache';
|
|
2
|
-
import { Record } from '../record';
|
|
3
|
+
import type { Record } from '../record';
|
|
3
4
|
type CacheTypeDef = {
|
|
4
5
|
types: {
|
|
5
6
|
__ROOT__: {
|
|
6
7
|
idFields: {};
|
|
8
|
+
fragments: [];
|
|
7
9
|
fields: {
|
|
8
10
|
test: {
|
|
9
11
|
type: number | null;
|
|
@@ -39,6 +41,19 @@ type CacheTypeDef = {
|
|
|
39
41
|
idFields: {
|
|
40
42
|
id: string;
|
|
41
43
|
};
|
|
44
|
+
fragments: [
|
|
45
|
+
[
|
|
46
|
+
{
|
|
47
|
+
artifact: FragmentArtifact;
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
firstName: string;
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
pattern: string;
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
];
|
|
42
57
|
fields: {
|
|
43
58
|
firstName: {
|
|
44
59
|
type: string;
|
|
@@ -62,6 +77,7 @@ type CacheTypeDef = {
|
|
|
62
77
|
idFields: {
|
|
63
78
|
id: string;
|
|
64
79
|
};
|
|
80
|
+
fragments: [];
|
|
65
81
|
fields: {
|
|
66
82
|
name: {
|
|
67
83
|
type: string | null;
|
|
@@ -85,6 +101,7 @@ type CacheTypeDef = {
|
|
|
85
101
|
idFields: {
|
|
86
102
|
id: string;
|
|
87
103
|
};
|
|
104
|
+
fragments: [];
|
|
88
105
|
fields: {
|
|
89
106
|
name: {
|
|
90
107
|
type: string | null;
|
|
@@ -97,6 +114,26 @@ type CacheTypeDef = {
|
|
|
97
114
|
};
|
|
98
115
|
};
|
|
99
116
|
};
|
|
117
|
+
queries: [
|
|
118
|
+
[
|
|
119
|
+
{
|
|
120
|
+
artifact: QueryArtifact;
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
viewer: {
|
|
124
|
+
id: string;
|
|
125
|
+
firstName: string;
|
|
126
|
+
__typename: string;
|
|
127
|
+
parent: {
|
|
128
|
+
id: string;
|
|
129
|
+
firstName: string;
|
|
130
|
+
__typename: string;
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
},
|
|
134
|
+
any
|
|
135
|
+
]
|
|
136
|
+
];
|
|
100
137
|
lists: {
|
|
101
138
|
All_Pets: {
|
|
102
139
|
types: 'User' | 'Cat';
|
|
@@ -111,4 +148,10 @@ type CacheTypeDef = {
|
|
|
111
148
|
};
|
|
112
149
|
};
|
|
113
150
|
export declare const testCache: () => Cache<CacheTypeDef>;
|
|
151
|
+
export declare const testFragment: (selection: SubscriptionSelection) => {
|
|
152
|
+
artifact: FragmentArtifact;
|
|
153
|
+
};
|
|
154
|
+
export declare const testQuery: (selection: SubscriptionSelection) => {
|
|
155
|
+
artifact: QueryArtifact;
|
|
156
|
+
};
|
|
114
157
|
export {};
|
|
@@ -1,7 +1,32 @@
|
|
|
1
1
|
import { testConfigFile } from "../../../test";
|
|
2
2
|
import { Cache as _Cache } from "../../cache/cache";
|
|
3
|
+
import {
|
|
4
|
+
ArtifactKind
|
|
5
|
+
} from "../../lib";
|
|
3
6
|
import { Cache } from "../cache";
|
|
4
7
|
const testCache = () => new Cache(new _Cache(testConfigFile()));
|
|
8
|
+
const testFragment = (selection) => ({
|
|
9
|
+
artifact: {
|
|
10
|
+
kind: ArtifactKind.Fragment,
|
|
11
|
+
hash: "",
|
|
12
|
+
raw: "",
|
|
13
|
+
name: "",
|
|
14
|
+
rootType: "User",
|
|
15
|
+
selection
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
const testQuery = (selection) => ({
|
|
19
|
+
artifact: {
|
|
20
|
+
kind: ArtifactKind.Query,
|
|
21
|
+
hash: "",
|
|
22
|
+
raw: "",
|
|
23
|
+
name: "",
|
|
24
|
+
rootType: "Query",
|
|
25
|
+
selection
|
|
26
|
+
}
|
|
27
|
+
});
|
|
5
28
|
export {
|
|
6
|
-
testCache
|
|
29
|
+
testCache,
|
|
30
|
+
testFragment,
|
|
31
|
+
testQuery
|
|
7
32
|
};
|
|
@@ -11,6 +11,7 @@ export type CacheTypeDef = {
|
|
|
11
11
|
type: any;
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
|
+
fragments: [any, any, any][];
|
|
14
15
|
};
|
|
15
16
|
};
|
|
16
17
|
lists: {
|
|
@@ -19,11 +20,14 @@ export type CacheTypeDef = {
|
|
|
19
20
|
filters: any;
|
|
20
21
|
};
|
|
21
22
|
};
|
|
23
|
+
queries: [any, any, any][];
|
|
22
24
|
};
|
|
23
25
|
export type ValidTypes<Def extends CacheTypeDef> = keyof Def['types'];
|
|
24
26
|
export type TypeFields<Def extends CacheTypeDef, Type extends keyof Def['types']> = Def['types'][Type]['fields'];
|
|
25
27
|
export type TypeFieldNames<Def extends CacheTypeDef, Type extends keyof Def['types']> = Extract<keyof TypeFields<Def, Type>, string>;
|
|
26
28
|
export type TypeNames<Def extends CacheTypeDef> = Extract<Exclude<ValidTypes<Def>, '__ROOT__'>, string>;
|
|
29
|
+
export type FragmentList<Def extends CacheTypeDef, Type extends ValidTypes<Def>> = Def['types'][Type]['fragments'];
|
|
30
|
+
export type QueryList<Def extends CacheTypeDef> = Def['queries'];
|
|
27
31
|
export type IDFields<Def extends CacheTypeDef, Type extends keyof Def['types']> = Def['types'][Type]['idFields'];
|
|
28
32
|
export type ProxyUnion<Def extends CacheTypeDef, U> = U extends null ? null : U extends TypeNames<Def> ? Record<Def, U> : never;
|
|
29
33
|
export type FieldType<Def extends CacheTypeDef, Type extends keyof Def['types'], Field extends keyof TypeFields<Def, Type>> = TypeFields<Def, Type>[Field]['type'];
|
|
@@ -34,3 +38,7 @@ export type ListFilters<Def extends CacheTypeDef, ListName extends ValidLists<De
|
|
|
34
38
|
must_not?: Def['lists'][ListName]['filters'];
|
|
35
39
|
} : never;
|
|
36
40
|
export type ListType<Def extends CacheTypeDef, Name extends ValidLists<Def>> = ProxyUnion<Def, Def['lists'][Name]['types']>;
|
|
41
|
+
export type FragmentVariables<_List, _Target> = _List extends [infer Head, ...infer Rest] ? Head extends [infer _Key, infer _Value, infer _Input] ? _Key extends _Target ? _Input : FragmentValue<Rest, _Target> : 'Encountered unknown fragment. Please make sure your runtime is up to date (ie, `vite dev` or `vite build`).' : 'Encountered unknown fragment. Please make sure your runtime is up to date (ie, `vite dev` or `vite build`).';
|
|
42
|
+
export type FragmentValue<List, _Target> = List extends [infer Head, ...infer Rest] ? Head extends [infer _Key, infer _Value, infer _Input] ? _Key extends _Target ? _Value : FragmentValue<Rest, _Target> : 'Encountered unknown fragment. Please make sure your runtime is up to date (ie, `vite dev` or `vite build`).' : 'Encountered unknown fragment. Please make sure your runtime is up to date (ie, `vite dev` or `vite build`).';
|
|
43
|
+
export type QueryValue<List, _Target> = List extends [infer Head, ...infer Rest] ? Head extends [infer _Key, infer _Value, infer _Input] ? _Key extends _Target ? _Value : QueryValue<Rest, _Target> : 'Encountered unknown query.Please make sure your runtime is up to date (ie, `vite dev` or `vite build`).' : 'Encountered unknown query.Please make sure your runtime is up to date (ie, `vite dev` or `vite build`).';
|
|
44
|
+
export type QueryInput<List, _Target> = List extends [infer Head, ...infer Rest] ? Head extends [infer _Key, infer _Value, infer _Input] ? _Key extends _Target ? _Input : QueryValue<Rest, _Target> : 'Encountered unknown query.Please make sure your runtime is up to date (ie, `vite dev` or `vite build`).' : 'Encountered unknown query.Please make sure your runtime is up to date (ie, `vite dev` or `vite build`).';
|
package/build/test/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import type { CollectedGraphQLDocument } from '../lib';
|
|
2
|
+
import { Config } from '../lib';
|
|
3
|
+
import type { ConfigFile } from '../runtime/lib/config';
|
|
4
|
+
export declare function testConfigFile({ plugins, ...config }?: Partial<ConfigFile>): ConfigFile;
|
|
4
5
|
export declare function testConfig(config?: Partial<ConfigFile>): Config;
|
|
5
6
|
export type Partial<T> = {
|
|
6
7
|
[P in keyof T]?: T[P];
|