houdini 0.17.14 → 0.18.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/build/cmd-cjs/index.js +442 -203
- package/build/cmd-esm/index.js +442 -203
- package/build/codegen/utils/flattenSelections.d.ts +3 -1
- package/build/codegen-cjs/index.js +409 -182
- package/build/codegen-esm/index.js +409 -182
- package/build/lib/config.d.ts +8 -3
- package/build/lib-cjs/index.js +145 -83
- package/build/lib-esm/index.js +145 -83
- package/build/runtime/cache/subscription.d.ts +3 -3
- package/build/runtime/lib/config.d.ts +2 -1
- package/build/runtime/lib/scalars.d.ts +2 -2
- package/build/runtime/lib/selection.d.ts +2 -0
- package/build/runtime/lib/types.d.ts +26 -16
- package/build/runtime-cjs/cache/cache.js +42 -25
- package/build/runtime-cjs/cache/lists.js +40 -26
- package/build/runtime-cjs/cache/subscription.d.ts +3 -3
- package/build/runtime-cjs/cache/subscription.js +23 -21
- package/build/runtime-cjs/lib/config.d.ts +2 -1
- package/build/runtime-cjs/lib/scalars.d.ts +2 -2
- package/build/runtime-cjs/lib/scalars.js +9 -6
- package/build/runtime-cjs/lib/selection.d.ts +2 -0
- package/build/runtime-cjs/lib/selection.js +39 -0
- package/build/runtime-cjs/lib/types.d.ts +26 -16
- package/build/runtime-esm/cache/cache.js +42 -25
- package/build/runtime-esm/cache/lists.js +40 -26
- package/build/runtime-esm/cache/subscription.d.ts +3 -3
- package/build/runtime-esm/cache/subscription.js +23 -21
- package/build/runtime-esm/lib/config.d.ts +2 -1
- package/build/runtime-esm/lib/scalars.d.ts +2 -2
- package/build/runtime-esm/lib/scalars.js +9 -6
- package/build/runtime-esm/lib/selection.d.ts +2 -0
- package/build/runtime-esm/lib/selection.js +15 -0
- package/build/runtime-esm/lib/types.d.ts +26 -16
- package/build/test/index.d.ts +1 -2
- package/build/test-cjs/index.js +489 -197
- package/build/test-esm/index.js +489 -197
- package/build/vite-cjs/index.js +442 -195
- package/build/vite-esm/index.js +442 -195
- package/package.json +3 -3
- package/build/runtime-cjs/cache/tests/availability.test.js +0 -357
- package/build/runtime-cjs/cache/tests/gc.test.js +0 -271
- package/build/runtime-cjs/cache/tests/keys.test.js +0 -34
- package/build/runtime-cjs/cache/tests/list.test.js +0 -3390
- package/build/runtime-cjs/cache/tests/readwrite.test.js +0 -1076
- package/build/runtime-cjs/cache/tests/scalars.test.js +0 -181
- package/build/runtime-cjs/cache/tests/storage.test.js +0 -280
- package/build/runtime-cjs/cache/tests/subscriptions.test.js +0 -1469
- package/build/runtime-cjs/lib/scalars.test.js +0 -736
- package/build/runtime-esm/cache/tests/availability.test.js +0 -356
- package/build/runtime-esm/cache/tests/gc.test.js +0 -270
- package/build/runtime-esm/cache/tests/keys.test.js +0 -33
- package/build/runtime-esm/cache/tests/list.test.js +0 -3389
- package/build/runtime-esm/cache/tests/readwrite.test.js +0 -1075
- package/build/runtime-esm/cache/tests/scalars.test.js +0 -180
- package/build/runtime-esm/cache/tests/storage.test.js +0 -279
- package/build/runtime-esm/cache/tests/subscriptions.test.js +0 -1468
- package/build/runtime-esm/lib/scalars.test.js +0 -735
package/build/lib-esm/index.js
CHANGED
|
@@ -60947,6 +60947,20 @@ function deepEquals(objA, objB, map = /* @__PURE__ */ new WeakMap()) {
|
|
|
60947
60947
|
return true;
|
|
60948
60948
|
}
|
|
60949
60949
|
|
|
60950
|
+
// src/runtime/lib/selection.ts
|
|
60951
|
+
function getFieldsForType(selection, __typename) {
|
|
60952
|
+
let targetSelection = selection.fields || {};
|
|
60953
|
+
if (selection.abstractFields && __typename) {
|
|
60954
|
+
const mappedType = selection.abstractFields.typeMap[__typename];
|
|
60955
|
+
if (mappedType) {
|
|
60956
|
+
targetSelection = selection.abstractFields.fields[mappedType];
|
|
60957
|
+
} else if (selection.abstractFields.fields[__typename]) {
|
|
60958
|
+
targetSelection = selection.abstractFields.fields[__typename];
|
|
60959
|
+
}
|
|
60960
|
+
}
|
|
60961
|
+
return targetSelection;
|
|
60962
|
+
}
|
|
60963
|
+
|
|
60950
60964
|
// src/runtime/cache/gc.ts
|
|
60951
60965
|
var GarbageCollector = class {
|
|
60952
60966
|
cache;
|
|
@@ -61169,23 +61183,32 @@ var List = class {
|
|
|
61169
61183
|
let insertData = data;
|
|
61170
61184
|
if (this.connection) {
|
|
61171
61185
|
insertSelection = {
|
|
61172
|
-
|
|
61173
|
-
|
|
61174
|
-
|
|
61175
|
-
|
|
61176
|
-
|
|
61177
|
-
keyRaw: "edges",
|
|
61178
|
-
type: "ConnectionEdge",
|
|
61179
|
-
update: where === "first" ? "prepend" : "append",
|
|
61186
|
+
fields: {
|
|
61187
|
+
newEntry: {
|
|
61188
|
+
keyRaw: this.key,
|
|
61189
|
+
type: "Connection",
|
|
61190
|
+
selection: {
|
|
61180
61191
|
fields: {
|
|
61181
|
-
|
|
61182
|
-
|
|
61183
|
-
|
|
61184
|
-
|
|
61185
|
-
|
|
61186
|
-
|
|
61187
|
-
|
|
61188
|
-
|
|
61192
|
+
edges: {
|
|
61193
|
+
keyRaw: "edges",
|
|
61194
|
+
type: "ConnectionEdge",
|
|
61195
|
+
update: where === "first" ? "prepend" : "append",
|
|
61196
|
+
selection: {
|
|
61197
|
+
fields: {
|
|
61198
|
+
node: {
|
|
61199
|
+
type: listType,
|
|
61200
|
+
keyRaw: "node",
|
|
61201
|
+
selection: {
|
|
61202
|
+
...selection,
|
|
61203
|
+
fields: {
|
|
61204
|
+
...selection.fields,
|
|
61205
|
+
__typename: {
|
|
61206
|
+
keyRaw: "__typename",
|
|
61207
|
+
type: "String"
|
|
61208
|
+
}
|
|
61209
|
+
}
|
|
61210
|
+
}
|
|
61211
|
+
}
|
|
61189
61212
|
}
|
|
61190
61213
|
}
|
|
61191
61214
|
}
|
|
@@ -61201,15 +61224,20 @@ var List = class {
|
|
|
61201
61224
|
};
|
|
61202
61225
|
} else {
|
|
61203
61226
|
insertSelection = {
|
|
61204
|
-
|
|
61205
|
-
|
|
61206
|
-
|
|
61207
|
-
|
|
61208
|
-
|
|
61209
|
-
|
|
61210
|
-
|
|
61211
|
-
|
|
61212
|
-
|
|
61227
|
+
fields: {
|
|
61228
|
+
newEntries: {
|
|
61229
|
+
keyRaw: this.key,
|
|
61230
|
+
type: listType,
|
|
61231
|
+
update: where === "first" ? "prepend" : "append",
|
|
61232
|
+
selection: {
|
|
61233
|
+
...selection,
|
|
61234
|
+
fields: {
|
|
61235
|
+
...selection.fields,
|
|
61236
|
+
__typename: {
|
|
61237
|
+
keyRaw: "__typename",
|
|
61238
|
+
type: "String"
|
|
61239
|
+
}
|
|
61240
|
+
}
|
|
61213
61241
|
}
|
|
61214
61242
|
}
|
|
61215
61243
|
}
|
|
@@ -61269,7 +61297,7 @@ var List = class {
|
|
|
61269
61297
|
const subscribers = this.cache._internal_unstable.subscriptions.get(this.recordID, this.key);
|
|
61270
61298
|
this.cache._internal_unstable.subscriptions.remove(
|
|
61271
61299
|
targetID,
|
|
61272
|
-
this.connection ? this.selection.edges.
|
|
61300
|
+
this.connection ? this.selection.fields.edges.selection : this.selection,
|
|
61273
61301
|
subscribers,
|
|
61274
61302
|
variables
|
|
61275
61303
|
);
|
|
@@ -61758,18 +61786,20 @@ var InMemorySubscriptions = class {
|
|
|
61758
61786
|
variables,
|
|
61759
61787
|
parentType
|
|
61760
61788
|
}) {
|
|
61761
|
-
|
|
61762
|
-
|
|
61789
|
+
const __typename = this.cache._internal_unstable.storage.get(parent, "__typename").value;
|
|
61790
|
+
let targetSelection = getFieldsForType(selection, __typename);
|
|
61791
|
+
for (const fieldSelection of Object.values(targetSelection || {})) {
|
|
61792
|
+
const { keyRaw, selection: innerSelection, type } = fieldSelection;
|
|
61763
61793
|
const key = evaluateKey(keyRaw, variables);
|
|
61764
61794
|
this.addFieldSubscription({
|
|
61765
61795
|
id: parent,
|
|
61766
61796
|
key,
|
|
61767
|
-
|
|
61797
|
+
field: fieldSelection,
|
|
61768
61798
|
spec,
|
|
61769
61799
|
parentType: parentType || spec.rootType,
|
|
61770
61800
|
variables
|
|
61771
61801
|
});
|
|
61772
|
-
if (
|
|
61802
|
+
if (innerSelection) {
|
|
61773
61803
|
const { value: linkedRecord } = this.cache._internal_unstable.storage.get(
|
|
61774
61804
|
parent,
|
|
61775
61805
|
key
|
|
@@ -61782,7 +61812,7 @@ var InMemorySubscriptions = class {
|
|
|
61782
61812
|
this.add({
|
|
61783
61813
|
parent: child,
|
|
61784
61814
|
spec,
|
|
61785
|
-
selection:
|
|
61815
|
+
selection: innerSelection,
|
|
61786
61816
|
variables,
|
|
61787
61817
|
parentType: type
|
|
61788
61818
|
});
|
|
@@ -61793,7 +61823,7 @@ var InMemorySubscriptions = class {
|
|
|
61793
61823
|
addFieldSubscription({
|
|
61794
61824
|
id,
|
|
61795
61825
|
key,
|
|
61796
|
-
|
|
61826
|
+
field,
|
|
61797
61827
|
spec,
|
|
61798
61828
|
parentType,
|
|
61799
61829
|
variables
|
|
@@ -61820,8 +61850,8 @@ var InMemorySubscriptions = class {
|
|
|
61820
61850
|
const counts = this.referenceCounts[id][key];
|
|
61821
61851
|
counts.set(spec.set, (counts.get(spec.set) || 0) + 1);
|
|
61822
61852
|
this.cache._internal_unstable.lifetimes.resetLifetime(id, key);
|
|
61823
|
-
const {
|
|
61824
|
-
if (
|
|
61853
|
+
const { selection, list, filters } = field;
|
|
61854
|
+
if (selection && list) {
|
|
61825
61855
|
this.cache._internal_unstable.lists.add({
|
|
61826
61856
|
name: list.name,
|
|
61827
61857
|
connection: list.connection,
|
|
@@ -61829,7 +61859,7 @@ var InMemorySubscriptions = class {
|
|
|
61829
61859
|
recordType: this.cache._internal_unstable.storage.get(id, "__typename")?.value || parentType,
|
|
61830
61860
|
listType: list.type,
|
|
61831
61861
|
key,
|
|
61832
|
-
selection
|
|
61862
|
+
selection,
|
|
61833
61863
|
filters: Object.entries(filters || {}).reduce((acc, [key2, { kind, value }]) => {
|
|
61834
61864
|
return {
|
|
61835
61865
|
...acc,
|
|
@@ -61846,20 +61876,21 @@ var InMemorySubscriptions = class {
|
|
|
61846
61876
|
subscribers,
|
|
61847
61877
|
parentType
|
|
61848
61878
|
}) {
|
|
61849
|
-
|
|
61850
|
-
|
|
61879
|
+
let targetSelection = getFieldsForType(selection, parentType);
|
|
61880
|
+
for (const fieldSelection of Object.values(targetSelection)) {
|
|
61881
|
+
const { type: linkedType, keyRaw, selection: innerSelection } = fieldSelection;
|
|
61851
61882
|
const key = evaluateKey(keyRaw, variables);
|
|
61852
61883
|
for (const spec of subscribers) {
|
|
61853
61884
|
this.addFieldSubscription({
|
|
61854
61885
|
id: parent,
|
|
61855
61886
|
key,
|
|
61856
|
-
|
|
61887
|
+
field: fieldSelection,
|
|
61857
61888
|
spec,
|
|
61858
61889
|
parentType,
|
|
61859
61890
|
variables
|
|
61860
61891
|
});
|
|
61861
61892
|
}
|
|
61862
|
-
if (
|
|
61893
|
+
if (innerSelection) {
|
|
61863
61894
|
const { value: link } = this.cache._internal_unstable.storage.get(parent, key);
|
|
61864
61895
|
const children = !Array.isArray(link) ? [link] : flattenList(link);
|
|
61865
61896
|
for (const linkedRecord of children) {
|
|
@@ -61868,7 +61899,7 @@ var InMemorySubscriptions = class {
|
|
|
61868
61899
|
}
|
|
61869
61900
|
this.addMany({
|
|
61870
61901
|
parent: linkedRecord,
|
|
61871
|
-
selection:
|
|
61902
|
+
selection: innerSelection,
|
|
61872
61903
|
variables,
|
|
61873
61904
|
subscribers,
|
|
61874
61905
|
parentType: linkedType
|
|
@@ -61880,22 +61911,20 @@ var InMemorySubscriptions = class {
|
|
|
61880
61911
|
get(id, field) {
|
|
61881
61912
|
return this.subscribers[id]?.[field] || [];
|
|
61882
61913
|
}
|
|
61883
|
-
remove(id,
|
|
61914
|
+
remove(id, selection, targets, variables, visited = []) {
|
|
61884
61915
|
visited.push(id);
|
|
61885
61916
|
const linkedIDs = [];
|
|
61886
|
-
for (const
|
|
61887
|
-
const key = evaluateKey(
|
|
61917
|
+
for (const fieldSelection of Object.values(selection.fields || {})) {
|
|
61918
|
+
const key = evaluateKey(fieldSelection.keyRaw, variables);
|
|
61888
61919
|
this.removeSubscribers(id, key, targets);
|
|
61889
|
-
if (!selection
|
|
61920
|
+
if (!fieldSelection.selection?.fields) {
|
|
61890
61921
|
continue;
|
|
61891
61922
|
}
|
|
61892
|
-
if (selection.list) {
|
|
61893
|
-
}
|
|
61894
61923
|
const { value: previousValue } = this.cache._internal_unstable.storage.get(id, key);
|
|
61895
61924
|
const links = !Array.isArray(previousValue) ? [previousValue] : flattenList(previousValue);
|
|
61896
61925
|
for (const link of links) {
|
|
61897
61926
|
if (link !== null) {
|
|
61898
|
-
linkedIDs.push([link, selection
|
|
61927
|
+
linkedIDs.push([link, fieldSelection.selection || {}]);
|
|
61899
61928
|
}
|
|
61900
61929
|
}
|
|
61901
61930
|
}
|
|
@@ -62050,10 +62079,12 @@ var CacheInternal = class {
|
|
|
62050
62079
|
this.lists = lists;
|
|
62051
62080
|
this.cache = cache;
|
|
62052
62081
|
this.lifetimes = lifetimes;
|
|
62082
|
+
this._disabled = typeof globalThis.window === "undefined";
|
|
62053
62083
|
try {
|
|
62054
|
-
|
|
62084
|
+
if (process.env.HOUDINI_TEST === "true") {
|
|
62085
|
+
this._disabled = false;
|
|
62086
|
+
}
|
|
62055
62087
|
} catch {
|
|
62056
|
-
this._disabled = typeof globalThis.window === "undefined";
|
|
62057
62088
|
}
|
|
62058
62089
|
}
|
|
62059
62090
|
setConfig(config) {
|
|
@@ -62073,8 +62104,9 @@ var CacheInternal = class {
|
|
|
62073
62104
|
if (this._disabled) {
|
|
62074
62105
|
return [];
|
|
62075
62106
|
}
|
|
62107
|
+
let targetSelection = getFieldsForType(selection, data["__typename"]);
|
|
62076
62108
|
for (const [field, value] of Object.entries(data)) {
|
|
62077
|
-
if (!selection || !
|
|
62109
|
+
if (!selection || !targetSelection[field]) {
|
|
62078
62110
|
throw new Error(
|
|
62079
62111
|
"Could not find field listing in selection for " + field + " @ " + JSON.stringify(selection)
|
|
62080
62112
|
);
|
|
@@ -62082,11 +62114,11 @@ var CacheInternal = class {
|
|
|
62082
62114
|
let {
|
|
62083
62115
|
type: linkedType,
|
|
62084
62116
|
keyRaw,
|
|
62085
|
-
|
|
62117
|
+
selection: fieldSelection,
|
|
62086
62118
|
operations,
|
|
62087
62119
|
abstract: isAbstract,
|
|
62088
62120
|
update
|
|
62089
|
-
} =
|
|
62121
|
+
} = targetSelection[field];
|
|
62090
62122
|
const key = evaluateKey(keyRaw, variables);
|
|
62091
62123
|
const currentSubscribers = this.subscriptions.get(parent, key);
|
|
62092
62124
|
const { value: previousValue, displayLayers } = this.storage.get(parent, key);
|
|
@@ -62094,7 +62126,7 @@ var CacheInternal = class {
|
|
|
62094
62126
|
if (displayLayer) {
|
|
62095
62127
|
this.lifetimes.resetLifetime(parent, key);
|
|
62096
62128
|
}
|
|
62097
|
-
if (!
|
|
62129
|
+
if (!fieldSelection) {
|
|
62098
62130
|
let newValue = value;
|
|
62099
62131
|
if (Array.isArray(value) && applyUpdates && update) {
|
|
62100
62132
|
if (update === "append") {
|
|
@@ -62114,7 +62146,7 @@ var CacheInternal = class {
|
|
|
62114
62146
|
}
|
|
62115
62147
|
const previousLinks = flattenList([previousValue]);
|
|
62116
62148
|
for (const link of previousLinks) {
|
|
62117
|
-
this.subscriptions.remove(link,
|
|
62149
|
+
this.subscriptions.remove(link, fieldSelection, currentSubscribers, variables);
|
|
62118
62150
|
}
|
|
62119
62151
|
layer.writeLink(parent, key, null);
|
|
62120
62152
|
toNotify.push(...currentSubscribers);
|
|
@@ -62140,14 +62172,14 @@ var CacheInternal = class {
|
|
|
62140
62172
|
if (previousValue && typeof previousValue === "string") {
|
|
62141
62173
|
this.subscriptions.remove(
|
|
62142
62174
|
previousValue,
|
|
62143
|
-
|
|
62175
|
+
fieldSelection,
|
|
62144
62176
|
currentSubscribers,
|
|
62145
62177
|
variables
|
|
62146
62178
|
);
|
|
62147
62179
|
}
|
|
62148
62180
|
this.subscriptions.addMany({
|
|
62149
62181
|
parent: linkedID,
|
|
62150
|
-
selection:
|
|
62182
|
+
selection: fieldSelection,
|
|
62151
62183
|
subscribers: currentSubscribers,
|
|
62152
62184
|
variables,
|
|
62153
62185
|
parentType: linkedType
|
|
@@ -62157,14 +62189,14 @@ var CacheInternal = class {
|
|
|
62157
62189
|
if (linkedID) {
|
|
62158
62190
|
this.writeSelection({
|
|
62159
62191
|
root,
|
|
62160
|
-
selection:
|
|
62192
|
+
selection: fieldSelection,
|
|
62161
62193
|
parent: linkedID,
|
|
62162
62194
|
data: value,
|
|
62163
62195
|
variables,
|
|
62164
62196
|
toNotify,
|
|
62165
62197
|
applyUpdates,
|
|
62166
62198
|
layer,
|
|
62167
|
-
forceNotify
|
|
62199
|
+
forceNotify
|
|
62168
62200
|
});
|
|
62169
62201
|
}
|
|
62170
62202
|
} else if (Array.isArray(value) && (typeof previousValue === "undefined" || Array.isArray(previousValue))) {
|
|
@@ -62193,7 +62225,7 @@ var CacheInternal = class {
|
|
|
62193
62225
|
key,
|
|
62194
62226
|
linkedType,
|
|
62195
62227
|
variables,
|
|
62196
|
-
fields,
|
|
62228
|
+
fields: fieldSelection,
|
|
62197
62229
|
layer,
|
|
62198
62230
|
forceNotify
|
|
62199
62231
|
});
|
|
@@ -62243,7 +62275,7 @@ var CacheInternal = class {
|
|
|
62243
62275
|
if (linkedIDs.includes(lostID) || !lostID) {
|
|
62244
62276
|
continue;
|
|
62245
62277
|
}
|
|
62246
|
-
this.subscriptions.remove(lostID,
|
|
62278
|
+
this.subscriptions.remove(lostID, fieldSelection, currentSubscribers, variables);
|
|
62247
62279
|
}
|
|
62248
62280
|
if (contentChanged || oldIDs.length === 0 && newIDs.length === 0) {
|
|
62249
62281
|
layer.writeLink(parent, key, linkedIDs);
|
|
@@ -62254,7 +62286,7 @@ var CacheInternal = class {
|
|
|
62254
62286
|
}
|
|
62255
62287
|
this.subscriptions.addMany({
|
|
62256
62288
|
parent: id,
|
|
62257
|
-
selection:
|
|
62289
|
+
selection: fieldSelection,
|
|
62258
62290
|
subscribers: currentSubscribers,
|
|
62259
62291
|
variables,
|
|
62260
62292
|
parentType: linkedType
|
|
@@ -62279,9 +62311,14 @@ var CacheInternal = class {
|
|
|
62279
62311
|
}
|
|
62280
62312
|
const targets = Array.isArray(value) ? value : [value];
|
|
62281
62313
|
for (const target of targets) {
|
|
62282
|
-
if (operation.action === "insert" && target instanceof Object &&
|
|
62283
|
-
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).addToList(
|
|
62284
|
-
|
|
62314
|
+
if (operation.action === "insert" && target instanceof Object && fieldSelection && operation.list) {
|
|
62315
|
+
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).addToList(
|
|
62316
|
+
fieldSelection,
|
|
62317
|
+
target,
|
|
62318
|
+
variables,
|
|
62319
|
+
operation.position || "last"
|
|
62320
|
+
);
|
|
62321
|
+
} else if (operation.action === "remove" && target instanceof Object && fieldSelection && operation.list) {
|
|
62285
62322
|
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables);
|
|
62286
62323
|
} else if (operation.action === "delete" && operation.type) {
|
|
62287
62324
|
if (typeof target !== "string") {
|
|
@@ -62292,8 +62329,13 @@ var CacheInternal = class {
|
|
|
62292
62329
|
continue;
|
|
62293
62330
|
}
|
|
62294
62331
|
this.cache.delete(targetID);
|
|
62295
|
-
} else if (operation.action === "toggle" && target instanceof Object &&
|
|
62296
|
-
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement(
|
|
62332
|
+
} else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
|
|
62333
|
+
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement(
|
|
62334
|
+
fieldSelection,
|
|
62335
|
+
target,
|
|
62336
|
+
variables,
|
|
62337
|
+
operation.position || "last"
|
|
62338
|
+
);
|
|
62297
62339
|
}
|
|
62298
62340
|
}
|
|
62299
62341
|
}
|
|
@@ -62313,9 +62355,12 @@ var CacheInternal = class {
|
|
|
62313
62355
|
let hasData = false;
|
|
62314
62356
|
let partial = false;
|
|
62315
62357
|
let cascadeNull = false;
|
|
62316
|
-
|
|
62317
|
-
|
|
62318
|
-
|
|
62358
|
+
const typename = this.storage.get(parent, "__typename").value;
|
|
62359
|
+
let targetSelection = getFieldsForType(selection, typename);
|
|
62360
|
+
for (const [
|
|
62361
|
+
attributeName,
|
|
62362
|
+
{ type, keyRaw, selection: fieldSelection, nullable, list }
|
|
62363
|
+
] of Object.entries(targetSelection)) {
|
|
62319
62364
|
const key = evaluateKey(keyRaw, variables);
|
|
62320
62365
|
const { value } = this.storage.get(parent, key);
|
|
62321
62366
|
let nextStep = stepsFromConnection;
|
|
@@ -62338,7 +62383,7 @@ var CacheInternal = class {
|
|
|
62338
62383
|
if (typeof value !== "undefined") {
|
|
62339
62384
|
hasData = true;
|
|
62340
62385
|
}
|
|
62341
|
-
} else if (!
|
|
62386
|
+
} else if (!fieldSelection) {
|
|
62342
62387
|
const fnUnmarshal = this.config?.scalars?.[type]?.unmarshal;
|
|
62343
62388
|
if (fnUnmarshal) {
|
|
62344
62389
|
target[attributeName] = fnUnmarshal(value);
|
|
@@ -62348,7 +62393,7 @@ var CacheInternal = class {
|
|
|
62348
62393
|
hasData = true;
|
|
62349
62394
|
} else if (Array.isArray(value)) {
|
|
62350
62395
|
const listValue = this.hydrateNestedList({
|
|
62351
|
-
fields,
|
|
62396
|
+
fields: fieldSelection,
|
|
62352
62397
|
variables,
|
|
62353
62398
|
linkedList: value,
|
|
62354
62399
|
stepsFromConnection: nextStep
|
|
@@ -62363,7 +62408,7 @@ var CacheInternal = class {
|
|
|
62363
62408
|
} else {
|
|
62364
62409
|
const objectFields = this.getSelection({
|
|
62365
62410
|
parent: value,
|
|
62366
|
-
selection:
|
|
62411
|
+
selection: fieldSelection,
|
|
62367
62412
|
variables,
|
|
62368
62413
|
stepsFromConnection: nextStep
|
|
62369
62414
|
});
|
|
@@ -64122,7 +64167,7 @@ var Config = class {
|
|
|
64122
64167
|
typeConfig;
|
|
64123
64168
|
configFile;
|
|
64124
64169
|
logLevel;
|
|
64125
|
-
|
|
64170
|
+
defaultFragmentMasking = "enable";
|
|
64126
64171
|
configIsRoute = null;
|
|
64127
64172
|
routesDir;
|
|
64128
64173
|
schemaPollInterval;
|
|
@@ -64135,6 +64180,11 @@ var Config = class {
|
|
|
64135
64180
|
...configFile
|
|
64136
64181
|
}) {
|
|
64137
64182
|
this.configFile = defaultConfigValues(configFile);
|
|
64183
|
+
if (configFile.disableMasking !== void 0) {
|
|
64184
|
+
throw new HoudiniError({
|
|
64185
|
+
message: `"disableMasking" was replaced by "defaultFragmentMasking". Please update your config file.`
|
|
64186
|
+
});
|
|
64187
|
+
}
|
|
64138
64188
|
let {
|
|
64139
64189
|
schema,
|
|
64140
64190
|
schemaPath = "./schema.graphql",
|
|
@@ -64151,7 +64201,7 @@ var Config = class {
|
|
|
64151
64201
|
defaultKeys,
|
|
64152
64202
|
types: types4 = {},
|
|
64153
64203
|
logLevel,
|
|
64154
|
-
|
|
64204
|
+
defaultFragmentMasking = "enable",
|
|
64155
64205
|
schemaPollInterval = 2e3,
|
|
64156
64206
|
schemaPollHeaders = {},
|
|
64157
64207
|
projectDir
|
|
@@ -64170,7 +64220,11 @@ var Config = class {
|
|
|
64170
64220
|
logLevel = LogLevel.Summary;
|
|
64171
64221
|
}
|
|
64172
64222
|
this.schemaPath = schemaPath;
|
|
64173
|
-
|
|
64223
|
+
if (apiUrl && apiUrl.startsWith("env:")) {
|
|
64224
|
+
this.apiUrl = process.env[apiUrl.slice("env:".length)];
|
|
64225
|
+
} else {
|
|
64226
|
+
this.apiUrl = apiUrl;
|
|
64227
|
+
}
|
|
64174
64228
|
this.filepath = filepath;
|
|
64175
64229
|
this.exclude = Array.isArray(exclude) ? exclude : [exclude];
|
|
64176
64230
|
this.module = module;
|
|
@@ -64182,10 +64236,10 @@ var Config = class {
|
|
|
64182
64236
|
this.defaultCachePolicy = defaultCachePolicy;
|
|
64183
64237
|
this.defaultPartial = defaultPartial;
|
|
64184
64238
|
this.internalListPosition = defaultListPosition === "append" ? "last" : "first";
|
|
64185
|
-
this.defaultListTarget
|
|
64239
|
+
this.defaultListTarget = defaultListTarget;
|
|
64186
64240
|
this.definitionsFolder = definitionsPath;
|
|
64187
64241
|
this.logLevel = (logLevel || LogLevel.Summary).toLowerCase();
|
|
64188
|
-
this.
|
|
64242
|
+
this.defaultFragmentMasking = defaultFragmentMasking;
|
|
64189
64243
|
this.routesDir = join2(this.projectRoot, "src", "routes");
|
|
64190
64244
|
this.schemaPollInterval = schemaPollInterval;
|
|
64191
64245
|
this.schemaPollHeaders = schemaPollHeaders;
|
|
@@ -64379,8 +64433,14 @@ var Config = class {
|
|
|
64379
64433
|
pluginDirectory(name) {
|
|
64380
64434
|
return houdini_mode.is_testing ? resolve("../../../", name) : join2(this.rootDir, "plugins", name);
|
|
64381
64435
|
}
|
|
64382
|
-
get
|
|
64383
|
-
return "
|
|
64436
|
+
get manualLoadDirective() {
|
|
64437
|
+
return "manual_load";
|
|
64438
|
+
}
|
|
64439
|
+
get maskEnableDirective() {
|
|
64440
|
+
return "mask_enable";
|
|
64441
|
+
}
|
|
64442
|
+
get maskDisableDirective() {
|
|
64443
|
+
return "mask_disable";
|
|
64384
64444
|
}
|
|
64385
64445
|
get listDirective() {
|
|
64386
64446
|
return "list";
|
|
@@ -64392,9 +64452,9 @@ var Config = class {
|
|
|
64392
64452
|
return "append";
|
|
64393
64453
|
}
|
|
64394
64454
|
get listParentDirective() {
|
|
64395
|
-
return
|
|
64455
|
+
return "parentID";
|
|
64396
64456
|
}
|
|
64397
|
-
get
|
|
64457
|
+
get deprecatedlistDirectiveParentIDArg() {
|
|
64398
64458
|
return "parentID";
|
|
64399
64459
|
}
|
|
64400
64460
|
get listAllListsDirective() {
|
|
@@ -64480,7 +64540,7 @@ var Config = class {
|
|
|
64480
64540
|
this.listDirective,
|
|
64481
64541
|
this.listPrependDirective,
|
|
64482
64542
|
this.listAppendDirective,
|
|
64483
|
-
this.
|
|
64543
|
+
this.listParentDirective,
|
|
64484
64544
|
this.listAllListsDirective,
|
|
64485
64545
|
this.whenDirective,
|
|
64486
64546
|
this.whenNotDirective,
|
|
@@ -64488,7 +64548,9 @@ var Config = class {
|
|
|
64488
64548
|
this.withDirective,
|
|
64489
64549
|
this.paginateDirective,
|
|
64490
64550
|
this.cacheDirective,
|
|
64491
|
-
this.
|
|
64551
|
+
this.manualLoadDirective,
|
|
64552
|
+
this.maskEnableDirective,
|
|
64553
|
+
this.maskDisableDirective
|
|
64492
64554
|
].includes(name.value) || this.isDeleteDirective(name.value);
|
|
64493
64555
|
}
|
|
64494
64556
|
isListFragment(name) {
|
|
@@ -16,10 +16,10 @@ export declare class InMemorySubscriptions {
|
|
|
16
16
|
[key: string]: GraphQLValue;
|
|
17
17
|
};
|
|
18
18
|
}): void;
|
|
19
|
-
addFieldSubscription({ id, key,
|
|
19
|
+
addFieldSubscription({ id, key, field, spec, parentType, variables, }: {
|
|
20
20
|
id: string;
|
|
21
21
|
key: string;
|
|
22
|
-
|
|
22
|
+
field: Required<SubscriptionSelection>['fields'][string];
|
|
23
23
|
spec: SubscriptionSpec;
|
|
24
24
|
parentType: string;
|
|
25
25
|
variables: GraphQLObject;
|
|
@@ -32,7 +32,7 @@ export declare class InMemorySubscriptions {
|
|
|
32
32
|
parentType: string;
|
|
33
33
|
}): void;
|
|
34
34
|
get(id: string, field: string): SubscriptionSpec[];
|
|
35
|
-
remove(id: string,
|
|
35
|
+
remove(id: string, selection: SubscriptionSelection, targets: SubscriptionSpec[], variables: {}, visited?: string[]): void;
|
|
36
36
|
private removeSubscribers;
|
|
37
37
|
removeAllSubscribers(id: string, targets?: SubscriptionSpec[], visited?: string[]): void;
|
|
38
38
|
}
|
|
@@ -87,8 +87,9 @@ export declare type ConfigFile = {
|
|
|
87
87
|
logLevel?: string;
|
|
88
88
|
/**
|
|
89
89
|
* A flag to specify the default fragment masking behavior.
|
|
90
|
+
* @default `enable`
|
|
90
91
|
*/
|
|
91
|
-
|
|
92
|
+
defaultFragmentMasking?: 'enable' | 'disable';
|
|
92
93
|
/**
|
|
93
94
|
* Configures the houdini plugin's schema polling behavior. By default, houdini will poll your APIs
|
|
94
95
|
* during development in order to keep it's definition of your schema up to date. The schemaPollingInterval
|
|
@@ -2,12 +2,12 @@ import { ConfigFile } from './config';
|
|
|
2
2
|
import { MutationArtifact, QueryArtifact, SubscriptionArtifact, SubscriptionSelection } from './types';
|
|
3
3
|
export declare function marshalSelection({ selection, data, }: {
|
|
4
4
|
selection: SubscriptionSelection;
|
|
5
|
-
data:
|
|
5
|
+
data: any;
|
|
6
6
|
}): Promise<{} | null | undefined>;
|
|
7
7
|
export declare function marshalInputs<T>({ artifact, input, rootType, }: {
|
|
8
8
|
artifact: QueryArtifact | MutationArtifact | SubscriptionArtifact;
|
|
9
9
|
input: unknown;
|
|
10
10
|
rootType?: string;
|
|
11
11
|
}): Promise<{} | null | undefined>;
|
|
12
|
-
export declare function unmarshalSelection(config: ConfigFile, selection: SubscriptionSelection, data:
|
|
12
|
+
export declare function unmarshalSelection(config: ConfigFile, selection: SubscriptionSelection, data: any): {} | null | undefined;
|
|
13
13
|
export declare function isScalar(config: ConfigFile, type: string): boolean;
|
|
@@ -107,25 +107,35 @@ export declare type GraphQLObject = {
|
|
|
107
107
|
};
|
|
108
108
|
export declare type GraphQLValue = number | string | boolean | null | GraphQLObject | GraphQLValue[] | undefined;
|
|
109
109
|
export declare type SubscriptionSelection = {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
nullable?: boolean;
|
|
113
|
-
keyRaw: string;
|
|
114
|
-
operations?: MutationOperation[];
|
|
115
|
-
list?: {
|
|
116
|
-
name: string;
|
|
117
|
-
connection: boolean;
|
|
110
|
+
fields?: {
|
|
111
|
+
[fieldName: string]: {
|
|
118
112
|
type: string;
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
113
|
+
nullable?: boolean;
|
|
114
|
+
keyRaw: string;
|
|
115
|
+
operations?: MutationOperation[];
|
|
116
|
+
list?: {
|
|
117
|
+
name: string;
|
|
118
|
+
connection: boolean;
|
|
119
|
+
type: string;
|
|
120
|
+
};
|
|
121
|
+
update?: RefetchUpdateMode;
|
|
122
|
+
filters?: {
|
|
123
|
+
[key: string]: {
|
|
124
|
+
kind: 'Boolean' | 'String' | 'Float' | 'Int' | 'Variable';
|
|
125
|
+
value: string | number | boolean;
|
|
126
|
+
};
|
|
125
127
|
};
|
|
128
|
+
selection?: SubscriptionSelection;
|
|
129
|
+
abstract?: boolean;
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
abstractFields?: {
|
|
133
|
+
fields: {
|
|
134
|
+
[typeName: string]: SubscriptionSelection['fields'];
|
|
135
|
+
};
|
|
136
|
+
typeMap: {
|
|
137
|
+
[typeName: string]: string;
|
|
126
138
|
};
|
|
127
|
-
fields?: SubscriptionSelection;
|
|
128
|
-
abstract?: boolean;
|
|
129
139
|
};
|
|
130
140
|
};
|
|
131
141
|
export declare type SubscriptionSpec = {
|