houdini 0.17.14 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cmd-cjs/index.js +438 -201
- package/build/cmd-esm/index.js +438 -201
- package/build/codegen/utils/flattenSelections.d.ts +3 -1
- package/build/codegen-cjs/index.js +405 -180
- package/build/codegen-esm/index.js +405 -180
- package/build/lib/config.d.ts +8 -3
- package/build/lib-cjs/index.js +141 -81
- package/build/lib-esm/index.js +141 -81
- 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 +38 -23
- 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 +38 -23
- 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 +485 -195
- package/build/test-esm/index.js +485 -195
- package/build/vite-cjs/index.js +438 -193
- package/build/vite-esm/index.js +438 -193
- package/package.json +1 -1
- 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-cjs/index.js
CHANGED
|
@@ -5099,7 +5099,7 @@ var require_definition = __commonJS({
|
|
|
5099
5099
|
exports.assertObjectType = assertObjectType;
|
|
5100
5100
|
exports.isInterfaceType = isInterfaceType12;
|
|
5101
5101
|
exports.assertInterfaceType = assertInterfaceType;
|
|
5102
|
-
exports.isUnionType =
|
|
5102
|
+
exports.isUnionType = isUnionType13;
|
|
5103
5103
|
exports.assertUnionType = assertUnionType;
|
|
5104
5104
|
exports.isEnumType = isEnumType9;
|
|
5105
5105
|
exports.assertEnumType = assertEnumType;
|
|
@@ -5117,7 +5117,7 @@ var require_definition = __commonJS({
|
|
|
5117
5117
|
exports.assertLeafType = assertLeafType;
|
|
5118
5118
|
exports.isCompositeType = isCompositeType;
|
|
5119
5119
|
exports.assertCompositeType = assertCompositeType;
|
|
5120
|
-
exports.isAbstractType =
|
|
5120
|
+
exports.isAbstractType = isAbstractType2;
|
|
5121
5121
|
exports.assertAbstractType = assertAbstractType;
|
|
5122
5122
|
exports.GraphQLList = GraphQLList6;
|
|
5123
5123
|
exports.GraphQLNonNull = GraphQLNonNull6;
|
|
@@ -5172,7 +5172,7 @@ var require_definition = __commonJS({
|
|
|
5172
5172
|
return Constructor;
|
|
5173
5173
|
}
|
|
5174
5174
|
function isType(type) {
|
|
5175
|
-
return isScalarType12(type) || isObjectType11(type) || isInterfaceType12(type) ||
|
|
5175
|
+
return isScalarType12(type) || isObjectType11(type) || isInterfaceType12(type) || isUnionType13(type) || isEnumType9(type) || isInputObjectType7(type) || isListType8(type) || isNonNullType10(type);
|
|
5176
5176
|
}
|
|
5177
5177
|
function assertType(type) {
|
|
5178
5178
|
if (!isType(type)) {
|
|
@@ -5207,11 +5207,11 @@ var require_definition = __commonJS({
|
|
|
5207
5207
|
}
|
|
5208
5208
|
return type;
|
|
5209
5209
|
}
|
|
5210
|
-
function
|
|
5210
|
+
function isUnionType13(type) {
|
|
5211
5211
|
return (0, _instanceOf.default)(type, GraphQLUnionType3);
|
|
5212
5212
|
}
|
|
5213
5213
|
function assertUnionType(type) {
|
|
5214
|
-
if (!
|
|
5214
|
+
if (!isUnionType13(type)) {
|
|
5215
5215
|
throw new Error("Expected ".concat((0, _inspect.default)(type), " to be a GraphQL Union type."));
|
|
5216
5216
|
}
|
|
5217
5217
|
return type;
|
|
@@ -5262,7 +5262,7 @@ var require_definition = __commonJS({
|
|
|
5262
5262
|
return type;
|
|
5263
5263
|
}
|
|
5264
5264
|
function isOutputType(type) {
|
|
5265
|
-
return isScalarType12(type) || isObjectType11(type) || isInterfaceType12(type) ||
|
|
5265
|
+
return isScalarType12(type) || isObjectType11(type) || isInterfaceType12(type) || isUnionType13(type) || isEnumType9(type) || isWrappingType(type) && isOutputType(type.ofType);
|
|
5266
5266
|
}
|
|
5267
5267
|
function assertOutputType(type) {
|
|
5268
5268
|
if (!isOutputType(type)) {
|
|
@@ -5280,7 +5280,7 @@ var require_definition = __commonJS({
|
|
|
5280
5280
|
return type;
|
|
5281
5281
|
}
|
|
5282
5282
|
function isCompositeType(type) {
|
|
5283
|
-
return isObjectType11(type) || isInterfaceType12(type) ||
|
|
5283
|
+
return isObjectType11(type) || isInterfaceType12(type) || isUnionType13(type);
|
|
5284
5284
|
}
|
|
5285
5285
|
function assertCompositeType(type) {
|
|
5286
5286
|
if (!isCompositeType(type)) {
|
|
@@ -5288,11 +5288,11 @@ var require_definition = __commonJS({
|
|
|
5288
5288
|
}
|
|
5289
5289
|
return type;
|
|
5290
5290
|
}
|
|
5291
|
-
function
|
|
5292
|
-
return isInterfaceType12(type) ||
|
|
5291
|
+
function isAbstractType2(type) {
|
|
5292
|
+
return isInterfaceType12(type) || isUnionType13(type);
|
|
5293
5293
|
}
|
|
5294
5294
|
function assertAbstractType(type) {
|
|
5295
|
-
if (!
|
|
5295
|
+
if (!isAbstractType2(type)) {
|
|
5296
5296
|
throw new Error("Expected ".concat((0, _inspect.default)(type), " to be a GraphQL abstract type."));
|
|
5297
5297
|
}
|
|
5298
5298
|
return type;
|
|
@@ -5359,7 +5359,7 @@ var require_definition = __commonJS({
|
|
|
5359
5359
|
}
|
|
5360
5360
|
}
|
|
5361
5361
|
function isNamedType4(type) {
|
|
5362
|
-
return isScalarType12(type) || isObjectType11(type) || isInterfaceType12(type) ||
|
|
5362
|
+
return isScalarType12(type) || isObjectType11(type) || isInterfaceType12(type) || isUnionType13(type) || isEnumType9(type) || isInputObjectType7(type);
|
|
5363
5363
|
}
|
|
5364
5364
|
function assertNamedType(type) {
|
|
5365
5365
|
if (!isNamedType4(type)) {
|
|
@@ -67736,6 +67736,20 @@ function deepEquals(objA, objB, map = /* @__PURE__ */ new WeakMap()) {
|
|
|
67736
67736
|
return true;
|
|
67737
67737
|
}
|
|
67738
67738
|
|
|
67739
|
+
// src/runtime/lib/selection.ts
|
|
67740
|
+
function getFieldsForType(selection2, __typename) {
|
|
67741
|
+
let targetSelection = selection2.fields || {};
|
|
67742
|
+
if (selection2.abstractFields && __typename) {
|
|
67743
|
+
const mappedType = selection2.abstractFields.typeMap[__typename];
|
|
67744
|
+
if (mappedType) {
|
|
67745
|
+
targetSelection = selection2.abstractFields.fields[mappedType];
|
|
67746
|
+
} else if (selection2.abstractFields.fields[__typename]) {
|
|
67747
|
+
targetSelection = selection2.abstractFields.fields[__typename];
|
|
67748
|
+
}
|
|
67749
|
+
}
|
|
67750
|
+
return targetSelection;
|
|
67751
|
+
}
|
|
67752
|
+
|
|
67739
67753
|
// src/runtime/cache/gc.ts
|
|
67740
67754
|
var GarbageCollector = class {
|
|
67741
67755
|
cache;
|
|
@@ -67958,23 +67972,32 @@ var List = class {
|
|
|
67958
67972
|
let insertData = data;
|
|
67959
67973
|
if (this.connection) {
|
|
67960
67974
|
insertSelection = {
|
|
67961
|
-
|
|
67962
|
-
|
|
67963
|
-
|
|
67964
|
-
|
|
67965
|
-
|
|
67966
|
-
keyRaw: "edges",
|
|
67967
|
-
type: "ConnectionEdge",
|
|
67968
|
-
update: where === "first" ? "prepend" : "append",
|
|
67975
|
+
fields: {
|
|
67976
|
+
newEntry: {
|
|
67977
|
+
keyRaw: this.key,
|
|
67978
|
+
type: "Connection",
|
|
67979
|
+
selection: {
|
|
67969
67980
|
fields: {
|
|
67970
|
-
|
|
67971
|
-
|
|
67972
|
-
|
|
67973
|
-
|
|
67974
|
-
|
|
67975
|
-
|
|
67976
|
-
|
|
67977
|
-
|
|
67981
|
+
edges: {
|
|
67982
|
+
keyRaw: "edges",
|
|
67983
|
+
type: "ConnectionEdge",
|
|
67984
|
+
update: where === "first" ? "prepend" : "append",
|
|
67985
|
+
selection: {
|
|
67986
|
+
fields: {
|
|
67987
|
+
node: {
|
|
67988
|
+
type: listType,
|
|
67989
|
+
keyRaw: "node",
|
|
67990
|
+
selection: {
|
|
67991
|
+
...selection2,
|
|
67992
|
+
fields: {
|
|
67993
|
+
...selection2.fields,
|
|
67994
|
+
__typename: {
|
|
67995
|
+
keyRaw: "__typename",
|
|
67996
|
+
type: "String"
|
|
67997
|
+
}
|
|
67998
|
+
}
|
|
67999
|
+
}
|
|
68000
|
+
}
|
|
67978
68001
|
}
|
|
67979
68002
|
}
|
|
67980
68003
|
}
|
|
@@ -67990,15 +68013,20 @@ var List = class {
|
|
|
67990
68013
|
};
|
|
67991
68014
|
} else {
|
|
67992
68015
|
insertSelection = {
|
|
67993
|
-
|
|
67994
|
-
|
|
67995
|
-
|
|
67996
|
-
|
|
67997
|
-
|
|
67998
|
-
|
|
67999
|
-
|
|
68000
|
-
|
|
68001
|
-
|
|
68016
|
+
fields: {
|
|
68017
|
+
newEntries: {
|
|
68018
|
+
keyRaw: this.key,
|
|
68019
|
+
type: listType,
|
|
68020
|
+
update: where === "first" ? "prepend" : "append",
|
|
68021
|
+
selection: {
|
|
68022
|
+
...selection2,
|
|
68023
|
+
fields: {
|
|
68024
|
+
...selection2.fields,
|
|
68025
|
+
__typename: {
|
|
68026
|
+
keyRaw: "__typename",
|
|
68027
|
+
type: "String"
|
|
68028
|
+
}
|
|
68029
|
+
}
|
|
68002
68030
|
}
|
|
68003
68031
|
}
|
|
68004
68032
|
}
|
|
@@ -68058,7 +68086,7 @@ var List = class {
|
|
|
68058
68086
|
const subscribers = this.cache._internal_unstable.subscriptions.get(this.recordID, this.key);
|
|
68059
68087
|
this.cache._internal_unstable.subscriptions.remove(
|
|
68060
68088
|
targetID,
|
|
68061
|
-
this.connection ? this.selection.edges.
|
|
68089
|
+
this.connection ? this.selection.fields.edges.selection : this.selection,
|
|
68062
68090
|
subscribers,
|
|
68063
68091
|
variables
|
|
68064
68092
|
);
|
|
@@ -68547,18 +68575,20 @@ var InMemorySubscriptions = class {
|
|
|
68547
68575
|
variables,
|
|
68548
68576
|
parentType
|
|
68549
68577
|
}) {
|
|
68550
|
-
|
|
68551
|
-
|
|
68578
|
+
const __typename = this.cache._internal_unstable.storage.get(parent, "__typename").value;
|
|
68579
|
+
let targetSelection = getFieldsForType(selection2, __typename);
|
|
68580
|
+
for (const fieldSelection of Object.values(targetSelection || {})) {
|
|
68581
|
+
const { keyRaw, selection: innerSelection, type } = fieldSelection;
|
|
68552
68582
|
const key = evaluateKey(keyRaw, variables);
|
|
68553
68583
|
this.addFieldSubscription({
|
|
68554
68584
|
id: parent,
|
|
68555
68585
|
key,
|
|
68556
|
-
|
|
68586
|
+
field: fieldSelection,
|
|
68557
68587
|
spec,
|
|
68558
68588
|
parentType: parentType || spec.rootType,
|
|
68559
68589
|
variables
|
|
68560
68590
|
});
|
|
68561
|
-
if (
|
|
68591
|
+
if (innerSelection) {
|
|
68562
68592
|
const { value: linkedRecord } = this.cache._internal_unstable.storage.get(
|
|
68563
68593
|
parent,
|
|
68564
68594
|
key
|
|
@@ -68571,7 +68601,7 @@ var InMemorySubscriptions = class {
|
|
|
68571
68601
|
this.add({
|
|
68572
68602
|
parent: child,
|
|
68573
68603
|
spec,
|
|
68574
|
-
selection:
|
|
68604
|
+
selection: innerSelection,
|
|
68575
68605
|
variables,
|
|
68576
68606
|
parentType: type
|
|
68577
68607
|
});
|
|
@@ -68582,7 +68612,7 @@ var InMemorySubscriptions = class {
|
|
|
68582
68612
|
addFieldSubscription({
|
|
68583
68613
|
id,
|
|
68584
68614
|
key,
|
|
68585
|
-
|
|
68615
|
+
field,
|
|
68586
68616
|
spec,
|
|
68587
68617
|
parentType,
|
|
68588
68618
|
variables
|
|
@@ -68609,8 +68639,8 @@ var InMemorySubscriptions = class {
|
|
|
68609
68639
|
const counts = this.referenceCounts[id][key];
|
|
68610
68640
|
counts.set(spec.set, (counts.get(spec.set) || 0) + 1);
|
|
68611
68641
|
this.cache._internal_unstable.lifetimes.resetLifetime(id, key);
|
|
68612
|
-
const {
|
|
68613
|
-
if (
|
|
68642
|
+
const { selection: selection2, list, filters } = field;
|
|
68643
|
+
if (selection2 && list) {
|
|
68614
68644
|
this.cache._internal_unstable.lists.add({
|
|
68615
68645
|
name: list.name,
|
|
68616
68646
|
connection: list.connection,
|
|
@@ -68618,7 +68648,7 @@ var InMemorySubscriptions = class {
|
|
|
68618
68648
|
recordType: this.cache._internal_unstable.storage.get(id, "__typename")?.value || parentType,
|
|
68619
68649
|
listType: list.type,
|
|
68620
68650
|
key,
|
|
68621
|
-
selection:
|
|
68651
|
+
selection: selection2,
|
|
68622
68652
|
filters: Object.entries(filters || {}).reduce((acc, [key2, { kind, value }]) => {
|
|
68623
68653
|
return {
|
|
68624
68654
|
...acc,
|
|
@@ -68635,20 +68665,21 @@ var InMemorySubscriptions = class {
|
|
|
68635
68665
|
subscribers,
|
|
68636
68666
|
parentType
|
|
68637
68667
|
}) {
|
|
68638
|
-
|
|
68639
|
-
|
|
68668
|
+
let targetSelection = getFieldsForType(selection2, parentType);
|
|
68669
|
+
for (const fieldSelection of Object.values(targetSelection)) {
|
|
68670
|
+
const { type: linkedType, keyRaw, selection: innerSelection } = fieldSelection;
|
|
68640
68671
|
const key = evaluateKey(keyRaw, variables);
|
|
68641
68672
|
for (const spec of subscribers) {
|
|
68642
68673
|
this.addFieldSubscription({
|
|
68643
68674
|
id: parent,
|
|
68644
68675
|
key,
|
|
68645
|
-
|
|
68676
|
+
field: fieldSelection,
|
|
68646
68677
|
spec,
|
|
68647
68678
|
parentType,
|
|
68648
68679
|
variables
|
|
68649
68680
|
});
|
|
68650
68681
|
}
|
|
68651
|
-
if (
|
|
68682
|
+
if (innerSelection) {
|
|
68652
68683
|
const { value: link } = this.cache._internal_unstable.storage.get(parent, key);
|
|
68653
68684
|
const children = !Array.isArray(link) ? [link] : flattenList(link);
|
|
68654
68685
|
for (const linkedRecord of children) {
|
|
@@ -68657,7 +68688,7 @@ var InMemorySubscriptions = class {
|
|
|
68657
68688
|
}
|
|
68658
68689
|
this.addMany({
|
|
68659
68690
|
parent: linkedRecord,
|
|
68660
|
-
selection:
|
|
68691
|
+
selection: innerSelection,
|
|
68661
68692
|
variables,
|
|
68662
68693
|
subscribers,
|
|
68663
68694
|
parentType: linkedType
|
|
@@ -68669,22 +68700,20 @@ var InMemorySubscriptions = class {
|
|
|
68669
68700
|
get(id, field) {
|
|
68670
68701
|
return this.subscribers[id]?.[field] || [];
|
|
68671
68702
|
}
|
|
68672
|
-
remove(id,
|
|
68703
|
+
remove(id, selection2, targets, variables, visited = []) {
|
|
68673
68704
|
visited.push(id);
|
|
68674
68705
|
const linkedIDs = [];
|
|
68675
|
-
for (const
|
|
68676
|
-
const key = evaluateKey(
|
|
68706
|
+
for (const fieldSelection of Object.values(selection2.fields || {})) {
|
|
68707
|
+
const key = evaluateKey(fieldSelection.keyRaw, variables);
|
|
68677
68708
|
this.removeSubscribers(id, key, targets);
|
|
68678
|
-
if (!
|
|
68709
|
+
if (!fieldSelection.selection?.fields) {
|
|
68679
68710
|
continue;
|
|
68680
68711
|
}
|
|
68681
|
-
if (selection2.list) {
|
|
68682
|
-
}
|
|
68683
68712
|
const { value: previousValue } = this.cache._internal_unstable.storage.get(id, key);
|
|
68684
68713
|
const links = !Array.isArray(previousValue) ? [previousValue] : flattenList(previousValue);
|
|
68685
68714
|
for (const link of links) {
|
|
68686
68715
|
if (link !== null) {
|
|
68687
|
-
linkedIDs.push([link,
|
|
68716
|
+
linkedIDs.push([link, fieldSelection.selection || {}]);
|
|
68688
68717
|
}
|
|
68689
68718
|
}
|
|
68690
68719
|
}
|
|
@@ -68862,8 +68891,9 @@ var CacheInternal = class {
|
|
|
68862
68891
|
if (this._disabled) {
|
|
68863
68892
|
return [];
|
|
68864
68893
|
}
|
|
68894
|
+
let targetSelection = getFieldsForType(selection2, data["__typename"]);
|
|
68865
68895
|
for (const [field, value] of Object.entries(data)) {
|
|
68866
|
-
if (!selection2 || !
|
|
68896
|
+
if (!selection2 || !targetSelection[field]) {
|
|
68867
68897
|
throw new Error(
|
|
68868
68898
|
"Could not find field listing in selection for " + field + " @ " + JSON.stringify(selection2)
|
|
68869
68899
|
);
|
|
@@ -68871,11 +68901,11 @@ var CacheInternal = class {
|
|
|
68871
68901
|
let {
|
|
68872
68902
|
type: linkedType,
|
|
68873
68903
|
keyRaw,
|
|
68874
|
-
|
|
68904
|
+
selection: fieldSelection,
|
|
68875
68905
|
operations,
|
|
68876
68906
|
abstract: isAbstract,
|
|
68877
68907
|
update
|
|
68878
|
-
} =
|
|
68908
|
+
} = targetSelection[field];
|
|
68879
68909
|
const key = evaluateKey(keyRaw, variables);
|
|
68880
68910
|
const currentSubscribers = this.subscriptions.get(parent, key);
|
|
68881
68911
|
const { value: previousValue, displayLayers } = this.storage.get(parent, key);
|
|
@@ -68883,7 +68913,7 @@ var CacheInternal = class {
|
|
|
68883
68913
|
if (displayLayer) {
|
|
68884
68914
|
this.lifetimes.resetLifetime(parent, key);
|
|
68885
68915
|
}
|
|
68886
|
-
if (!
|
|
68916
|
+
if (!fieldSelection) {
|
|
68887
68917
|
let newValue = value;
|
|
68888
68918
|
if (Array.isArray(value) && applyUpdates && update) {
|
|
68889
68919
|
if (update === "append") {
|
|
@@ -68903,7 +68933,7 @@ var CacheInternal = class {
|
|
|
68903
68933
|
}
|
|
68904
68934
|
const previousLinks = flattenList([previousValue]);
|
|
68905
68935
|
for (const link of previousLinks) {
|
|
68906
|
-
this.subscriptions.remove(link,
|
|
68936
|
+
this.subscriptions.remove(link, fieldSelection, currentSubscribers, variables);
|
|
68907
68937
|
}
|
|
68908
68938
|
layer.writeLink(parent, key, null);
|
|
68909
68939
|
toNotify.push(...currentSubscribers);
|
|
@@ -68929,14 +68959,14 @@ var CacheInternal = class {
|
|
|
68929
68959
|
if (previousValue && typeof previousValue === "string") {
|
|
68930
68960
|
this.subscriptions.remove(
|
|
68931
68961
|
previousValue,
|
|
68932
|
-
|
|
68962
|
+
fieldSelection,
|
|
68933
68963
|
currentSubscribers,
|
|
68934
68964
|
variables
|
|
68935
68965
|
);
|
|
68936
68966
|
}
|
|
68937
68967
|
this.subscriptions.addMany({
|
|
68938
68968
|
parent: linkedID,
|
|
68939
|
-
selection:
|
|
68969
|
+
selection: fieldSelection,
|
|
68940
68970
|
subscribers: currentSubscribers,
|
|
68941
68971
|
variables,
|
|
68942
68972
|
parentType: linkedType
|
|
@@ -68946,14 +68976,14 @@ var CacheInternal = class {
|
|
|
68946
68976
|
if (linkedID) {
|
|
68947
68977
|
this.writeSelection({
|
|
68948
68978
|
root,
|
|
68949
|
-
selection:
|
|
68979
|
+
selection: fieldSelection,
|
|
68950
68980
|
parent: linkedID,
|
|
68951
68981
|
data: value,
|
|
68952
68982
|
variables,
|
|
68953
68983
|
toNotify,
|
|
68954
68984
|
applyUpdates,
|
|
68955
68985
|
layer,
|
|
68956
|
-
forceNotify
|
|
68986
|
+
forceNotify
|
|
68957
68987
|
});
|
|
68958
68988
|
}
|
|
68959
68989
|
} else if (Array.isArray(value) && (typeof previousValue === "undefined" || Array.isArray(previousValue))) {
|
|
@@ -68982,7 +69012,7 @@ var CacheInternal = class {
|
|
|
68982
69012
|
key,
|
|
68983
69013
|
linkedType,
|
|
68984
69014
|
variables,
|
|
68985
|
-
fields,
|
|
69015
|
+
fields: fieldSelection,
|
|
68986
69016
|
layer,
|
|
68987
69017
|
forceNotify
|
|
68988
69018
|
});
|
|
@@ -69032,7 +69062,7 @@ var CacheInternal = class {
|
|
|
69032
69062
|
if (linkedIDs.includes(lostID) || !lostID) {
|
|
69033
69063
|
continue;
|
|
69034
69064
|
}
|
|
69035
|
-
this.subscriptions.remove(lostID,
|
|
69065
|
+
this.subscriptions.remove(lostID, fieldSelection, currentSubscribers, variables);
|
|
69036
69066
|
}
|
|
69037
69067
|
if (contentChanged || oldIDs.length === 0 && newIDs.length === 0) {
|
|
69038
69068
|
layer.writeLink(parent, key, linkedIDs);
|
|
@@ -69043,7 +69073,7 @@ var CacheInternal = class {
|
|
|
69043
69073
|
}
|
|
69044
69074
|
this.subscriptions.addMany({
|
|
69045
69075
|
parent: id,
|
|
69046
|
-
selection:
|
|
69076
|
+
selection: fieldSelection,
|
|
69047
69077
|
subscribers: currentSubscribers,
|
|
69048
69078
|
variables,
|
|
69049
69079
|
parentType: linkedType
|
|
@@ -69068,9 +69098,14 @@ var CacheInternal = class {
|
|
|
69068
69098
|
}
|
|
69069
69099
|
const targets = Array.isArray(value) ? value : [value];
|
|
69070
69100
|
for (const target of targets) {
|
|
69071
|
-
if (operation.action === "insert" && target instanceof Object &&
|
|
69072
|
-
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).addToList(
|
|
69073
|
-
|
|
69101
|
+
if (operation.action === "insert" && target instanceof Object && fieldSelection && operation.list) {
|
|
69102
|
+
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).addToList(
|
|
69103
|
+
fieldSelection,
|
|
69104
|
+
target,
|
|
69105
|
+
variables,
|
|
69106
|
+
operation.position || "last"
|
|
69107
|
+
);
|
|
69108
|
+
} else if (operation.action === "remove" && target instanceof Object && fieldSelection && operation.list) {
|
|
69074
69109
|
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables);
|
|
69075
69110
|
} else if (operation.action === "delete" && operation.type) {
|
|
69076
69111
|
if (typeof target !== "string") {
|
|
@@ -69081,8 +69116,13 @@ var CacheInternal = class {
|
|
|
69081
69116
|
continue;
|
|
69082
69117
|
}
|
|
69083
69118
|
this.cache.delete(targetID);
|
|
69084
|
-
} else if (operation.action === "toggle" && target instanceof Object &&
|
|
69085
|
-
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement(
|
|
69119
|
+
} else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
|
|
69120
|
+
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement(
|
|
69121
|
+
fieldSelection,
|
|
69122
|
+
target,
|
|
69123
|
+
variables,
|
|
69124
|
+
operation.position || "last"
|
|
69125
|
+
);
|
|
69086
69126
|
}
|
|
69087
69127
|
}
|
|
69088
69128
|
}
|
|
@@ -69102,9 +69142,12 @@ var CacheInternal = class {
|
|
|
69102
69142
|
let hasData = false;
|
|
69103
69143
|
let partial = false;
|
|
69104
69144
|
let cascadeNull = false;
|
|
69105
|
-
|
|
69106
|
-
|
|
69107
|
-
|
|
69145
|
+
const typename = this.storage.get(parent, "__typename").value;
|
|
69146
|
+
let targetSelection = getFieldsForType(selection2, typename);
|
|
69147
|
+
for (const [
|
|
69148
|
+
attributeName,
|
|
69149
|
+
{ type, keyRaw, selection: fieldSelection, nullable, list }
|
|
69150
|
+
] of Object.entries(targetSelection)) {
|
|
69108
69151
|
const key = evaluateKey(keyRaw, variables);
|
|
69109
69152
|
const { value } = this.storage.get(parent, key);
|
|
69110
69153
|
let nextStep = stepsFromConnection;
|
|
@@ -69127,7 +69170,7 @@ var CacheInternal = class {
|
|
|
69127
69170
|
if (typeof value !== "undefined") {
|
|
69128
69171
|
hasData = true;
|
|
69129
69172
|
}
|
|
69130
|
-
} else if (!
|
|
69173
|
+
} else if (!fieldSelection) {
|
|
69131
69174
|
const fnUnmarshal = this.config?.scalars?.[type]?.unmarshal;
|
|
69132
69175
|
if (fnUnmarshal) {
|
|
69133
69176
|
target[attributeName] = fnUnmarshal(value);
|
|
@@ -69137,7 +69180,7 @@ var CacheInternal = class {
|
|
|
69137
69180
|
hasData = true;
|
|
69138
69181
|
} else if (Array.isArray(value)) {
|
|
69139
69182
|
const listValue = this.hydrateNestedList({
|
|
69140
|
-
fields,
|
|
69183
|
+
fields: fieldSelection,
|
|
69141
69184
|
variables,
|
|
69142
69185
|
linkedList: value,
|
|
69143
69186
|
stepsFromConnection: nextStep
|
|
@@ -69152,7 +69195,7 @@ var CacheInternal = class {
|
|
|
69152
69195
|
} else {
|
|
69153
69196
|
const objectFields = this.getSelection({
|
|
69154
69197
|
parent: value,
|
|
69155
|
-
selection:
|
|
69198
|
+
selection: fieldSelection,
|
|
69156
69199
|
variables,
|
|
69157
69200
|
stepsFromConnection: nextStep
|
|
69158
69201
|
});
|
|
@@ -70886,7 +70929,7 @@ var Config = class {
|
|
|
70886
70929
|
typeConfig;
|
|
70887
70930
|
configFile;
|
|
70888
70931
|
logLevel;
|
|
70889
|
-
|
|
70932
|
+
defaultFragmentMasking = "enable";
|
|
70890
70933
|
configIsRoute = null;
|
|
70891
70934
|
routesDir;
|
|
70892
70935
|
schemaPollInterval;
|
|
@@ -70899,6 +70942,11 @@ var Config = class {
|
|
|
70899
70942
|
...configFile
|
|
70900
70943
|
}) {
|
|
70901
70944
|
this.configFile = defaultConfigValues(configFile);
|
|
70945
|
+
if (configFile.disableMasking !== void 0) {
|
|
70946
|
+
throw new HoudiniError({
|
|
70947
|
+
message: `"disableMasking" was replaced by "defaultFragmentMasking". Please update your config file.`
|
|
70948
|
+
});
|
|
70949
|
+
}
|
|
70902
70950
|
let {
|
|
70903
70951
|
schema,
|
|
70904
70952
|
schemaPath = "./schema.graphql",
|
|
@@ -70915,7 +70963,7 @@ var Config = class {
|
|
|
70915
70963
|
defaultKeys,
|
|
70916
70964
|
types: types14 = {},
|
|
70917
70965
|
logLevel,
|
|
70918
|
-
|
|
70966
|
+
defaultFragmentMasking = "enable",
|
|
70919
70967
|
schemaPollInterval = 2e3,
|
|
70920
70968
|
schemaPollHeaders = {},
|
|
70921
70969
|
projectDir
|
|
@@ -70934,7 +70982,11 @@ var Config = class {
|
|
|
70934
70982
|
logLevel = LogLevel.Summary;
|
|
70935
70983
|
}
|
|
70936
70984
|
this.schemaPath = schemaPath;
|
|
70937
|
-
|
|
70985
|
+
if (apiUrl && apiUrl.startsWith("env:")) {
|
|
70986
|
+
this.apiUrl = process.env[apiUrl.slice("env:".length)];
|
|
70987
|
+
} else {
|
|
70988
|
+
this.apiUrl = apiUrl;
|
|
70989
|
+
}
|
|
70938
70990
|
this.filepath = filepath;
|
|
70939
70991
|
this.exclude = Array.isArray(exclude) ? exclude : [exclude];
|
|
70940
70992
|
this.module = module2;
|
|
@@ -70946,10 +70998,10 @@ var Config = class {
|
|
|
70946
70998
|
this.defaultCachePolicy = defaultCachePolicy;
|
|
70947
70999
|
this.defaultPartial = defaultPartial;
|
|
70948
71000
|
this.internalListPosition = defaultListPosition === "append" ? "last" : "first";
|
|
70949
|
-
this.defaultListTarget
|
|
71001
|
+
this.defaultListTarget = defaultListTarget;
|
|
70950
71002
|
this.definitionsFolder = definitionsPath;
|
|
70951
71003
|
this.logLevel = (logLevel || LogLevel.Summary).toLowerCase();
|
|
70952
|
-
this.
|
|
71004
|
+
this.defaultFragmentMasking = defaultFragmentMasking;
|
|
70953
71005
|
this.routesDir = join2(this.projectRoot, "src", "routes");
|
|
70954
71006
|
this.schemaPollInterval = schemaPollInterval;
|
|
70955
71007
|
this.schemaPollHeaders = schemaPollHeaders;
|
|
@@ -71143,8 +71195,14 @@ var Config = class {
|
|
|
71143
71195
|
pluginDirectory(name2) {
|
|
71144
71196
|
return houdini_mode.is_testing ? resolve("../../../", name2) : join2(this.rootDir, "plugins", name2);
|
|
71145
71197
|
}
|
|
71146
|
-
get
|
|
71147
|
-
return "
|
|
71198
|
+
get manualLoadDirective() {
|
|
71199
|
+
return "manual_load";
|
|
71200
|
+
}
|
|
71201
|
+
get maskEnableDirective() {
|
|
71202
|
+
return "mask_enable";
|
|
71203
|
+
}
|
|
71204
|
+
get maskDisableDirective() {
|
|
71205
|
+
return "mask_disable";
|
|
71148
71206
|
}
|
|
71149
71207
|
get listDirective() {
|
|
71150
71208
|
return "list";
|
|
@@ -71156,9 +71214,9 @@ var Config = class {
|
|
|
71156
71214
|
return "append";
|
|
71157
71215
|
}
|
|
71158
71216
|
get listParentDirective() {
|
|
71159
|
-
return
|
|
71217
|
+
return "parentID";
|
|
71160
71218
|
}
|
|
71161
|
-
get
|
|
71219
|
+
get deprecatedlistDirectiveParentIDArg() {
|
|
71162
71220
|
return "parentID";
|
|
71163
71221
|
}
|
|
71164
71222
|
get listAllListsDirective() {
|
|
@@ -71244,7 +71302,7 @@ var Config = class {
|
|
|
71244
71302
|
this.listDirective,
|
|
71245
71303
|
this.listPrependDirective,
|
|
71246
71304
|
this.listAppendDirective,
|
|
71247
|
-
this.
|
|
71305
|
+
this.listParentDirective,
|
|
71248
71306
|
this.listAllListsDirective,
|
|
71249
71307
|
this.whenDirective,
|
|
71250
71308
|
this.whenNotDirective,
|
|
@@ -71252,7 +71310,9 @@ var Config = class {
|
|
|
71252
71310
|
this.withDirective,
|
|
71253
71311
|
this.paginateDirective,
|
|
71254
71312
|
this.cacheDirective,
|
|
71255
|
-
this.
|
|
71313
|
+
this.manualLoadDirective,
|
|
71314
|
+
this.maskEnableDirective,
|
|
71315
|
+
this.maskDisableDirective
|
|
71256
71316
|
].includes(name2.value) || this.isDeleteDirective(name2.value);
|
|
71257
71317
|
}
|
|
71258
71318
|
isListFragment(name2) {
|
|
@@ -71823,13 +71883,17 @@ function flattenSelections({
|
|
|
71823
71883
|
config: config2,
|
|
71824
71884
|
filepath,
|
|
71825
71885
|
selections,
|
|
71826
|
-
fragmentDefinitions
|
|
71886
|
+
fragmentDefinitions,
|
|
71887
|
+
applyFragments,
|
|
71888
|
+
ignoreMaskDisable
|
|
71827
71889
|
}) {
|
|
71828
71890
|
const fields = new FieldCollection({
|
|
71829
71891
|
config: config2,
|
|
71830
71892
|
filepath,
|
|
71831
71893
|
selections,
|
|
71832
|
-
fragmentDefinitions
|
|
71894
|
+
fragmentDefinitions,
|
|
71895
|
+
applyFragments,
|
|
71896
|
+
ignoreMaskDisable: !!ignoreMaskDisable
|
|
71833
71897
|
});
|
|
71834
71898
|
return fields.toSelectionSet();
|
|
71835
71899
|
}
|
|
@@ -71840,9 +71904,13 @@ var FieldCollection = class {
|
|
|
71840
71904
|
fields;
|
|
71841
71905
|
inlineFragments;
|
|
71842
71906
|
fragmentSpreads;
|
|
71907
|
+
applyFragments;
|
|
71908
|
+
ignoreMaskDisable;
|
|
71843
71909
|
constructor(args) {
|
|
71844
71910
|
this.config = args.config;
|
|
71845
71911
|
this.fragmentDefinitions = args.fragmentDefinitions;
|
|
71912
|
+
this.applyFragments = args.applyFragments;
|
|
71913
|
+
this.ignoreMaskDisable = args.ignoreMaskDisable;
|
|
71846
71914
|
this.fields = {};
|
|
71847
71915
|
this.inlineFragments = {};
|
|
71848
71916
|
this.fragmentSpreads = {};
|
|
@@ -71871,31 +71939,28 @@ var FieldCollection = class {
|
|
|
71871
71939
|
}
|
|
71872
71940
|
}
|
|
71873
71941
|
if (selection2.kind === "InlineFragment" && selection2.typeCondition) {
|
|
71874
|
-
|
|
71875
|
-
if (!this.inlineFragments[key]) {
|
|
71876
|
-
this.inlineFragments[key] = {
|
|
71877
|
-
astNode: selection2,
|
|
71878
|
-
selection: this.empty()
|
|
71879
|
-
};
|
|
71880
|
-
}
|
|
71881
|
-
for (const subselect of selection2.selectionSet?.selections || []) {
|
|
71882
|
-
this.inlineFragments[key].selection.add(subselect);
|
|
71883
|
-
}
|
|
71942
|
+
this.walkInlineFragment(selection2);
|
|
71884
71943
|
return;
|
|
71885
71944
|
}
|
|
71886
71945
|
if (selection2.kind === "FragmentSpread") {
|
|
71887
71946
|
this.fragmentSpreads[selection2.name.value] = selection2;
|
|
71888
|
-
|
|
71889
|
-
|
|
71947
|
+
let includeFragments = this.config.defaultFragmentMasking === "disable";
|
|
71948
|
+
const maskEnableDirective = selection2.directives?.find(
|
|
71949
|
+
({ name: name2 }) => name2.value === this.config.maskEnableDirective
|
|
71890
71950
|
);
|
|
71891
|
-
|
|
71892
|
-
|
|
71951
|
+
if (maskEnableDirective) {
|
|
71952
|
+
includeFragments = false;
|
|
71953
|
+
}
|
|
71954
|
+
const maskDisableDirective = selection2.directives?.find(
|
|
71955
|
+
({ name: name2 }) => name2.value === this.config.maskDisableDirective
|
|
71893
71956
|
);
|
|
71894
|
-
|
|
71895
|
-
|
|
71896
|
-
includeFragments = !maskArgument.value.value;
|
|
71957
|
+
if (maskDisableDirective) {
|
|
71958
|
+
includeFragments = true;
|
|
71897
71959
|
}
|
|
71898
|
-
if (
|
|
71960
|
+
if (this.ignoreMaskDisable) {
|
|
71961
|
+
includeFragments = true;
|
|
71962
|
+
}
|
|
71963
|
+
if (!includeFragments || !this.applyFragments) {
|
|
71899
71964
|
return;
|
|
71900
71965
|
}
|
|
71901
71966
|
const definition = this.fragmentDefinitions[selection2.name.value];
|
|
@@ -71905,9 +71970,20 @@ var FieldCollection = class {
|
|
|
71905
71970
|
message: "Could not find referenced fragment definition: " + selection2.name.value
|
|
71906
71971
|
});
|
|
71907
71972
|
}
|
|
71908
|
-
|
|
71909
|
-
|
|
71910
|
-
|
|
71973
|
+
this.add({
|
|
71974
|
+
kind: "InlineFragment",
|
|
71975
|
+
typeCondition: {
|
|
71976
|
+
kind: "NamedType",
|
|
71977
|
+
name: {
|
|
71978
|
+
kind: "Name",
|
|
71979
|
+
value: definition.typeCondition.name.value
|
|
71980
|
+
}
|
|
71981
|
+
},
|
|
71982
|
+
selectionSet: {
|
|
71983
|
+
kind: "SelectionSet",
|
|
71984
|
+
selections: [...definition.selectionSet.selections]
|
|
71985
|
+
}
|
|
71986
|
+
});
|
|
71911
71987
|
}
|
|
71912
71988
|
}
|
|
71913
71989
|
toSelectionSet() {
|
|
@@ -71923,12 +71999,30 @@ var FieldCollection = class {
|
|
|
71923
71999
|
})
|
|
71924
72000
|
).concat(Object.values(this.fragmentSpreads));
|
|
71925
72001
|
}
|
|
72002
|
+
walkInlineFragment(selection2) {
|
|
72003
|
+
const key = selection2.typeCondition.name.value;
|
|
72004
|
+
if (!this.inlineFragments[key]) {
|
|
72005
|
+
this.inlineFragments[key] = {
|
|
72006
|
+
astNode: selection2,
|
|
72007
|
+
selection: this.empty()
|
|
72008
|
+
};
|
|
72009
|
+
}
|
|
72010
|
+
for (const subselect of selection2.selectionSet.selections || []) {
|
|
72011
|
+
if (subselect.kind !== "InlineFragment" || !subselect.typeCondition) {
|
|
72012
|
+
this.inlineFragments[key].selection.add(subselect);
|
|
72013
|
+
continue;
|
|
72014
|
+
}
|
|
72015
|
+
this.walkInlineFragment(subselect);
|
|
72016
|
+
}
|
|
72017
|
+
}
|
|
71926
72018
|
empty() {
|
|
71927
72019
|
return new FieldCollection({
|
|
71928
72020
|
config: this.config,
|
|
71929
72021
|
fragmentDefinitions: this.fragmentDefinitions,
|
|
71930
72022
|
selections: [],
|
|
71931
|
-
filepath: this.filepath
|
|
72023
|
+
filepath: this.filepath,
|
|
72024
|
+
applyFragments: this.applyFragments,
|
|
72025
|
+
ignoreMaskDisable: this.ignoreMaskDisable
|
|
71932
72026
|
});
|
|
71933
72027
|
}
|
|
71934
72028
|
};
|
|
@@ -72283,11 +72377,6 @@ function operationObject({
|
|
|
72283
72377
|
const when = internalDirectives.find(({ name: name2 }) => name2.value === "when");
|
|
72284
72378
|
const when_not = internalDirectives.find(({ name: name2 }) => name2.value === "when_not");
|
|
72285
72379
|
let parentIDArg = parent?.arguments?.find((argument) => argument.name.value === "value");
|
|
72286
|
-
if (!parentIDArg) {
|
|
72287
|
-
parentIDArg = (append || prepend)?.arguments?.find(
|
|
72288
|
-
({ name: name2 }) => name2.value === config2.listDirectiveParentIDArg
|
|
72289
|
-
);
|
|
72290
|
-
}
|
|
72291
72380
|
if (parentIDArg) {
|
|
72292
72381
|
if (parentIDArg.value.kind === "StringValue") {
|
|
72293
72382
|
parentID = parentIDArg.value.value;
|
|
@@ -73315,6 +73404,8 @@ function selection({
|
|
|
73315
73404
|
markEdges
|
|
73316
73405
|
}) {
|
|
73317
73406
|
let object = {};
|
|
73407
|
+
const typeMap = {};
|
|
73408
|
+
const abstractTypes = [];
|
|
73318
73409
|
for (const field of selections) {
|
|
73319
73410
|
if (field.kind === "FragmentSpread" && includeFragments) {
|
|
73320
73411
|
const fragmentDefinition = document.document.definitions.find(
|
|
@@ -73341,20 +73432,68 @@ function selection({
|
|
|
73341
73432
|
})
|
|
73342
73433
|
);
|
|
73343
73434
|
} else if (field.kind === "InlineFragment") {
|
|
73344
|
-
|
|
73345
|
-
|
|
73346
|
-
object,
|
|
73347
|
-
selection({
|
|
73348
|
-
config: config2,
|
|
73435
|
+
if (!field.typeCondition || field.typeCondition.name.value === rootType) {
|
|
73436
|
+
object.fields = deepMerge(
|
|
73349
73437
|
filepath,
|
|
73350
|
-
|
|
73351
|
-
|
|
73352
|
-
|
|
73353
|
-
|
|
73354
|
-
|
|
73355
|
-
|
|
73356
|
-
|
|
73357
|
-
|
|
73438
|
+
object.fields || {},
|
|
73439
|
+
selection({
|
|
73440
|
+
config: config2,
|
|
73441
|
+
filepath,
|
|
73442
|
+
rootType: field.typeCondition?.name.value || rootType,
|
|
73443
|
+
operations,
|
|
73444
|
+
selections: field.selectionSet.selections,
|
|
73445
|
+
path: path2,
|
|
73446
|
+
includeFragments,
|
|
73447
|
+
document
|
|
73448
|
+
}).fields || {}
|
|
73449
|
+
);
|
|
73450
|
+
} else {
|
|
73451
|
+
if (!object.abstractFields) {
|
|
73452
|
+
object.abstractFields = {
|
|
73453
|
+
fields: {},
|
|
73454
|
+
typeMap: {}
|
|
73455
|
+
};
|
|
73456
|
+
}
|
|
73457
|
+
const parentType = config2.schema.getType(rootType);
|
|
73458
|
+
const typeConditionName = field.typeCondition.name.value;
|
|
73459
|
+
const typeCondition = config2.schema.getType(typeConditionName);
|
|
73460
|
+
const possibleTypes = [];
|
|
73461
|
+
if (!graphql12.isAbstractType(typeCondition)) {
|
|
73462
|
+
} else if (graphql12.isAbstractType(parentType)) {
|
|
73463
|
+
const possibleParentTypes = config2.schema.getPossibleTypes(parentType).map((type) => type.name);
|
|
73464
|
+
for (const possible of config2.schema.getPossibleTypes(typeCondition)) {
|
|
73465
|
+
if (possibleParentTypes.includes(possible.name)) {
|
|
73466
|
+
possibleTypes.push(possible.name);
|
|
73467
|
+
}
|
|
73468
|
+
}
|
|
73469
|
+
} else {
|
|
73470
|
+
possibleTypes.push(rootType);
|
|
73471
|
+
}
|
|
73472
|
+
if (possibleTypes.length > 0) {
|
|
73473
|
+
for (const type of possibleTypes) {
|
|
73474
|
+
const existing = typeMap[type];
|
|
73475
|
+
if (!existing || !existing.includes(type)) {
|
|
73476
|
+
typeMap[type] = [typeConditionName].concat(existing || []);
|
|
73477
|
+
}
|
|
73478
|
+
if (!abstractTypes.includes(typeConditionName)) {
|
|
73479
|
+
abstractTypes.push(typeConditionName);
|
|
73480
|
+
}
|
|
73481
|
+
}
|
|
73482
|
+
}
|
|
73483
|
+
object.abstractFields.fields = {
|
|
73484
|
+
...object.abstractFields.fields,
|
|
73485
|
+
[field.typeCondition.name.value]: selection({
|
|
73486
|
+
config: config2,
|
|
73487
|
+
filepath,
|
|
73488
|
+
rootType: field.typeCondition?.name.value || rootType,
|
|
73489
|
+
operations,
|
|
73490
|
+
selections: field.selectionSet.selections,
|
|
73491
|
+
path: path2,
|
|
73492
|
+
includeFragments,
|
|
73493
|
+
document
|
|
73494
|
+
}).fields
|
|
73495
|
+
};
|
|
73496
|
+
}
|
|
73358
73497
|
} else if (field.kind === "Field") {
|
|
73359
73498
|
const type = config2.schema.getType(rootType);
|
|
73360
73499
|
if (!type) {
|
|
@@ -73412,7 +73551,7 @@ function selection({
|
|
|
73412
73551
|
}
|
|
73413
73552
|
if (field.selectionSet) {
|
|
73414
73553
|
const edgesMark = paginated && document.refetch?.method === "cursor" ? document.refetch.update : markEdges;
|
|
73415
|
-
fieldObj.
|
|
73554
|
+
fieldObj.selection = selection({
|
|
73416
73555
|
config: config2,
|
|
73417
73556
|
filepath,
|
|
73418
73557
|
rootType: typeName,
|
|
@@ -73436,11 +73575,49 @@ function selection({
|
|
|
73436
73575
|
if (graphql12.isInterfaceType(fieldType) || graphql12.isUnionType(fieldType)) {
|
|
73437
73576
|
fieldObj.abstract = true;
|
|
73438
73577
|
}
|
|
73439
|
-
object
|
|
73440
|
-
|
|
73441
|
-
fieldObj
|
|
73442
|
-
|
|
73443
|
-
|
|
73578
|
+
object.fields = {
|
|
73579
|
+
...object.fields,
|
|
73580
|
+
[attributeName]: fieldObj
|
|
73581
|
+
};
|
|
73582
|
+
}
|
|
73583
|
+
}
|
|
73584
|
+
if (Object.keys(object.fields || {}).length > 0 && object.abstractFields && Object.keys(object.abstractFields.fields).length > 0) {
|
|
73585
|
+
for (const [typeName, possibles] of Object.entries(typeMap)) {
|
|
73586
|
+
let overlap = false;
|
|
73587
|
+
for (const possible of possibles) {
|
|
73588
|
+
if (object.abstractFields.fields[typeName]) {
|
|
73589
|
+
object.abstractFields.fields[typeName] = deepMerge(
|
|
73590
|
+
filepath,
|
|
73591
|
+
object.abstractFields.fields[typeName] || {},
|
|
73592
|
+
object.abstractFields.fields[possible]
|
|
73593
|
+
);
|
|
73594
|
+
overlap = true;
|
|
73595
|
+
}
|
|
73596
|
+
}
|
|
73597
|
+
if (overlap) {
|
|
73598
|
+
delete typeMap[typeName];
|
|
73599
|
+
}
|
|
73600
|
+
}
|
|
73601
|
+
for (const [type, options] of Object.entries(typeMap)) {
|
|
73602
|
+
if (options.length > 1) {
|
|
73603
|
+
object.abstractFields.fields[type] = deepMerge(
|
|
73604
|
+
filepath,
|
|
73605
|
+
...options.map((opt) => object.abstractFields.fields[opt] || {})
|
|
73606
|
+
);
|
|
73607
|
+
delete typeMap[type];
|
|
73608
|
+
}
|
|
73609
|
+
}
|
|
73610
|
+
for (const [type, sel] of Object.entries(object.abstractFields?.fields || {})) {
|
|
73611
|
+
object.abstractFields.fields[type] = deepMerge(filepath, sel || {}, object.fields);
|
|
73612
|
+
}
|
|
73613
|
+
for (const [type, options] of Object.entries(typeMap)) {
|
|
73614
|
+
object.abstractFields.typeMap[type] = options[0];
|
|
73615
|
+
}
|
|
73616
|
+
const usedTypes = Object.values(object.abstractFields.typeMap);
|
|
73617
|
+
for (const type of abstractTypes) {
|
|
73618
|
+
if (!usedTypes.includes(type)) {
|
|
73619
|
+
delete object.abstractFields.fields[type];
|
|
73620
|
+
}
|
|
73444
73621
|
}
|
|
73445
73622
|
}
|
|
73446
73623
|
return object;
|
|
@@ -73575,6 +73752,22 @@ function artifactGenerator(stats) {
|
|
|
73575
73752
|
selectionSet = matchingFragment.selectionSet;
|
|
73576
73753
|
}
|
|
73577
73754
|
const inputs = operations[0]?.variableDefinitions;
|
|
73755
|
+
const mergedSelection = flattenSelections({
|
|
73756
|
+
config: config2,
|
|
73757
|
+
filepath: doc.filename,
|
|
73758
|
+
selections: selectionSet.selections,
|
|
73759
|
+
fragmentDefinitions: doc.document.definitions.filter(
|
|
73760
|
+
(definition) => definition.kind === "FragmentDefinition"
|
|
73761
|
+
).reduce(
|
|
73762
|
+
(prev, definition) => ({
|
|
73763
|
+
...prev,
|
|
73764
|
+
[definition.name.value]: definition
|
|
73765
|
+
}),
|
|
73766
|
+
{}
|
|
73767
|
+
),
|
|
73768
|
+
ignoreMaskDisable: docKind === "HoudiniQuery",
|
|
73769
|
+
applyFragments: docKind !== "HoudiniFragment"
|
|
73770
|
+
});
|
|
73578
73771
|
const artifact = {
|
|
73579
73772
|
name: name2,
|
|
73580
73773
|
kind: docKind,
|
|
@@ -73586,7 +73779,7 @@ function artifactGenerator(stats) {
|
|
|
73586
73779
|
config: config2,
|
|
73587
73780
|
filepath: doc.filename,
|
|
73588
73781
|
rootType,
|
|
73589
|
-
selections:
|
|
73782
|
+
selections: mergedSelection,
|
|
73590
73783
|
operations: operationsByPath(
|
|
73591
73784
|
config2,
|
|
73592
73785
|
doc.filename,
|
|
@@ -73882,6 +74075,17 @@ function inlineType({
|
|
|
73882
74075
|
continue;
|
|
73883
74076
|
}
|
|
73884
74077
|
const possibleParents = config2.schema.getPossibleTypes(type).map((t2) => t2.name);
|
|
74078
|
+
const freeSelections = [];
|
|
74079
|
+
const typeSpecificSelections = {};
|
|
74080
|
+
for (const node of selection2.selectionSet.selections) {
|
|
74081
|
+
if (node.kind !== "InlineFragment") {
|
|
74082
|
+
freeSelections.push(node);
|
|
74083
|
+
} else if (node.typeCondition) {
|
|
74084
|
+
typeSpecificSelections[node.typeCondition.name.value] = node.selectionSet.selections;
|
|
74085
|
+
} else {
|
|
74086
|
+
freeSelections.push(...node.selectionSet.selections);
|
|
74087
|
+
}
|
|
74088
|
+
}
|
|
73885
74089
|
for (const possibleType of config2.schema.getPossibleTypes(fragmentType)) {
|
|
73886
74090
|
if (!possibleParents.includes(possibleType.name)) {
|
|
73887
74091
|
continue;
|
|
@@ -73889,7 +74093,12 @@ function inlineType({
|
|
|
73889
74093
|
if (!inlineFragments[possibleType.name]) {
|
|
73890
74094
|
inlineFragments[possibleType.name] = [];
|
|
73891
74095
|
}
|
|
73892
|
-
inlineFragments[possibleType.name].push(...
|
|
74096
|
+
inlineFragments[possibleType.name].push(...freeSelections);
|
|
74097
|
+
if (typeSpecificSelections[possibleType.name]) {
|
|
74098
|
+
inlineFragments[possibleType.name].push(
|
|
74099
|
+
...typeSpecificSelections[possibleType.name]
|
|
74100
|
+
);
|
|
74101
|
+
}
|
|
73893
74102
|
}
|
|
73894
74103
|
} else if (selection2.kind === "InlineFragment" && !selection2.typeCondition) {
|
|
73895
74104
|
selectedFields.push(...selection2.selectionSet.selections);
|
|
@@ -73901,12 +74110,7 @@ function inlineType({
|
|
|
73901
74110
|
...(selectedFields || []).filter(
|
|
73902
74111
|
(field) => field.kind === "Field"
|
|
73903
74112
|
).map((selection2) => {
|
|
73904
|
-
const {
|
|
73905
|
-
config2.schema,
|
|
73906
|
-
filepath,
|
|
73907
|
-
rootObj,
|
|
73908
|
-
selection2
|
|
73909
|
-
);
|
|
74113
|
+
const { field } = selectionTypeInfo(config2.schema, filepath, rootObj, selection2);
|
|
73910
74114
|
const attributeName = selection2.alias?.value || selection2.name.value;
|
|
73911
74115
|
let attributeType = inlineType({
|
|
73912
74116
|
config: config2,
|
|
@@ -74105,7 +74309,8 @@ async function typescriptGenerator(config2, docs) {
|
|
|
74105
74309
|
config: config2,
|
|
74106
74310
|
filepath: filename,
|
|
74107
74311
|
selections: definition.selectionSet.selections,
|
|
74108
|
-
fragmentDefinitions
|
|
74312
|
+
fragmentDefinitions,
|
|
74313
|
+
applyFragments: definition.kind === "OperationDefinition"
|
|
74109
74314
|
});
|
|
74110
74315
|
if (definition?.kind === "OperationDefinition") {
|
|
74111
74316
|
await generateOperationTypeDefs(
|
|
@@ -74618,14 +74823,12 @@ directive @${config2.paginateDirective}(${config2.paginateNameArg}: String) on F
|
|
|
74618
74823
|
"""
|
|
74619
74824
|
@${config2.listPrependDirective} is used to tell the runtime to add the result to the end of the list
|
|
74620
74825
|
"""
|
|
74621
|
-
directive @${config2.listPrependDirective}
|
|
74622
|
-
${config2.listDirectiveParentIDArg}: ID
|
|
74623
|
-
) on FRAGMENT_SPREAD
|
|
74826
|
+
directive @${config2.listPrependDirective} on FRAGMENT_SPREAD
|
|
74624
74827
|
|
|
74625
74828
|
"""
|
|
74626
74829
|
@${config2.listAppendDirective} is used to tell the runtime to add the result to the start of the list
|
|
74627
74830
|
"""
|
|
74628
|
-
directive @${config2.listAppendDirective}
|
|
74831
|
+
directive @${config2.listAppendDirective} on FRAGMENT_SPREAD
|
|
74629
74832
|
|
|
74630
74833
|
"""
|
|
74631
74834
|
@${config2.listAllListsDirective} is used to tell the runtime to add the result to all list
|
|
@@ -74659,18 +74862,19 @@ directive @${config2.argumentsDirective} on FRAGMENT_DEFINITION
|
|
|
74659
74862
|
directive @${config2.cacheDirective}(${config2.cachePolicyArg}: CachePolicy, ${config2.cachePartialArg}: Boolean) on QUERY
|
|
74660
74863
|
|
|
74661
74864
|
"""
|
|
74662
|
-
@${config2.
|
|
74865
|
+
@${config2.manualLoadDirective} is used to disable automatic fetch (no load, no auto fetch in component), you will have to do it manually.
|
|
74866
|
+
"""
|
|
74867
|
+
directive @${config2.manualLoadDirective} on QUERY
|
|
74868
|
+
|
|
74869
|
+
"""
|
|
74870
|
+
@${config2.maskEnableDirective} to enable masking on fragment (overwriting the global conf)
|
|
74871
|
+
"""
|
|
74872
|
+
directive @${config2.maskEnableDirective} on FRAGMENT_SPREAD
|
|
74873
|
+
|
|
74874
|
+
"""
|
|
74875
|
+
@${config2.maskDisableDirective} to disable masking on fragment (overwriting the global conf)
|
|
74663
74876
|
"""
|
|
74664
|
-
directive @${config2.
|
|
74665
|
-
"""
|
|
74666
|
-
Opt-in to an automatic load function (only valid when used at queries)
|
|
74667
|
-
"""
|
|
74668
|
-
load: Boolean! = true
|
|
74669
|
-
"""
|
|
74670
|
-
Mask fragment fields (only valid when used at a fragment spread)
|
|
74671
|
-
"""
|
|
74672
|
-
mask: Boolean! = ${config2.disableMasking ? "false" : "true"}
|
|
74673
|
-
) on QUERY | FRAGMENT_SPREAD
|
|
74877
|
+
directive @${config2.maskDisableDirective} on FRAGMENT_SPREAD
|
|
74674
74878
|
`;
|
|
74675
74879
|
let currentSchema = graphql21.printSchema(config2.schema);
|
|
74676
74880
|
if (!currentSchema.includes(`directive @${config2.listDirective}`)) {
|
|
@@ -75163,26 +75367,42 @@ async function typeCheck(config2, docs) {
|
|
|
75163
75367
|
),
|
|
75164
75368
|
targetField.selectionSet
|
|
75165
75369
|
);
|
|
75166
|
-
|
|
75167
|
-
if (
|
|
75168
|
-
|
|
75169
|
-
|
|
75170
|
-
|
|
75171
|
-
|
|
75172
|
-
|
|
75173
|
-
|
|
75174
|
-
|
|
75175
|
-
|
|
75176
|
-
|
|
75177
|
-
|
|
75178
|
-
|
|
75179
|
-
|
|
75180
|
-
|
|
75181
|
-
|
|
75182
|
-
|
|
75183
|
-
)
|
|
75370
|
+
let targetTypes = [type];
|
|
75371
|
+
if (graphql25.isUnionType(type)) {
|
|
75372
|
+
targetTypes = config2.schema.getPossibleTypes(type);
|
|
75373
|
+
} else if (graphql25.isInterfaceType(type)) {
|
|
75374
|
+
try {
|
|
75375
|
+
for (const key of config2.keyFieldsForType(type.name)) {
|
|
75376
|
+
if (!type.getFields()[key]) {
|
|
75377
|
+
throw new Error("continue");
|
|
75378
|
+
}
|
|
75379
|
+
}
|
|
75380
|
+
} catch {
|
|
75381
|
+
targetTypes = config2.schema.getPossibleTypes(type);
|
|
75382
|
+
}
|
|
75383
|
+
}
|
|
75384
|
+
for (const targetType of targetTypes) {
|
|
75385
|
+
const missingIDFields = config2.keyFieldsForType(targetType.name).filter((fieldName) => !targetType.getFields()[fieldName]);
|
|
75386
|
+
if (missingIDFields.length > 0) {
|
|
75387
|
+
if (error) {
|
|
75388
|
+
errors.push(
|
|
75389
|
+
new HoudiniError({
|
|
75390
|
+
filepath: filename,
|
|
75391
|
+
message: error
|
|
75392
|
+
})
|
|
75393
|
+
);
|
|
75394
|
+
} else {
|
|
75395
|
+
errors.push(
|
|
75396
|
+
new HoudiniError({
|
|
75397
|
+
filepath: filename,
|
|
75398
|
+
message: `@${config2.listDirective} can only be applied to types with the necessary id fields: ${missingIDFields.join(
|
|
75399
|
+
", "
|
|
75400
|
+
)}.`
|
|
75401
|
+
})
|
|
75402
|
+
);
|
|
75403
|
+
}
|
|
75404
|
+
return;
|
|
75184
75405
|
}
|
|
75185
|
-
return;
|
|
75186
75406
|
}
|
|
75187
75407
|
lists.push(listName);
|
|
75188
75408
|
listTypes.push(type.name);
|
|
@@ -75212,6 +75432,7 @@ async function typeCheck(config2, docs) {
|
|
|
75212
75432
|
fragments
|
|
75213
75433
|
}),
|
|
75214
75434
|
checkMutationOperation(config2),
|
|
75435
|
+
checkMaskDirective(config2),
|
|
75215
75436
|
nodeDirectives(config2, [config2.paginateDirective]),
|
|
75216
75437
|
knownArguments(config2),
|
|
75217
75438
|
validateFragmentArguments(config2, filepath, fragments),
|
|
@@ -75276,10 +75497,14 @@ var validateLists = ({
|
|
|
75276
75497
|
]);
|
|
75277
75498
|
if (directive) {
|
|
75278
75499
|
let parentArg = directive.arguments?.find(
|
|
75279
|
-
(arg) => arg.name.value === config2.
|
|
75500
|
+
(arg) => arg.name.value === config2.deprecatedlistDirectiveParentIDArg
|
|
75280
75501
|
);
|
|
75281
75502
|
if (parentArg) {
|
|
75282
|
-
|
|
75503
|
+
ctx.reportError(
|
|
75504
|
+
new graphql25.GraphQLError(
|
|
75505
|
+
`@${config2.deprecatedlistDirectiveParentIDArg} should be defined only in it's own directive now`
|
|
75506
|
+
)
|
|
75507
|
+
);
|
|
75283
75508
|
}
|
|
75284
75509
|
}
|
|
75285
75510
|
if (parentIdFound) {
|
|
@@ -75675,6 +75900,28 @@ function checkMutationOperation(config2) {
|
|
|
75675
75900
|
};
|
|
75676
75901
|
};
|
|
75677
75902
|
}
|
|
75903
|
+
function checkMaskDirective(config2) {
|
|
75904
|
+
return function(ctx) {
|
|
75905
|
+
return {
|
|
75906
|
+
FragmentSpread(node, _, __, ___, ancestors) {
|
|
75907
|
+
const maskEnableDirective = node.directives?.find(
|
|
75908
|
+
(c) => c.name.value === config2.maskEnableDirective
|
|
75909
|
+
);
|
|
75910
|
+
const maskDisableDirective = node.directives?.find(
|
|
75911
|
+
(c) => c.name.value === config2.maskDisableDirective
|
|
75912
|
+
);
|
|
75913
|
+
if (maskEnableDirective && maskDisableDirective) {
|
|
75914
|
+
ctx.reportError(
|
|
75915
|
+
new graphql25.GraphQLError(
|
|
75916
|
+
`You can't apply both @${config2.maskEnableDirective} and @${config2.maskDisableDirective} at the same time`
|
|
75917
|
+
)
|
|
75918
|
+
);
|
|
75919
|
+
return;
|
|
75920
|
+
}
|
|
75921
|
+
}
|
|
75922
|
+
};
|
|
75923
|
+
};
|
|
75924
|
+
}
|
|
75678
75925
|
function getAndVerifyNodeInterface(config2) {
|
|
75679
75926
|
const { schema } = config2;
|
|
75680
75927
|
const nodeInterface = schema.getType("Node");
|
|
@@ -75972,12 +76219,7 @@ async function collectDocuments(config2) {
|
|
|
75972
76219
|
}
|
|
75973
76220
|
async function processJSFile(config2, contents) {
|
|
75974
76221
|
const documents = [];
|
|
75975
|
-
|
|
75976
|
-
var program3 = (await parseJS(contents)).script;
|
|
75977
|
-
} catch (e2) {
|
|
75978
|
-
console.log(contents);
|
|
75979
|
-
throw e2;
|
|
75980
|
-
}
|
|
76222
|
+
var program3 = (await parseJS(contents)).script;
|
|
75981
76223
|
await find_graphql(config2, program3, {
|
|
75982
76224
|
tag({ tagContent }) {
|
|
75983
76225
|
documents.push(tagContent);
|
|
@@ -76277,7 +76519,6 @@ async function init(_path, args) {
|
|
|
76277
76519
|
const sourceDir = path_exports.join(targetPath, "src");
|
|
76278
76520
|
const configPath = path_exports.join(targetPath, "houdini.config.js");
|
|
76279
76521
|
const houdiniClientPath = typescript ? path_exports.join(sourceDir, "client.ts") : path_exports.join(sourceDir, "client.js");
|
|
76280
|
-
const houdiniClientImport = "./src/client";
|
|
76281
76522
|
console.log("\u{1F6A7} Generating project files...");
|
|
76282
76523
|
await updatePackageJSON(targetPath);
|
|
76283
76524
|
if (is_remote_endpoint) {
|
|
@@ -76287,8 +76528,7 @@ async function init(_path, args) {
|
|
|
76287
76528
|
configPath,
|
|
76288
76529
|
schemaPath,
|
|
76289
76530
|
module: module2,
|
|
76290
|
-
url: is_remote_endpoint ? url : null
|
|
76291
|
-
houdiniClientImport
|
|
76531
|
+
url: is_remote_endpoint ? url : null
|
|
76292
76532
|
});
|
|
76293
76533
|
await fs_exports.writeFile(houdiniClientPath, networkFile(url, typescript));
|
|
76294
76534
|
await graphqlRCFile(targetPath);
|
|
@@ -76345,8 +76585,7 @@ var writeConfigFile = async ({
|
|
|
76345
76585
|
configPath,
|
|
76346
76586
|
schemaPath,
|
|
76347
76587
|
module: module2,
|
|
76348
|
-
url
|
|
76349
|
-
houdiniClientImport
|
|
76588
|
+
url
|
|
76350
76589
|
}) => {
|
|
76351
76590
|
const config2 = {};
|
|
76352
76591
|
if (url !== null) {
|
|
@@ -76359,9 +76598,7 @@ var writeConfigFile = async ({
|
|
|
76359
76598
|
config2.module = module2;
|
|
76360
76599
|
}
|
|
76361
76600
|
config2.plugins = {
|
|
76362
|
-
"houdini-svelte": {
|
|
76363
|
-
client: houdiniClientImport
|
|
76364
|
-
}
|
|
76601
|
+
"houdini-svelte": {}
|
|
76365
76602
|
};
|
|
76366
76603
|
const configObj = JSON.stringify(config2, null, 4);
|
|
76367
76604
|
const content_base = `/// <references types="houdini-svelte">
|
|
@@ -76535,8 +76772,8 @@ async function updatePackageJSON(targetPath) {
|
|
|
76535
76772
|
}
|
|
76536
76773
|
packageJSON.devDependencies = {
|
|
76537
76774
|
...packageJSON.devDependencies,
|
|
76538
|
-
houdini: "^0.
|
|
76539
|
-
"houdini-svelte": "^0.
|
|
76775
|
+
houdini: "^0.18.0",
|
|
76776
|
+
"houdini-svelte": "^0.18.0",
|
|
76540
76777
|
graphql: "^15.8.0"
|
|
76541
76778
|
};
|
|
76542
76779
|
await fs_exports.writeFile(packagePath, JSON.stringify(packageJSON, null, 4));
|