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/cmd-esm/index.js
CHANGED
|
@@ -5105,7 +5105,7 @@ var require_definition = __commonJS({
|
|
|
5105
5105
|
exports.assertObjectType = assertObjectType;
|
|
5106
5106
|
exports.isInterfaceType = isInterfaceType12;
|
|
5107
5107
|
exports.assertInterfaceType = assertInterfaceType;
|
|
5108
|
-
exports.isUnionType =
|
|
5108
|
+
exports.isUnionType = isUnionType13;
|
|
5109
5109
|
exports.assertUnionType = assertUnionType;
|
|
5110
5110
|
exports.isEnumType = isEnumType9;
|
|
5111
5111
|
exports.assertEnumType = assertEnumType;
|
|
@@ -5123,7 +5123,7 @@ var require_definition = __commonJS({
|
|
|
5123
5123
|
exports.assertLeafType = assertLeafType;
|
|
5124
5124
|
exports.isCompositeType = isCompositeType;
|
|
5125
5125
|
exports.assertCompositeType = assertCompositeType;
|
|
5126
|
-
exports.isAbstractType =
|
|
5126
|
+
exports.isAbstractType = isAbstractType2;
|
|
5127
5127
|
exports.assertAbstractType = assertAbstractType;
|
|
5128
5128
|
exports.GraphQLList = GraphQLList6;
|
|
5129
5129
|
exports.GraphQLNonNull = GraphQLNonNull6;
|
|
@@ -5178,7 +5178,7 @@ var require_definition = __commonJS({
|
|
|
5178
5178
|
return Constructor;
|
|
5179
5179
|
}
|
|
5180
5180
|
function isType(type) {
|
|
5181
|
-
return isScalarType12(type) || isObjectType11(type) || isInterfaceType12(type) ||
|
|
5181
|
+
return isScalarType12(type) || isObjectType11(type) || isInterfaceType12(type) || isUnionType13(type) || isEnumType9(type) || isInputObjectType7(type) || isListType8(type) || isNonNullType10(type);
|
|
5182
5182
|
}
|
|
5183
5183
|
function assertType(type) {
|
|
5184
5184
|
if (!isType(type)) {
|
|
@@ -5213,11 +5213,11 @@ var require_definition = __commonJS({
|
|
|
5213
5213
|
}
|
|
5214
5214
|
return type;
|
|
5215
5215
|
}
|
|
5216
|
-
function
|
|
5216
|
+
function isUnionType13(type) {
|
|
5217
5217
|
return (0, _instanceOf.default)(type, GraphQLUnionType3);
|
|
5218
5218
|
}
|
|
5219
5219
|
function assertUnionType(type) {
|
|
5220
|
-
if (!
|
|
5220
|
+
if (!isUnionType13(type)) {
|
|
5221
5221
|
throw new Error("Expected ".concat((0, _inspect.default)(type), " to be a GraphQL Union type."));
|
|
5222
5222
|
}
|
|
5223
5223
|
return type;
|
|
@@ -5268,7 +5268,7 @@ var require_definition = __commonJS({
|
|
|
5268
5268
|
return type;
|
|
5269
5269
|
}
|
|
5270
5270
|
function isOutputType(type) {
|
|
5271
|
-
return isScalarType12(type) || isObjectType11(type) || isInterfaceType12(type) ||
|
|
5271
|
+
return isScalarType12(type) || isObjectType11(type) || isInterfaceType12(type) || isUnionType13(type) || isEnumType9(type) || isWrappingType(type) && isOutputType(type.ofType);
|
|
5272
5272
|
}
|
|
5273
5273
|
function assertOutputType(type) {
|
|
5274
5274
|
if (!isOutputType(type)) {
|
|
@@ -5286,7 +5286,7 @@ var require_definition = __commonJS({
|
|
|
5286
5286
|
return type;
|
|
5287
5287
|
}
|
|
5288
5288
|
function isCompositeType(type) {
|
|
5289
|
-
return isObjectType11(type) || isInterfaceType12(type) ||
|
|
5289
|
+
return isObjectType11(type) || isInterfaceType12(type) || isUnionType13(type);
|
|
5290
5290
|
}
|
|
5291
5291
|
function assertCompositeType(type) {
|
|
5292
5292
|
if (!isCompositeType(type)) {
|
|
@@ -5294,11 +5294,11 @@ var require_definition = __commonJS({
|
|
|
5294
5294
|
}
|
|
5295
5295
|
return type;
|
|
5296
5296
|
}
|
|
5297
|
-
function
|
|
5298
|
-
return isInterfaceType12(type) ||
|
|
5297
|
+
function isAbstractType2(type) {
|
|
5298
|
+
return isInterfaceType12(type) || isUnionType13(type);
|
|
5299
5299
|
}
|
|
5300
5300
|
function assertAbstractType(type) {
|
|
5301
|
-
if (!
|
|
5301
|
+
if (!isAbstractType2(type)) {
|
|
5302
5302
|
throw new Error("Expected ".concat((0, _inspect.default)(type), " to be a GraphQL abstract type."));
|
|
5303
5303
|
}
|
|
5304
5304
|
return type;
|
|
@@ -5365,7 +5365,7 @@ var require_definition = __commonJS({
|
|
|
5365
5365
|
}
|
|
5366
5366
|
}
|
|
5367
5367
|
function isNamedType4(type) {
|
|
5368
|
-
return isScalarType12(type) || isObjectType11(type) || isInterfaceType12(type) ||
|
|
5368
|
+
return isScalarType12(type) || isObjectType11(type) || isInterfaceType12(type) || isUnionType13(type) || isEnumType9(type) || isInputObjectType7(type);
|
|
5369
5369
|
}
|
|
5370
5370
|
function assertNamedType(type) {
|
|
5371
5371
|
if (!isNamedType4(type)) {
|
|
@@ -67742,6 +67742,20 @@ function deepEquals(objA, objB, map = /* @__PURE__ */ new WeakMap()) {
|
|
|
67742
67742
|
return true;
|
|
67743
67743
|
}
|
|
67744
67744
|
|
|
67745
|
+
// src/runtime/lib/selection.ts
|
|
67746
|
+
function getFieldsForType(selection2, __typename) {
|
|
67747
|
+
let targetSelection = selection2.fields || {};
|
|
67748
|
+
if (selection2.abstractFields && __typename) {
|
|
67749
|
+
const mappedType = selection2.abstractFields.typeMap[__typename];
|
|
67750
|
+
if (mappedType) {
|
|
67751
|
+
targetSelection = selection2.abstractFields.fields[mappedType];
|
|
67752
|
+
} else if (selection2.abstractFields.fields[__typename]) {
|
|
67753
|
+
targetSelection = selection2.abstractFields.fields[__typename];
|
|
67754
|
+
}
|
|
67755
|
+
}
|
|
67756
|
+
return targetSelection;
|
|
67757
|
+
}
|
|
67758
|
+
|
|
67745
67759
|
// src/runtime/cache/gc.ts
|
|
67746
67760
|
var GarbageCollector = class {
|
|
67747
67761
|
cache;
|
|
@@ -67964,23 +67978,32 @@ var List = class {
|
|
|
67964
67978
|
let insertData = data;
|
|
67965
67979
|
if (this.connection) {
|
|
67966
67980
|
insertSelection = {
|
|
67967
|
-
|
|
67968
|
-
|
|
67969
|
-
|
|
67970
|
-
|
|
67971
|
-
|
|
67972
|
-
keyRaw: "edges",
|
|
67973
|
-
type: "ConnectionEdge",
|
|
67974
|
-
update: where === "first" ? "prepend" : "append",
|
|
67981
|
+
fields: {
|
|
67982
|
+
newEntry: {
|
|
67983
|
+
keyRaw: this.key,
|
|
67984
|
+
type: "Connection",
|
|
67985
|
+
selection: {
|
|
67975
67986
|
fields: {
|
|
67976
|
-
|
|
67977
|
-
|
|
67978
|
-
|
|
67979
|
-
|
|
67980
|
-
|
|
67981
|
-
|
|
67982
|
-
|
|
67983
|
-
|
|
67987
|
+
edges: {
|
|
67988
|
+
keyRaw: "edges",
|
|
67989
|
+
type: "ConnectionEdge",
|
|
67990
|
+
update: where === "first" ? "prepend" : "append",
|
|
67991
|
+
selection: {
|
|
67992
|
+
fields: {
|
|
67993
|
+
node: {
|
|
67994
|
+
type: listType,
|
|
67995
|
+
keyRaw: "node",
|
|
67996
|
+
selection: {
|
|
67997
|
+
...selection2,
|
|
67998
|
+
fields: {
|
|
67999
|
+
...selection2.fields,
|
|
68000
|
+
__typename: {
|
|
68001
|
+
keyRaw: "__typename",
|
|
68002
|
+
type: "String"
|
|
68003
|
+
}
|
|
68004
|
+
}
|
|
68005
|
+
}
|
|
68006
|
+
}
|
|
67984
68007
|
}
|
|
67985
68008
|
}
|
|
67986
68009
|
}
|
|
@@ -67996,15 +68019,20 @@ var List = class {
|
|
|
67996
68019
|
};
|
|
67997
68020
|
} else {
|
|
67998
68021
|
insertSelection = {
|
|
67999
|
-
|
|
68000
|
-
|
|
68001
|
-
|
|
68002
|
-
|
|
68003
|
-
|
|
68004
|
-
|
|
68005
|
-
|
|
68006
|
-
|
|
68007
|
-
|
|
68022
|
+
fields: {
|
|
68023
|
+
newEntries: {
|
|
68024
|
+
keyRaw: this.key,
|
|
68025
|
+
type: listType,
|
|
68026
|
+
update: where === "first" ? "prepend" : "append",
|
|
68027
|
+
selection: {
|
|
68028
|
+
...selection2,
|
|
68029
|
+
fields: {
|
|
68030
|
+
...selection2.fields,
|
|
68031
|
+
__typename: {
|
|
68032
|
+
keyRaw: "__typename",
|
|
68033
|
+
type: "String"
|
|
68034
|
+
}
|
|
68035
|
+
}
|
|
68008
68036
|
}
|
|
68009
68037
|
}
|
|
68010
68038
|
}
|
|
@@ -68064,7 +68092,7 @@ var List = class {
|
|
|
68064
68092
|
const subscribers = this.cache._internal_unstable.subscriptions.get(this.recordID, this.key);
|
|
68065
68093
|
this.cache._internal_unstable.subscriptions.remove(
|
|
68066
68094
|
targetID,
|
|
68067
|
-
this.connection ? this.selection.edges.
|
|
68095
|
+
this.connection ? this.selection.fields.edges.selection : this.selection,
|
|
68068
68096
|
subscribers,
|
|
68069
68097
|
variables
|
|
68070
68098
|
);
|
|
@@ -68553,18 +68581,20 @@ var InMemorySubscriptions = class {
|
|
|
68553
68581
|
variables,
|
|
68554
68582
|
parentType
|
|
68555
68583
|
}) {
|
|
68556
|
-
|
|
68557
|
-
|
|
68584
|
+
const __typename = this.cache._internal_unstable.storage.get(parent, "__typename").value;
|
|
68585
|
+
let targetSelection = getFieldsForType(selection2, __typename);
|
|
68586
|
+
for (const fieldSelection of Object.values(targetSelection || {})) {
|
|
68587
|
+
const { keyRaw, selection: innerSelection, type } = fieldSelection;
|
|
68558
68588
|
const key = evaluateKey(keyRaw, variables);
|
|
68559
68589
|
this.addFieldSubscription({
|
|
68560
68590
|
id: parent,
|
|
68561
68591
|
key,
|
|
68562
|
-
|
|
68592
|
+
field: fieldSelection,
|
|
68563
68593
|
spec,
|
|
68564
68594
|
parentType: parentType || spec.rootType,
|
|
68565
68595
|
variables
|
|
68566
68596
|
});
|
|
68567
|
-
if (
|
|
68597
|
+
if (innerSelection) {
|
|
68568
68598
|
const { value: linkedRecord } = this.cache._internal_unstable.storage.get(
|
|
68569
68599
|
parent,
|
|
68570
68600
|
key
|
|
@@ -68577,7 +68607,7 @@ var InMemorySubscriptions = class {
|
|
|
68577
68607
|
this.add({
|
|
68578
68608
|
parent: child,
|
|
68579
68609
|
spec,
|
|
68580
|
-
selection:
|
|
68610
|
+
selection: innerSelection,
|
|
68581
68611
|
variables,
|
|
68582
68612
|
parentType: type
|
|
68583
68613
|
});
|
|
@@ -68588,7 +68618,7 @@ var InMemorySubscriptions = class {
|
|
|
68588
68618
|
addFieldSubscription({
|
|
68589
68619
|
id,
|
|
68590
68620
|
key,
|
|
68591
|
-
|
|
68621
|
+
field,
|
|
68592
68622
|
spec,
|
|
68593
68623
|
parentType,
|
|
68594
68624
|
variables
|
|
@@ -68615,8 +68645,8 @@ var InMemorySubscriptions = class {
|
|
|
68615
68645
|
const counts = this.referenceCounts[id][key];
|
|
68616
68646
|
counts.set(spec.set, (counts.get(spec.set) || 0) + 1);
|
|
68617
68647
|
this.cache._internal_unstable.lifetimes.resetLifetime(id, key);
|
|
68618
|
-
const {
|
|
68619
|
-
if (
|
|
68648
|
+
const { selection: selection2, list, filters } = field;
|
|
68649
|
+
if (selection2 && list) {
|
|
68620
68650
|
this.cache._internal_unstable.lists.add({
|
|
68621
68651
|
name: list.name,
|
|
68622
68652
|
connection: list.connection,
|
|
@@ -68624,7 +68654,7 @@ var InMemorySubscriptions = class {
|
|
|
68624
68654
|
recordType: this.cache._internal_unstable.storage.get(id, "__typename")?.value || parentType,
|
|
68625
68655
|
listType: list.type,
|
|
68626
68656
|
key,
|
|
68627
|
-
selection:
|
|
68657
|
+
selection: selection2,
|
|
68628
68658
|
filters: Object.entries(filters || {}).reduce((acc, [key2, { kind, value }]) => {
|
|
68629
68659
|
return {
|
|
68630
68660
|
...acc,
|
|
@@ -68641,20 +68671,21 @@ var InMemorySubscriptions = class {
|
|
|
68641
68671
|
subscribers,
|
|
68642
68672
|
parentType
|
|
68643
68673
|
}) {
|
|
68644
|
-
|
|
68645
|
-
|
|
68674
|
+
let targetSelection = getFieldsForType(selection2, parentType);
|
|
68675
|
+
for (const fieldSelection of Object.values(targetSelection)) {
|
|
68676
|
+
const { type: linkedType, keyRaw, selection: innerSelection } = fieldSelection;
|
|
68646
68677
|
const key = evaluateKey(keyRaw, variables);
|
|
68647
68678
|
for (const spec of subscribers) {
|
|
68648
68679
|
this.addFieldSubscription({
|
|
68649
68680
|
id: parent,
|
|
68650
68681
|
key,
|
|
68651
|
-
|
|
68682
|
+
field: fieldSelection,
|
|
68652
68683
|
spec,
|
|
68653
68684
|
parentType,
|
|
68654
68685
|
variables
|
|
68655
68686
|
});
|
|
68656
68687
|
}
|
|
68657
|
-
if (
|
|
68688
|
+
if (innerSelection) {
|
|
68658
68689
|
const { value: link } = this.cache._internal_unstable.storage.get(parent, key);
|
|
68659
68690
|
const children = !Array.isArray(link) ? [link] : flattenList(link);
|
|
68660
68691
|
for (const linkedRecord of children) {
|
|
@@ -68663,7 +68694,7 @@ var InMemorySubscriptions = class {
|
|
|
68663
68694
|
}
|
|
68664
68695
|
this.addMany({
|
|
68665
68696
|
parent: linkedRecord,
|
|
68666
|
-
selection:
|
|
68697
|
+
selection: innerSelection,
|
|
68667
68698
|
variables,
|
|
68668
68699
|
subscribers,
|
|
68669
68700
|
parentType: linkedType
|
|
@@ -68675,22 +68706,20 @@ var InMemorySubscriptions = class {
|
|
|
68675
68706
|
get(id, field) {
|
|
68676
68707
|
return this.subscribers[id]?.[field] || [];
|
|
68677
68708
|
}
|
|
68678
|
-
remove(id,
|
|
68709
|
+
remove(id, selection2, targets, variables, visited = []) {
|
|
68679
68710
|
visited.push(id);
|
|
68680
68711
|
const linkedIDs = [];
|
|
68681
|
-
for (const
|
|
68682
|
-
const key = evaluateKey(
|
|
68712
|
+
for (const fieldSelection of Object.values(selection2.fields || {})) {
|
|
68713
|
+
const key = evaluateKey(fieldSelection.keyRaw, variables);
|
|
68683
68714
|
this.removeSubscribers(id, key, targets);
|
|
68684
|
-
if (!
|
|
68715
|
+
if (!fieldSelection.selection?.fields) {
|
|
68685
68716
|
continue;
|
|
68686
68717
|
}
|
|
68687
|
-
if (selection2.list) {
|
|
68688
|
-
}
|
|
68689
68718
|
const { value: previousValue } = this.cache._internal_unstable.storage.get(id, key);
|
|
68690
68719
|
const links = !Array.isArray(previousValue) ? [previousValue] : flattenList(previousValue);
|
|
68691
68720
|
for (const link of links) {
|
|
68692
68721
|
if (link !== null) {
|
|
68693
|
-
linkedIDs.push([link,
|
|
68722
|
+
linkedIDs.push([link, fieldSelection.selection || {}]);
|
|
68694
68723
|
}
|
|
68695
68724
|
}
|
|
68696
68725
|
}
|
|
@@ -68845,10 +68874,12 @@ var CacheInternal = class {
|
|
|
68845
68874
|
this.lists = lists;
|
|
68846
68875
|
this.cache = cache;
|
|
68847
68876
|
this.lifetimes = lifetimes;
|
|
68877
|
+
this._disabled = typeof globalThis.window === "undefined";
|
|
68848
68878
|
try {
|
|
68849
|
-
|
|
68879
|
+
if (process.env.HOUDINI_TEST === "true") {
|
|
68880
|
+
this._disabled = false;
|
|
68881
|
+
}
|
|
68850
68882
|
} catch {
|
|
68851
|
-
this._disabled = typeof globalThis.window === "undefined";
|
|
68852
68883
|
}
|
|
68853
68884
|
}
|
|
68854
68885
|
setConfig(config2) {
|
|
@@ -68868,8 +68899,9 @@ var CacheInternal = class {
|
|
|
68868
68899
|
if (this._disabled) {
|
|
68869
68900
|
return [];
|
|
68870
68901
|
}
|
|
68902
|
+
let targetSelection = getFieldsForType(selection2, data["__typename"]);
|
|
68871
68903
|
for (const [field, value] of Object.entries(data)) {
|
|
68872
|
-
if (!selection2 || !
|
|
68904
|
+
if (!selection2 || !targetSelection[field]) {
|
|
68873
68905
|
throw new Error(
|
|
68874
68906
|
"Could not find field listing in selection for " + field + " @ " + JSON.stringify(selection2)
|
|
68875
68907
|
);
|
|
@@ -68877,11 +68909,11 @@ var CacheInternal = class {
|
|
|
68877
68909
|
let {
|
|
68878
68910
|
type: linkedType,
|
|
68879
68911
|
keyRaw,
|
|
68880
|
-
|
|
68912
|
+
selection: fieldSelection,
|
|
68881
68913
|
operations,
|
|
68882
68914
|
abstract: isAbstract,
|
|
68883
68915
|
update
|
|
68884
|
-
} =
|
|
68916
|
+
} = targetSelection[field];
|
|
68885
68917
|
const key = evaluateKey(keyRaw, variables);
|
|
68886
68918
|
const currentSubscribers = this.subscriptions.get(parent, key);
|
|
68887
68919
|
const { value: previousValue, displayLayers } = this.storage.get(parent, key);
|
|
@@ -68889,7 +68921,7 @@ var CacheInternal = class {
|
|
|
68889
68921
|
if (displayLayer) {
|
|
68890
68922
|
this.lifetimes.resetLifetime(parent, key);
|
|
68891
68923
|
}
|
|
68892
|
-
if (!
|
|
68924
|
+
if (!fieldSelection) {
|
|
68893
68925
|
let newValue = value;
|
|
68894
68926
|
if (Array.isArray(value) && applyUpdates && update) {
|
|
68895
68927
|
if (update === "append") {
|
|
@@ -68909,7 +68941,7 @@ var CacheInternal = class {
|
|
|
68909
68941
|
}
|
|
68910
68942
|
const previousLinks = flattenList([previousValue]);
|
|
68911
68943
|
for (const link of previousLinks) {
|
|
68912
|
-
this.subscriptions.remove(link,
|
|
68944
|
+
this.subscriptions.remove(link, fieldSelection, currentSubscribers, variables);
|
|
68913
68945
|
}
|
|
68914
68946
|
layer.writeLink(parent, key, null);
|
|
68915
68947
|
toNotify.push(...currentSubscribers);
|
|
@@ -68935,14 +68967,14 @@ var CacheInternal = class {
|
|
|
68935
68967
|
if (previousValue && typeof previousValue === "string") {
|
|
68936
68968
|
this.subscriptions.remove(
|
|
68937
68969
|
previousValue,
|
|
68938
|
-
|
|
68970
|
+
fieldSelection,
|
|
68939
68971
|
currentSubscribers,
|
|
68940
68972
|
variables
|
|
68941
68973
|
);
|
|
68942
68974
|
}
|
|
68943
68975
|
this.subscriptions.addMany({
|
|
68944
68976
|
parent: linkedID,
|
|
68945
|
-
selection:
|
|
68977
|
+
selection: fieldSelection,
|
|
68946
68978
|
subscribers: currentSubscribers,
|
|
68947
68979
|
variables,
|
|
68948
68980
|
parentType: linkedType
|
|
@@ -68952,14 +68984,14 @@ var CacheInternal = class {
|
|
|
68952
68984
|
if (linkedID) {
|
|
68953
68985
|
this.writeSelection({
|
|
68954
68986
|
root,
|
|
68955
|
-
selection:
|
|
68987
|
+
selection: fieldSelection,
|
|
68956
68988
|
parent: linkedID,
|
|
68957
68989
|
data: value,
|
|
68958
68990
|
variables,
|
|
68959
68991
|
toNotify,
|
|
68960
68992
|
applyUpdates,
|
|
68961
68993
|
layer,
|
|
68962
|
-
forceNotify
|
|
68994
|
+
forceNotify
|
|
68963
68995
|
});
|
|
68964
68996
|
}
|
|
68965
68997
|
} else if (Array.isArray(value) && (typeof previousValue === "undefined" || Array.isArray(previousValue))) {
|
|
@@ -68988,7 +69020,7 @@ var CacheInternal = class {
|
|
|
68988
69020
|
key,
|
|
68989
69021
|
linkedType,
|
|
68990
69022
|
variables,
|
|
68991
|
-
fields,
|
|
69023
|
+
fields: fieldSelection,
|
|
68992
69024
|
layer,
|
|
68993
69025
|
forceNotify
|
|
68994
69026
|
});
|
|
@@ -69038,7 +69070,7 @@ var CacheInternal = class {
|
|
|
69038
69070
|
if (linkedIDs.includes(lostID) || !lostID) {
|
|
69039
69071
|
continue;
|
|
69040
69072
|
}
|
|
69041
|
-
this.subscriptions.remove(lostID,
|
|
69073
|
+
this.subscriptions.remove(lostID, fieldSelection, currentSubscribers, variables);
|
|
69042
69074
|
}
|
|
69043
69075
|
if (contentChanged || oldIDs.length === 0 && newIDs.length === 0) {
|
|
69044
69076
|
layer.writeLink(parent, key, linkedIDs);
|
|
@@ -69049,7 +69081,7 @@ var CacheInternal = class {
|
|
|
69049
69081
|
}
|
|
69050
69082
|
this.subscriptions.addMany({
|
|
69051
69083
|
parent: id,
|
|
69052
|
-
selection:
|
|
69084
|
+
selection: fieldSelection,
|
|
69053
69085
|
subscribers: currentSubscribers,
|
|
69054
69086
|
variables,
|
|
69055
69087
|
parentType: linkedType
|
|
@@ -69074,9 +69106,14 @@ var CacheInternal = class {
|
|
|
69074
69106
|
}
|
|
69075
69107
|
const targets = Array.isArray(value) ? value : [value];
|
|
69076
69108
|
for (const target of targets) {
|
|
69077
|
-
if (operation.action === "insert" && target instanceof Object &&
|
|
69078
|
-
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).addToList(
|
|
69079
|
-
|
|
69109
|
+
if (operation.action === "insert" && target instanceof Object && fieldSelection && operation.list) {
|
|
69110
|
+
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).addToList(
|
|
69111
|
+
fieldSelection,
|
|
69112
|
+
target,
|
|
69113
|
+
variables,
|
|
69114
|
+
operation.position || "last"
|
|
69115
|
+
);
|
|
69116
|
+
} else if (operation.action === "remove" && target instanceof Object && fieldSelection && operation.list) {
|
|
69080
69117
|
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables);
|
|
69081
69118
|
} else if (operation.action === "delete" && operation.type) {
|
|
69082
69119
|
if (typeof target !== "string") {
|
|
@@ -69087,8 +69124,13 @@ var CacheInternal = class {
|
|
|
69087
69124
|
continue;
|
|
69088
69125
|
}
|
|
69089
69126
|
this.cache.delete(targetID);
|
|
69090
|
-
} else if (operation.action === "toggle" && target instanceof Object &&
|
|
69091
|
-
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement(
|
|
69127
|
+
} else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
|
|
69128
|
+
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement(
|
|
69129
|
+
fieldSelection,
|
|
69130
|
+
target,
|
|
69131
|
+
variables,
|
|
69132
|
+
operation.position || "last"
|
|
69133
|
+
);
|
|
69092
69134
|
}
|
|
69093
69135
|
}
|
|
69094
69136
|
}
|
|
@@ -69108,9 +69150,12 @@ var CacheInternal = class {
|
|
|
69108
69150
|
let hasData = false;
|
|
69109
69151
|
let partial = false;
|
|
69110
69152
|
let cascadeNull = false;
|
|
69111
|
-
|
|
69112
|
-
|
|
69113
|
-
|
|
69153
|
+
const typename = this.storage.get(parent, "__typename").value;
|
|
69154
|
+
let targetSelection = getFieldsForType(selection2, typename);
|
|
69155
|
+
for (const [
|
|
69156
|
+
attributeName,
|
|
69157
|
+
{ type, keyRaw, selection: fieldSelection, nullable, list }
|
|
69158
|
+
] of Object.entries(targetSelection)) {
|
|
69114
69159
|
const key = evaluateKey(keyRaw, variables);
|
|
69115
69160
|
const { value } = this.storage.get(parent, key);
|
|
69116
69161
|
let nextStep = stepsFromConnection;
|
|
@@ -69133,7 +69178,7 @@ var CacheInternal = class {
|
|
|
69133
69178
|
if (typeof value !== "undefined") {
|
|
69134
69179
|
hasData = true;
|
|
69135
69180
|
}
|
|
69136
|
-
} else if (!
|
|
69181
|
+
} else if (!fieldSelection) {
|
|
69137
69182
|
const fnUnmarshal = this.config?.scalars?.[type]?.unmarshal;
|
|
69138
69183
|
if (fnUnmarshal) {
|
|
69139
69184
|
target[attributeName] = fnUnmarshal(value);
|
|
@@ -69143,7 +69188,7 @@ var CacheInternal = class {
|
|
|
69143
69188
|
hasData = true;
|
|
69144
69189
|
} else if (Array.isArray(value)) {
|
|
69145
69190
|
const listValue = this.hydrateNestedList({
|
|
69146
|
-
fields,
|
|
69191
|
+
fields: fieldSelection,
|
|
69147
69192
|
variables,
|
|
69148
69193
|
linkedList: value,
|
|
69149
69194
|
stepsFromConnection: nextStep
|
|
@@ -69158,7 +69203,7 @@ var CacheInternal = class {
|
|
|
69158
69203
|
} else {
|
|
69159
69204
|
const objectFields = this.getSelection({
|
|
69160
69205
|
parent: value,
|
|
69161
|
-
selection:
|
|
69206
|
+
selection: fieldSelection,
|
|
69162
69207
|
variables,
|
|
69163
69208
|
stepsFromConnection: nextStep
|
|
69164
69209
|
});
|
|
@@ -70891,7 +70936,7 @@ var Config = class {
|
|
|
70891
70936
|
typeConfig;
|
|
70892
70937
|
configFile;
|
|
70893
70938
|
logLevel;
|
|
70894
|
-
|
|
70939
|
+
defaultFragmentMasking = "enable";
|
|
70895
70940
|
configIsRoute = null;
|
|
70896
70941
|
routesDir;
|
|
70897
70942
|
schemaPollInterval;
|
|
@@ -70904,6 +70949,11 @@ var Config = class {
|
|
|
70904
70949
|
...configFile
|
|
70905
70950
|
}) {
|
|
70906
70951
|
this.configFile = defaultConfigValues(configFile);
|
|
70952
|
+
if (configFile.disableMasking !== void 0) {
|
|
70953
|
+
throw new HoudiniError({
|
|
70954
|
+
message: `"disableMasking" was replaced by "defaultFragmentMasking". Please update your config file.`
|
|
70955
|
+
});
|
|
70956
|
+
}
|
|
70907
70957
|
let {
|
|
70908
70958
|
schema,
|
|
70909
70959
|
schemaPath = "./schema.graphql",
|
|
@@ -70920,7 +70970,7 @@ var Config = class {
|
|
|
70920
70970
|
defaultKeys,
|
|
70921
70971
|
types: types14 = {},
|
|
70922
70972
|
logLevel,
|
|
70923
|
-
|
|
70973
|
+
defaultFragmentMasking = "enable",
|
|
70924
70974
|
schemaPollInterval = 2e3,
|
|
70925
70975
|
schemaPollHeaders = {},
|
|
70926
70976
|
projectDir
|
|
@@ -70939,7 +70989,11 @@ var Config = class {
|
|
|
70939
70989
|
logLevel = LogLevel.Summary;
|
|
70940
70990
|
}
|
|
70941
70991
|
this.schemaPath = schemaPath;
|
|
70942
|
-
|
|
70992
|
+
if (apiUrl && apiUrl.startsWith("env:")) {
|
|
70993
|
+
this.apiUrl = process.env[apiUrl.slice("env:".length)];
|
|
70994
|
+
} else {
|
|
70995
|
+
this.apiUrl = apiUrl;
|
|
70996
|
+
}
|
|
70943
70997
|
this.filepath = filepath;
|
|
70944
70998
|
this.exclude = Array.isArray(exclude) ? exclude : [exclude];
|
|
70945
70999
|
this.module = module;
|
|
@@ -70951,10 +71005,10 @@ var Config = class {
|
|
|
70951
71005
|
this.defaultCachePolicy = defaultCachePolicy;
|
|
70952
71006
|
this.defaultPartial = defaultPartial;
|
|
70953
71007
|
this.internalListPosition = defaultListPosition === "append" ? "last" : "first";
|
|
70954
|
-
this.defaultListTarget
|
|
71008
|
+
this.defaultListTarget = defaultListTarget;
|
|
70955
71009
|
this.definitionsFolder = definitionsPath;
|
|
70956
71010
|
this.logLevel = (logLevel || LogLevel.Summary).toLowerCase();
|
|
70957
|
-
this.
|
|
71011
|
+
this.defaultFragmentMasking = defaultFragmentMasking;
|
|
70958
71012
|
this.routesDir = join2(this.projectRoot, "src", "routes");
|
|
70959
71013
|
this.schemaPollInterval = schemaPollInterval;
|
|
70960
71014
|
this.schemaPollHeaders = schemaPollHeaders;
|
|
@@ -71148,8 +71202,14 @@ var Config = class {
|
|
|
71148
71202
|
pluginDirectory(name2) {
|
|
71149
71203
|
return houdini_mode.is_testing ? resolve("../../../", name2) : join2(this.rootDir, "plugins", name2);
|
|
71150
71204
|
}
|
|
71151
|
-
get
|
|
71152
|
-
return "
|
|
71205
|
+
get manualLoadDirective() {
|
|
71206
|
+
return "manual_load";
|
|
71207
|
+
}
|
|
71208
|
+
get maskEnableDirective() {
|
|
71209
|
+
return "mask_enable";
|
|
71210
|
+
}
|
|
71211
|
+
get maskDisableDirective() {
|
|
71212
|
+
return "mask_disable";
|
|
71153
71213
|
}
|
|
71154
71214
|
get listDirective() {
|
|
71155
71215
|
return "list";
|
|
@@ -71161,9 +71221,9 @@ var Config = class {
|
|
|
71161
71221
|
return "append";
|
|
71162
71222
|
}
|
|
71163
71223
|
get listParentDirective() {
|
|
71164
|
-
return
|
|
71224
|
+
return "parentID";
|
|
71165
71225
|
}
|
|
71166
|
-
get
|
|
71226
|
+
get deprecatedlistDirectiveParentIDArg() {
|
|
71167
71227
|
return "parentID";
|
|
71168
71228
|
}
|
|
71169
71229
|
get listAllListsDirective() {
|
|
@@ -71249,7 +71309,7 @@ var Config = class {
|
|
|
71249
71309
|
this.listDirective,
|
|
71250
71310
|
this.listPrependDirective,
|
|
71251
71311
|
this.listAppendDirective,
|
|
71252
|
-
this.
|
|
71312
|
+
this.listParentDirective,
|
|
71253
71313
|
this.listAllListsDirective,
|
|
71254
71314
|
this.whenDirective,
|
|
71255
71315
|
this.whenNotDirective,
|
|
@@ -71257,7 +71317,9 @@ var Config = class {
|
|
|
71257
71317
|
this.withDirective,
|
|
71258
71318
|
this.paginateDirective,
|
|
71259
71319
|
this.cacheDirective,
|
|
71260
|
-
this.
|
|
71320
|
+
this.manualLoadDirective,
|
|
71321
|
+
this.maskEnableDirective,
|
|
71322
|
+
this.maskDisableDirective
|
|
71261
71323
|
].includes(name2.value) || this.isDeleteDirective(name2.value);
|
|
71262
71324
|
}
|
|
71263
71325
|
isListFragment(name2) {
|
|
@@ -71828,13 +71890,17 @@ function flattenSelections({
|
|
|
71828
71890
|
config: config2,
|
|
71829
71891
|
filepath,
|
|
71830
71892
|
selections,
|
|
71831
|
-
fragmentDefinitions
|
|
71893
|
+
fragmentDefinitions,
|
|
71894
|
+
applyFragments,
|
|
71895
|
+
ignoreMaskDisable
|
|
71832
71896
|
}) {
|
|
71833
71897
|
const fields = new FieldCollection({
|
|
71834
71898
|
config: config2,
|
|
71835
71899
|
filepath,
|
|
71836
71900
|
selections,
|
|
71837
|
-
fragmentDefinitions
|
|
71901
|
+
fragmentDefinitions,
|
|
71902
|
+
applyFragments,
|
|
71903
|
+
ignoreMaskDisable: !!ignoreMaskDisable
|
|
71838
71904
|
});
|
|
71839
71905
|
return fields.toSelectionSet();
|
|
71840
71906
|
}
|
|
@@ -71845,9 +71911,13 @@ var FieldCollection = class {
|
|
|
71845
71911
|
fields;
|
|
71846
71912
|
inlineFragments;
|
|
71847
71913
|
fragmentSpreads;
|
|
71914
|
+
applyFragments;
|
|
71915
|
+
ignoreMaskDisable;
|
|
71848
71916
|
constructor(args) {
|
|
71849
71917
|
this.config = args.config;
|
|
71850
71918
|
this.fragmentDefinitions = args.fragmentDefinitions;
|
|
71919
|
+
this.applyFragments = args.applyFragments;
|
|
71920
|
+
this.ignoreMaskDisable = args.ignoreMaskDisable;
|
|
71851
71921
|
this.fields = {};
|
|
71852
71922
|
this.inlineFragments = {};
|
|
71853
71923
|
this.fragmentSpreads = {};
|
|
@@ -71876,31 +71946,28 @@ var FieldCollection = class {
|
|
|
71876
71946
|
}
|
|
71877
71947
|
}
|
|
71878
71948
|
if (selection2.kind === "InlineFragment" && selection2.typeCondition) {
|
|
71879
|
-
|
|
71880
|
-
if (!this.inlineFragments[key]) {
|
|
71881
|
-
this.inlineFragments[key] = {
|
|
71882
|
-
astNode: selection2,
|
|
71883
|
-
selection: this.empty()
|
|
71884
|
-
};
|
|
71885
|
-
}
|
|
71886
|
-
for (const subselect of selection2.selectionSet?.selections || []) {
|
|
71887
|
-
this.inlineFragments[key].selection.add(subselect);
|
|
71888
|
-
}
|
|
71949
|
+
this.walkInlineFragment(selection2);
|
|
71889
71950
|
return;
|
|
71890
71951
|
}
|
|
71891
71952
|
if (selection2.kind === "FragmentSpread") {
|
|
71892
71953
|
this.fragmentSpreads[selection2.name.value] = selection2;
|
|
71893
|
-
|
|
71894
|
-
|
|
71954
|
+
let includeFragments = this.config.defaultFragmentMasking === "disable";
|
|
71955
|
+
const maskEnableDirective = selection2.directives?.find(
|
|
71956
|
+
({ name: name2 }) => name2.value === this.config.maskEnableDirective
|
|
71895
71957
|
);
|
|
71896
|
-
|
|
71897
|
-
|
|
71958
|
+
if (maskEnableDirective) {
|
|
71959
|
+
includeFragments = false;
|
|
71960
|
+
}
|
|
71961
|
+
const maskDisableDirective = selection2.directives?.find(
|
|
71962
|
+
({ name: name2 }) => name2.value === this.config.maskDisableDirective
|
|
71898
71963
|
);
|
|
71899
|
-
|
|
71900
|
-
|
|
71901
|
-
includeFragments = !maskArgument.value.value;
|
|
71964
|
+
if (maskDisableDirective) {
|
|
71965
|
+
includeFragments = true;
|
|
71902
71966
|
}
|
|
71903
|
-
if (
|
|
71967
|
+
if (this.ignoreMaskDisable) {
|
|
71968
|
+
includeFragments = true;
|
|
71969
|
+
}
|
|
71970
|
+
if (!includeFragments || !this.applyFragments) {
|
|
71904
71971
|
return;
|
|
71905
71972
|
}
|
|
71906
71973
|
const definition = this.fragmentDefinitions[selection2.name.value];
|
|
@@ -71910,9 +71977,20 @@ var FieldCollection = class {
|
|
|
71910
71977
|
message: "Could not find referenced fragment definition: " + selection2.name.value
|
|
71911
71978
|
});
|
|
71912
71979
|
}
|
|
71913
|
-
|
|
71914
|
-
|
|
71915
|
-
|
|
71980
|
+
this.add({
|
|
71981
|
+
kind: "InlineFragment",
|
|
71982
|
+
typeCondition: {
|
|
71983
|
+
kind: "NamedType",
|
|
71984
|
+
name: {
|
|
71985
|
+
kind: "Name",
|
|
71986
|
+
value: definition.typeCondition.name.value
|
|
71987
|
+
}
|
|
71988
|
+
},
|
|
71989
|
+
selectionSet: {
|
|
71990
|
+
kind: "SelectionSet",
|
|
71991
|
+
selections: [...definition.selectionSet.selections]
|
|
71992
|
+
}
|
|
71993
|
+
});
|
|
71916
71994
|
}
|
|
71917
71995
|
}
|
|
71918
71996
|
toSelectionSet() {
|
|
@@ -71928,12 +72006,30 @@ var FieldCollection = class {
|
|
|
71928
72006
|
})
|
|
71929
72007
|
).concat(Object.values(this.fragmentSpreads));
|
|
71930
72008
|
}
|
|
72009
|
+
walkInlineFragment(selection2) {
|
|
72010
|
+
const key = selection2.typeCondition.name.value;
|
|
72011
|
+
if (!this.inlineFragments[key]) {
|
|
72012
|
+
this.inlineFragments[key] = {
|
|
72013
|
+
astNode: selection2,
|
|
72014
|
+
selection: this.empty()
|
|
72015
|
+
};
|
|
72016
|
+
}
|
|
72017
|
+
for (const subselect of selection2.selectionSet.selections || []) {
|
|
72018
|
+
if (subselect.kind !== "InlineFragment" || !subselect.typeCondition) {
|
|
72019
|
+
this.inlineFragments[key].selection.add(subselect);
|
|
72020
|
+
continue;
|
|
72021
|
+
}
|
|
72022
|
+
this.walkInlineFragment(subselect);
|
|
72023
|
+
}
|
|
72024
|
+
}
|
|
71931
72025
|
empty() {
|
|
71932
72026
|
return new FieldCollection({
|
|
71933
72027
|
config: this.config,
|
|
71934
72028
|
fragmentDefinitions: this.fragmentDefinitions,
|
|
71935
72029
|
selections: [],
|
|
71936
|
-
filepath: this.filepath
|
|
72030
|
+
filepath: this.filepath,
|
|
72031
|
+
applyFragments: this.applyFragments,
|
|
72032
|
+
ignoreMaskDisable: this.ignoreMaskDisable
|
|
71937
72033
|
});
|
|
71938
72034
|
}
|
|
71939
72035
|
};
|
|
@@ -72288,11 +72384,6 @@ function operationObject({
|
|
|
72288
72384
|
const when = internalDirectives.find(({ name: name2 }) => name2.value === "when");
|
|
72289
72385
|
const when_not = internalDirectives.find(({ name: name2 }) => name2.value === "when_not");
|
|
72290
72386
|
let parentIDArg = parent?.arguments?.find((argument) => argument.name.value === "value");
|
|
72291
|
-
if (!parentIDArg) {
|
|
72292
|
-
parentIDArg = (append || prepend)?.arguments?.find(
|
|
72293
|
-
({ name: name2 }) => name2.value === config2.listDirectiveParentIDArg
|
|
72294
|
-
);
|
|
72295
|
-
}
|
|
72296
72387
|
if (parentIDArg) {
|
|
72297
72388
|
if (parentIDArg.value.kind === "StringValue") {
|
|
72298
72389
|
parentID = parentIDArg.value.value;
|
|
@@ -73320,6 +73411,8 @@ function selection({
|
|
|
73320
73411
|
markEdges
|
|
73321
73412
|
}) {
|
|
73322
73413
|
let object = {};
|
|
73414
|
+
const typeMap = {};
|
|
73415
|
+
const abstractTypes = [];
|
|
73323
73416
|
for (const field of selections) {
|
|
73324
73417
|
if (field.kind === "FragmentSpread" && includeFragments) {
|
|
73325
73418
|
const fragmentDefinition = document.document.definitions.find(
|
|
@@ -73346,20 +73439,68 @@ function selection({
|
|
|
73346
73439
|
})
|
|
73347
73440
|
);
|
|
73348
73441
|
} else if (field.kind === "InlineFragment") {
|
|
73349
|
-
|
|
73350
|
-
|
|
73351
|
-
object,
|
|
73352
|
-
selection({
|
|
73353
|
-
config: config2,
|
|
73442
|
+
if (!field.typeCondition || field.typeCondition.name.value === rootType) {
|
|
73443
|
+
object.fields = deepMerge(
|
|
73354
73444
|
filepath,
|
|
73355
|
-
|
|
73356
|
-
|
|
73357
|
-
|
|
73358
|
-
|
|
73359
|
-
|
|
73360
|
-
|
|
73361
|
-
|
|
73362
|
-
|
|
73445
|
+
object.fields || {},
|
|
73446
|
+
selection({
|
|
73447
|
+
config: config2,
|
|
73448
|
+
filepath,
|
|
73449
|
+
rootType: field.typeCondition?.name.value || rootType,
|
|
73450
|
+
operations,
|
|
73451
|
+
selections: field.selectionSet.selections,
|
|
73452
|
+
path: path2,
|
|
73453
|
+
includeFragments,
|
|
73454
|
+
document
|
|
73455
|
+
}).fields || {}
|
|
73456
|
+
);
|
|
73457
|
+
} else {
|
|
73458
|
+
if (!object.abstractFields) {
|
|
73459
|
+
object.abstractFields = {
|
|
73460
|
+
fields: {},
|
|
73461
|
+
typeMap: {}
|
|
73462
|
+
};
|
|
73463
|
+
}
|
|
73464
|
+
const parentType = config2.schema.getType(rootType);
|
|
73465
|
+
const typeConditionName = field.typeCondition.name.value;
|
|
73466
|
+
const typeCondition = config2.schema.getType(typeConditionName);
|
|
73467
|
+
const possibleTypes = [];
|
|
73468
|
+
if (!graphql12.isAbstractType(typeCondition)) {
|
|
73469
|
+
} else if (graphql12.isAbstractType(parentType)) {
|
|
73470
|
+
const possibleParentTypes = config2.schema.getPossibleTypes(parentType).map((type) => type.name);
|
|
73471
|
+
for (const possible of config2.schema.getPossibleTypes(typeCondition)) {
|
|
73472
|
+
if (possibleParentTypes.includes(possible.name)) {
|
|
73473
|
+
possibleTypes.push(possible.name);
|
|
73474
|
+
}
|
|
73475
|
+
}
|
|
73476
|
+
} else {
|
|
73477
|
+
possibleTypes.push(rootType);
|
|
73478
|
+
}
|
|
73479
|
+
if (possibleTypes.length > 0) {
|
|
73480
|
+
for (const type of possibleTypes) {
|
|
73481
|
+
const existing = typeMap[type];
|
|
73482
|
+
if (!existing || !existing.includes(type)) {
|
|
73483
|
+
typeMap[type] = [typeConditionName].concat(existing || []);
|
|
73484
|
+
}
|
|
73485
|
+
if (!abstractTypes.includes(typeConditionName)) {
|
|
73486
|
+
abstractTypes.push(typeConditionName);
|
|
73487
|
+
}
|
|
73488
|
+
}
|
|
73489
|
+
}
|
|
73490
|
+
object.abstractFields.fields = {
|
|
73491
|
+
...object.abstractFields.fields,
|
|
73492
|
+
[field.typeCondition.name.value]: selection({
|
|
73493
|
+
config: config2,
|
|
73494
|
+
filepath,
|
|
73495
|
+
rootType: field.typeCondition?.name.value || rootType,
|
|
73496
|
+
operations,
|
|
73497
|
+
selections: field.selectionSet.selections,
|
|
73498
|
+
path: path2,
|
|
73499
|
+
includeFragments,
|
|
73500
|
+
document
|
|
73501
|
+
}).fields
|
|
73502
|
+
};
|
|
73503
|
+
}
|
|
73363
73504
|
} else if (field.kind === "Field") {
|
|
73364
73505
|
const type = config2.schema.getType(rootType);
|
|
73365
73506
|
if (!type) {
|
|
@@ -73417,7 +73558,7 @@ function selection({
|
|
|
73417
73558
|
}
|
|
73418
73559
|
if (field.selectionSet) {
|
|
73419
73560
|
const edgesMark = paginated && document.refetch?.method === "cursor" ? document.refetch.update : markEdges;
|
|
73420
|
-
fieldObj.
|
|
73561
|
+
fieldObj.selection = selection({
|
|
73421
73562
|
config: config2,
|
|
73422
73563
|
filepath,
|
|
73423
73564
|
rootType: typeName,
|
|
@@ -73441,11 +73582,49 @@ function selection({
|
|
|
73441
73582
|
if (graphql12.isInterfaceType(fieldType) || graphql12.isUnionType(fieldType)) {
|
|
73442
73583
|
fieldObj.abstract = true;
|
|
73443
73584
|
}
|
|
73444
|
-
object
|
|
73445
|
-
|
|
73446
|
-
fieldObj
|
|
73447
|
-
|
|
73448
|
-
|
|
73585
|
+
object.fields = {
|
|
73586
|
+
...object.fields,
|
|
73587
|
+
[attributeName]: fieldObj
|
|
73588
|
+
};
|
|
73589
|
+
}
|
|
73590
|
+
}
|
|
73591
|
+
if (Object.keys(object.fields || {}).length > 0 && object.abstractFields && Object.keys(object.abstractFields.fields).length > 0) {
|
|
73592
|
+
for (const [typeName, possibles] of Object.entries(typeMap)) {
|
|
73593
|
+
let overlap = false;
|
|
73594
|
+
for (const possible of possibles) {
|
|
73595
|
+
if (object.abstractFields.fields[typeName]) {
|
|
73596
|
+
object.abstractFields.fields[typeName] = deepMerge(
|
|
73597
|
+
filepath,
|
|
73598
|
+
object.abstractFields.fields[typeName] || {},
|
|
73599
|
+
object.abstractFields.fields[possible]
|
|
73600
|
+
);
|
|
73601
|
+
overlap = true;
|
|
73602
|
+
}
|
|
73603
|
+
}
|
|
73604
|
+
if (overlap) {
|
|
73605
|
+
delete typeMap[typeName];
|
|
73606
|
+
}
|
|
73607
|
+
}
|
|
73608
|
+
for (const [type, options] of Object.entries(typeMap)) {
|
|
73609
|
+
if (options.length > 1) {
|
|
73610
|
+
object.abstractFields.fields[type] = deepMerge(
|
|
73611
|
+
filepath,
|
|
73612
|
+
...options.map((opt) => object.abstractFields.fields[opt] || {})
|
|
73613
|
+
);
|
|
73614
|
+
delete typeMap[type];
|
|
73615
|
+
}
|
|
73616
|
+
}
|
|
73617
|
+
for (const [type, sel] of Object.entries(object.abstractFields?.fields || {})) {
|
|
73618
|
+
object.abstractFields.fields[type] = deepMerge(filepath, sel || {}, object.fields);
|
|
73619
|
+
}
|
|
73620
|
+
for (const [type, options] of Object.entries(typeMap)) {
|
|
73621
|
+
object.abstractFields.typeMap[type] = options[0];
|
|
73622
|
+
}
|
|
73623
|
+
const usedTypes = Object.values(object.abstractFields.typeMap);
|
|
73624
|
+
for (const type of abstractTypes) {
|
|
73625
|
+
if (!usedTypes.includes(type)) {
|
|
73626
|
+
delete object.abstractFields.fields[type];
|
|
73627
|
+
}
|
|
73449
73628
|
}
|
|
73450
73629
|
}
|
|
73451
73630
|
return object;
|
|
@@ -73580,6 +73759,22 @@ function artifactGenerator(stats) {
|
|
|
73580
73759
|
selectionSet = matchingFragment.selectionSet;
|
|
73581
73760
|
}
|
|
73582
73761
|
const inputs = operations[0]?.variableDefinitions;
|
|
73762
|
+
const mergedSelection = flattenSelections({
|
|
73763
|
+
config: config2,
|
|
73764
|
+
filepath: doc.filename,
|
|
73765
|
+
selections: selectionSet.selections,
|
|
73766
|
+
fragmentDefinitions: doc.document.definitions.filter(
|
|
73767
|
+
(definition) => definition.kind === "FragmentDefinition"
|
|
73768
|
+
).reduce(
|
|
73769
|
+
(prev, definition) => ({
|
|
73770
|
+
...prev,
|
|
73771
|
+
[definition.name.value]: definition
|
|
73772
|
+
}),
|
|
73773
|
+
{}
|
|
73774
|
+
),
|
|
73775
|
+
ignoreMaskDisable: docKind === "HoudiniQuery",
|
|
73776
|
+
applyFragments: docKind !== "HoudiniFragment"
|
|
73777
|
+
});
|
|
73583
73778
|
const artifact = {
|
|
73584
73779
|
name: name2,
|
|
73585
73780
|
kind: docKind,
|
|
@@ -73591,7 +73786,7 @@ function artifactGenerator(stats) {
|
|
|
73591
73786
|
config: config2,
|
|
73592
73787
|
filepath: doc.filename,
|
|
73593
73788
|
rootType,
|
|
73594
|
-
selections:
|
|
73789
|
+
selections: mergedSelection,
|
|
73595
73790
|
operations: operationsByPath(
|
|
73596
73791
|
config2,
|
|
73597
73792
|
doc.filename,
|
|
@@ -73887,6 +74082,17 @@ function inlineType({
|
|
|
73887
74082
|
continue;
|
|
73888
74083
|
}
|
|
73889
74084
|
const possibleParents = config2.schema.getPossibleTypes(type).map((t2) => t2.name);
|
|
74085
|
+
const freeSelections = [];
|
|
74086
|
+
const typeSpecificSelections = {};
|
|
74087
|
+
for (const node of selection2.selectionSet.selections) {
|
|
74088
|
+
if (node.kind !== "InlineFragment") {
|
|
74089
|
+
freeSelections.push(node);
|
|
74090
|
+
} else if (node.typeCondition) {
|
|
74091
|
+
typeSpecificSelections[node.typeCondition.name.value] = node.selectionSet.selections;
|
|
74092
|
+
} else {
|
|
74093
|
+
freeSelections.push(...node.selectionSet.selections);
|
|
74094
|
+
}
|
|
74095
|
+
}
|
|
73890
74096
|
for (const possibleType of config2.schema.getPossibleTypes(fragmentType)) {
|
|
73891
74097
|
if (!possibleParents.includes(possibleType.name)) {
|
|
73892
74098
|
continue;
|
|
@@ -73894,7 +74100,12 @@ function inlineType({
|
|
|
73894
74100
|
if (!inlineFragments[possibleType.name]) {
|
|
73895
74101
|
inlineFragments[possibleType.name] = [];
|
|
73896
74102
|
}
|
|
73897
|
-
inlineFragments[possibleType.name].push(...
|
|
74103
|
+
inlineFragments[possibleType.name].push(...freeSelections);
|
|
74104
|
+
if (typeSpecificSelections[possibleType.name]) {
|
|
74105
|
+
inlineFragments[possibleType.name].push(
|
|
74106
|
+
...typeSpecificSelections[possibleType.name]
|
|
74107
|
+
);
|
|
74108
|
+
}
|
|
73898
74109
|
}
|
|
73899
74110
|
} else if (selection2.kind === "InlineFragment" && !selection2.typeCondition) {
|
|
73900
74111
|
selectedFields.push(...selection2.selectionSet.selections);
|
|
@@ -73906,12 +74117,7 @@ function inlineType({
|
|
|
73906
74117
|
...(selectedFields || []).filter(
|
|
73907
74118
|
(field) => field.kind === "Field"
|
|
73908
74119
|
).map((selection2) => {
|
|
73909
|
-
const {
|
|
73910
|
-
config2.schema,
|
|
73911
|
-
filepath,
|
|
73912
|
-
rootObj,
|
|
73913
|
-
selection2
|
|
73914
|
-
);
|
|
74120
|
+
const { field } = selectionTypeInfo(config2.schema, filepath, rootObj, selection2);
|
|
73915
74121
|
const attributeName = selection2.alias?.value || selection2.name.value;
|
|
73916
74122
|
let attributeType = inlineType({
|
|
73917
74123
|
config: config2,
|
|
@@ -74110,7 +74316,8 @@ async function typescriptGenerator(config2, docs) {
|
|
|
74110
74316
|
config: config2,
|
|
74111
74317
|
filepath: filename,
|
|
74112
74318
|
selections: definition.selectionSet.selections,
|
|
74113
|
-
fragmentDefinitions
|
|
74319
|
+
fragmentDefinitions,
|
|
74320
|
+
applyFragments: definition.kind === "OperationDefinition"
|
|
74114
74321
|
});
|
|
74115
74322
|
if (definition?.kind === "OperationDefinition") {
|
|
74116
74323
|
await generateOperationTypeDefs(
|
|
@@ -74623,14 +74830,12 @@ directive @${config2.paginateDirective}(${config2.paginateNameArg}: String) on F
|
|
|
74623
74830
|
"""
|
|
74624
74831
|
@${config2.listPrependDirective} is used to tell the runtime to add the result to the end of the list
|
|
74625
74832
|
"""
|
|
74626
|
-
directive @${config2.listPrependDirective}
|
|
74627
|
-
${config2.listDirectiveParentIDArg}: ID
|
|
74628
|
-
) on FRAGMENT_SPREAD
|
|
74833
|
+
directive @${config2.listPrependDirective} on FRAGMENT_SPREAD
|
|
74629
74834
|
|
|
74630
74835
|
"""
|
|
74631
74836
|
@${config2.listAppendDirective} is used to tell the runtime to add the result to the start of the list
|
|
74632
74837
|
"""
|
|
74633
|
-
directive @${config2.listAppendDirective}
|
|
74838
|
+
directive @${config2.listAppendDirective} on FRAGMENT_SPREAD
|
|
74634
74839
|
|
|
74635
74840
|
"""
|
|
74636
74841
|
@${config2.listAllListsDirective} is used to tell the runtime to add the result to all list
|
|
@@ -74664,18 +74869,19 @@ directive @${config2.argumentsDirective} on FRAGMENT_DEFINITION
|
|
|
74664
74869
|
directive @${config2.cacheDirective}(${config2.cachePolicyArg}: CachePolicy, ${config2.cachePartialArg}: Boolean) on QUERY
|
|
74665
74870
|
|
|
74666
74871
|
"""
|
|
74667
|
-
@${config2.
|
|
74872
|
+
@${config2.manualLoadDirective} is used to disable automatic fetch (no load, no auto fetch in component), you will have to do it manually.
|
|
74873
|
+
"""
|
|
74874
|
+
directive @${config2.manualLoadDirective} on QUERY
|
|
74875
|
+
|
|
74876
|
+
"""
|
|
74877
|
+
@${config2.maskEnableDirective} to enable masking on fragment (overwriting the global conf)
|
|
74878
|
+
"""
|
|
74879
|
+
directive @${config2.maskEnableDirective} on FRAGMENT_SPREAD
|
|
74880
|
+
|
|
74881
|
+
"""
|
|
74882
|
+
@${config2.maskDisableDirective} to disable masking on fragment (overwriting the global conf)
|
|
74668
74883
|
"""
|
|
74669
|
-
directive @${config2.
|
|
74670
|
-
"""
|
|
74671
|
-
Opt-in to an automatic load function (only valid when used at queries)
|
|
74672
|
-
"""
|
|
74673
|
-
load: Boolean! = true
|
|
74674
|
-
"""
|
|
74675
|
-
Mask fragment fields (only valid when used at a fragment spread)
|
|
74676
|
-
"""
|
|
74677
|
-
mask: Boolean! = ${config2.disableMasking ? "false" : "true"}
|
|
74678
|
-
) on QUERY | FRAGMENT_SPREAD
|
|
74884
|
+
directive @${config2.maskDisableDirective} on FRAGMENT_SPREAD
|
|
74679
74885
|
`;
|
|
74680
74886
|
let currentSchema = graphql21.printSchema(config2.schema);
|
|
74681
74887
|
if (!currentSchema.includes(`directive @${config2.listDirective}`)) {
|
|
@@ -75168,26 +75374,42 @@ async function typeCheck(config2, docs) {
|
|
|
75168
75374
|
),
|
|
75169
75375
|
targetField.selectionSet
|
|
75170
75376
|
);
|
|
75171
|
-
|
|
75172
|
-
if (
|
|
75173
|
-
|
|
75174
|
-
|
|
75175
|
-
|
|
75176
|
-
|
|
75177
|
-
|
|
75178
|
-
|
|
75179
|
-
|
|
75180
|
-
|
|
75181
|
-
|
|
75182
|
-
|
|
75183
|
-
|
|
75184
|
-
|
|
75185
|
-
|
|
75186
|
-
|
|
75187
|
-
|
|
75188
|
-
)
|
|
75377
|
+
let targetTypes = [type];
|
|
75378
|
+
if (graphql25.isUnionType(type)) {
|
|
75379
|
+
targetTypes = config2.schema.getPossibleTypes(type);
|
|
75380
|
+
} else if (graphql25.isInterfaceType(type)) {
|
|
75381
|
+
try {
|
|
75382
|
+
for (const key of config2.keyFieldsForType(type.name)) {
|
|
75383
|
+
if (!type.getFields()[key]) {
|
|
75384
|
+
throw new Error("continue");
|
|
75385
|
+
}
|
|
75386
|
+
}
|
|
75387
|
+
} catch {
|
|
75388
|
+
targetTypes = config2.schema.getPossibleTypes(type);
|
|
75389
|
+
}
|
|
75390
|
+
}
|
|
75391
|
+
for (const targetType of targetTypes) {
|
|
75392
|
+
const missingIDFields = config2.keyFieldsForType(targetType.name).filter((fieldName) => !targetType.getFields()[fieldName]);
|
|
75393
|
+
if (missingIDFields.length > 0) {
|
|
75394
|
+
if (error) {
|
|
75395
|
+
errors.push(
|
|
75396
|
+
new HoudiniError({
|
|
75397
|
+
filepath: filename,
|
|
75398
|
+
message: error
|
|
75399
|
+
})
|
|
75400
|
+
);
|
|
75401
|
+
} else {
|
|
75402
|
+
errors.push(
|
|
75403
|
+
new HoudiniError({
|
|
75404
|
+
filepath: filename,
|
|
75405
|
+
message: `@${config2.listDirective} can only be applied to types with the necessary id fields: ${missingIDFields.join(
|
|
75406
|
+
", "
|
|
75407
|
+
)}.`
|
|
75408
|
+
})
|
|
75409
|
+
);
|
|
75410
|
+
}
|
|
75411
|
+
return;
|
|
75189
75412
|
}
|
|
75190
|
-
return;
|
|
75191
75413
|
}
|
|
75192
75414
|
lists.push(listName);
|
|
75193
75415
|
listTypes.push(type.name);
|
|
@@ -75217,6 +75439,7 @@ async function typeCheck(config2, docs) {
|
|
|
75217
75439
|
fragments
|
|
75218
75440
|
}),
|
|
75219
75441
|
checkMutationOperation(config2),
|
|
75442
|
+
checkMaskDirective(config2),
|
|
75220
75443
|
nodeDirectives(config2, [config2.paginateDirective]),
|
|
75221
75444
|
knownArguments(config2),
|
|
75222
75445
|
validateFragmentArguments(config2, filepath, fragments),
|
|
@@ -75281,10 +75504,14 @@ var validateLists = ({
|
|
|
75281
75504
|
]);
|
|
75282
75505
|
if (directive) {
|
|
75283
75506
|
let parentArg = directive.arguments?.find(
|
|
75284
|
-
(arg) => arg.name.value === config2.
|
|
75507
|
+
(arg) => arg.name.value === config2.deprecatedlistDirectiveParentIDArg
|
|
75285
75508
|
);
|
|
75286
75509
|
if (parentArg) {
|
|
75287
|
-
|
|
75510
|
+
ctx.reportError(
|
|
75511
|
+
new graphql25.GraphQLError(
|
|
75512
|
+
`@${config2.deprecatedlistDirectiveParentIDArg} should be defined only in it's own directive now`
|
|
75513
|
+
)
|
|
75514
|
+
);
|
|
75288
75515
|
}
|
|
75289
75516
|
}
|
|
75290
75517
|
if (parentIdFound) {
|
|
@@ -75680,6 +75907,28 @@ function checkMutationOperation(config2) {
|
|
|
75680
75907
|
};
|
|
75681
75908
|
};
|
|
75682
75909
|
}
|
|
75910
|
+
function checkMaskDirective(config2) {
|
|
75911
|
+
return function(ctx) {
|
|
75912
|
+
return {
|
|
75913
|
+
FragmentSpread(node, _, __, ___, ancestors) {
|
|
75914
|
+
const maskEnableDirective = node.directives?.find(
|
|
75915
|
+
(c) => c.name.value === config2.maskEnableDirective
|
|
75916
|
+
);
|
|
75917
|
+
const maskDisableDirective = node.directives?.find(
|
|
75918
|
+
(c) => c.name.value === config2.maskDisableDirective
|
|
75919
|
+
);
|
|
75920
|
+
if (maskEnableDirective && maskDisableDirective) {
|
|
75921
|
+
ctx.reportError(
|
|
75922
|
+
new graphql25.GraphQLError(
|
|
75923
|
+
`You can't apply both @${config2.maskEnableDirective} and @${config2.maskDisableDirective} at the same time`
|
|
75924
|
+
)
|
|
75925
|
+
);
|
|
75926
|
+
return;
|
|
75927
|
+
}
|
|
75928
|
+
}
|
|
75929
|
+
};
|
|
75930
|
+
};
|
|
75931
|
+
}
|
|
75683
75932
|
function getAndVerifyNodeInterface(config2) {
|
|
75684
75933
|
const { schema } = config2;
|
|
75685
75934
|
const nodeInterface = schema.getType("Node");
|
|
@@ -75977,12 +76226,7 @@ async function collectDocuments(config2) {
|
|
|
75977
76226
|
}
|
|
75978
76227
|
async function processJSFile(config2, contents) {
|
|
75979
76228
|
const documents = [];
|
|
75980
|
-
|
|
75981
|
-
var program3 = (await parseJS(contents)).script;
|
|
75982
|
-
} catch (e2) {
|
|
75983
|
-
console.log(contents);
|
|
75984
|
-
throw e2;
|
|
75985
|
-
}
|
|
76229
|
+
var program3 = (await parseJS(contents)).script;
|
|
75986
76230
|
await find_graphql(config2, program3, {
|
|
75987
76231
|
tag({ tagContent }) {
|
|
75988
76232
|
documents.push(tagContent);
|
|
@@ -76282,7 +76526,6 @@ async function init(_path, args) {
|
|
|
76282
76526
|
const sourceDir = path_exports.join(targetPath, "src");
|
|
76283
76527
|
const configPath = path_exports.join(targetPath, "houdini.config.js");
|
|
76284
76528
|
const houdiniClientPath = typescript ? path_exports.join(sourceDir, "client.ts") : path_exports.join(sourceDir, "client.js");
|
|
76285
|
-
const houdiniClientImport = "./src/client";
|
|
76286
76529
|
console.log("\u{1F6A7} Generating project files...");
|
|
76287
76530
|
await updatePackageJSON(targetPath);
|
|
76288
76531
|
if (is_remote_endpoint) {
|
|
@@ -76292,8 +76535,7 @@ async function init(_path, args) {
|
|
|
76292
76535
|
configPath,
|
|
76293
76536
|
schemaPath,
|
|
76294
76537
|
module,
|
|
76295
|
-
url: is_remote_endpoint ? url : null
|
|
76296
|
-
houdiniClientImport
|
|
76538
|
+
url: is_remote_endpoint ? url : null
|
|
76297
76539
|
});
|
|
76298
76540
|
await fs_exports.writeFile(houdiniClientPath, networkFile(url, typescript));
|
|
76299
76541
|
await graphqlRCFile(targetPath);
|
|
@@ -76350,8 +76592,7 @@ var writeConfigFile = async ({
|
|
|
76350
76592
|
configPath,
|
|
76351
76593
|
schemaPath,
|
|
76352
76594
|
module,
|
|
76353
|
-
url
|
|
76354
|
-
houdiniClientImport
|
|
76595
|
+
url
|
|
76355
76596
|
}) => {
|
|
76356
76597
|
const config2 = {};
|
|
76357
76598
|
if (url !== null) {
|
|
@@ -76364,9 +76605,7 @@ var writeConfigFile = async ({
|
|
|
76364
76605
|
config2.module = module;
|
|
76365
76606
|
}
|
|
76366
76607
|
config2.plugins = {
|
|
76367
|
-
"houdini-svelte": {
|
|
76368
|
-
client: houdiniClientImport
|
|
76369
|
-
}
|
|
76608
|
+
"houdini-svelte": {}
|
|
76370
76609
|
};
|
|
76371
76610
|
const configObj = JSON.stringify(config2, null, 4);
|
|
76372
76611
|
const content_base = `/// <references types="houdini-svelte">
|
|
@@ -76540,8 +76779,8 @@ async function updatePackageJSON(targetPath) {
|
|
|
76540
76779
|
}
|
|
76541
76780
|
packageJSON.devDependencies = {
|
|
76542
76781
|
...packageJSON.devDependencies,
|
|
76543
|
-
houdini: "^0.
|
|
76544
|
-
"houdini-svelte": "^0.
|
|
76782
|
+
houdini: "^0.18.1",
|
|
76783
|
+
"houdini-svelte": "^0.18.1",
|
|
76545
76784
|
graphql: "^15.8.0"
|
|
76546
76785
|
};
|
|
76547
76786
|
await fs_exports.writeFile(packagePath, JSON.stringify(packageJSON, null, 4));
|