houdini 0.17.13 → 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 +2 -2
- 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/vite-cjs/index.js
CHANGED
|
@@ -6774,7 +6774,7 @@ var require_definition = __commonJS({
|
|
|
6774
6774
|
exports.assertObjectType = assertObjectType;
|
|
6775
6775
|
exports.isInterfaceType = isInterfaceType12;
|
|
6776
6776
|
exports.assertInterfaceType = assertInterfaceType;
|
|
6777
|
-
exports.isUnionType =
|
|
6777
|
+
exports.isUnionType = isUnionType13;
|
|
6778
6778
|
exports.assertUnionType = assertUnionType;
|
|
6779
6779
|
exports.isEnumType = isEnumType9;
|
|
6780
6780
|
exports.assertEnumType = assertEnumType;
|
|
@@ -6792,7 +6792,7 @@ var require_definition = __commonJS({
|
|
|
6792
6792
|
exports.assertLeafType = assertLeafType;
|
|
6793
6793
|
exports.isCompositeType = isCompositeType;
|
|
6794
6794
|
exports.assertCompositeType = assertCompositeType;
|
|
6795
|
-
exports.isAbstractType =
|
|
6795
|
+
exports.isAbstractType = isAbstractType2;
|
|
6796
6796
|
exports.assertAbstractType = assertAbstractType;
|
|
6797
6797
|
exports.GraphQLList = GraphQLList6;
|
|
6798
6798
|
exports.GraphQLNonNull = GraphQLNonNull6;
|
|
@@ -6847,7 +6847,7 @@ var require_definition = __commonJS({
|
|
|
6847
6847
|
return Constructor;
|
|
6848
6848
|
}
|
|
6849
6849
|
function isType(type) {
|
|
6850
|
-
return isScalarType12(type) || isObjectType11(type) || isInterfaceType12(type) ||
|
|
6850
|
+
return isScalarType12(type) || isObjectType11(type) || isInterfaceType12(type) || isUnionType13(type) || isEnumType9(type) || isInputObjectType7(type) || isListType8(type) || isNonNullType10(type);
|
|
6851
6851
|
}
|
|
6852
6852
|
function assertType(type) {
|
|
6853
6853
|
if (!isType(type)) {
|
|
@@ -6882,11 +6882,11 @@ var require_definition = __commonJS({
|
|
|
6882
6882
|
}
|
|
6883
6883
|
return type;
|
|
6884
6884
|
}
|
|
6885
|
-
function
|
|
6885
|
+
function isUnionType13(type) {
|
|
6886
6886
|
return (0, _instanceOf.default)(type, GraphQLUnionType3);
|
|
6887
6887
|
}
|
|
6888
6888
|
function assertUnionType(type) {
|
|
6889
|
-
if (!
|
|
6889
|
+
if (!isUnionType13(type)) {
|
|
6890
6890
|
throw new Error("Expected ".concat((0, _inspect.default)(type), " to be a GraphQL Union type."));
|
|
6891
6891
|
}
|
|
6892
6892
|
return type;
|
|
@@ -6937,7 +6937,7 @@ var require_definition = __commonJS({
|
|
|
6937
6937
|
return type;
|
|
6938
6938
|
}
|
|
6939
6939
|
function isOutputType(type) {
|
|
6940
|
-
return isScalarType12(type) || isObjectType11(type) || isInterfaceType12(type) ||
|
|
6940
|
+
return isScalarType12(type) || isObjectType11(type) || isInterfaceType12(type) || isUnionType13(type) || isEnumType9(type) || isWrappingType(type) && isOutputType(type.ofType);
|
|
6941
6941
|
}
|
|
6942
6942
|
function assertOutputType(type) {
|
|
6943
6943
|
if (!isOutputType(type)) {
|
|
@@ -6955,7 +6955,7 @@ var require_definition = __commonJS({
|
|
|
6955
6955
|
return type;
|
|
6956
6956
|
}
|
|
6957
6957
|
function isCompositeType(type) {
|
|
6958
|
-
return isObjectType11(type) || isInterfaceType12(type) ||
|
|
6958
|
+
return isObjectType11(type) || isInterfaceType12(type) || isUnionType13(type);
|
|
6959
6959
|
}
|
|
6960
6960
|
function assertCompositeType(type) {
|
|
6961
6961
|
if (!isCompositeType(type)) {
|
|
@@ -6963,11 +6963,11 @@ var require_definition = __commonJS({
|
|
|
6963
6963
|
}
|
|
6964
6964
|
return type;
|
|
6965
6965
|
}
|
|
6966
|
-
function
|
|
6967
|
-
return isInterfaceType12(type) ||
|
|
6966
|
+
function isAbstractType2(type) {
|
|
6967
|
+
return isInterfaceType12(type) || isUnionType13(type);
|
|
6968
6968
|
}
|
|
6969
6969
|
function assertAbstractType(type) {
|
|
6970
|
-
if (!
|
|
6970
|
+
if (!isAbstractType2(type)) {
|
|
6971
6971
|
throw new Error("Expected ".concat((0, _inspect.default)(type), " to be a GraphQL abstract type."));
|
|
6972
6972
|
}
|
|
6973
6973
|
return type;
|
|
@@ -7034,7 +7034,7 @@ var require_definition = __commonJS({
|
|
|
7034
7034
|
}
|
|
7035
7035
|
}
|
|
7036
7036
|
function isNamedType4(type) {
|
|
7037
|
-
return isScalarType12(type) || isObjectType11(type) || isInterfaceType12(type) ||
|
|
7037
|
+
return isScalarType12(type) || isObjectType11(type) || isInterfaceType12(type) || isUnionType13(type) || isEnumType9(type) || isInputObjectType7(type);
|
|
7038
7038
|
}
|
|
7039
7039
|
function assertNamedType(type) {
|
|
7040
7040
|
if (!isNamedType4(type)) {
|
|
@@ -63889,6 +63889,20 @@ function deepEquals(objA, objB, map = /* @__PURE__ */ new WeakMap()) {
|
|
|
63889
63889
|
return true;
|
|
63890
63890
|
}
|
|
63891
63891
|
|
|
63892
|
+
// src/runtime/lib/selection.ts
|
|
63893
|
+
function getFieldsForType(selection2, __typename) {
|
|
63894
|
+
let targetSelection = selection2.fields || {};
|
|
63895
|
+
if (selection2.abstractFields && __typename) {
|
|
63896
|
+
const mappedType = selection2.abstractFields.typeMap[__typename];
|
|
63897
|
+
if (mappedType) {
|
|
63898
|
+
targetSelection = selection2.abstractFields.fields[mappedType];
|
|
63899
|
+
} else if (selection2.abstractFields.fields[__typename]) {
|
|
63900
|
+
targetSelection = selection2.abstractFields.fields[__typename];
|
|
63901
|
+
}
|
|
63902
|
+
}
|
|
63903
|
+
return targetSelection;
|
|
63904
|
+
}
|
|
63905
|
+
|
|
63892
63906
|
// src/runtime/cache/gc.ts
|
|
63893
63907
|
var GarbageCollector = class {
|
|
63894
63908
|
cache;
|
|
@@ -64111,23 +64125,32 @@ var List = class {
|
|
|
64111
64125
|
let insertData = data;
|
|
64112
64126
|
if (this.connection) {
|
|
64113
64127
|
insertSelection = {
|
|
64114
|
-
|
|
64115
|
-
|
|
64116
|
-
|
|
64117
|
-
|
|
64118
|
-
|
|
64119
|
-
keyRaw: "edges",
|
|
64120
|
-
type: "ConnectionEdge",
|
|
64121
|
-
update: where === "first" ? "prepend" : "append",
|
|
64128
|
+
fields: {
|
|
64129
|
+
newEntry: {
|
|
64130
|
+
keyRaw: this.key,
|
|
64131
|
+
type: "Connection",
|
|
64132
|
+
selection: {
|
|
64122
64133
|
fields: {
|
|
64123
|
-
|
|
64124
|
-
|
|
64125
|
-
|
|
64126
|
-
|
|
64127
|
-
|
|
64128
|
-
|
|
64129
|
-
|
|
64130
|
-
|
|
64134
|
+
edges: {
|
|
64135
|
+
keyRaw: "edges",
|
|
64136
|
+
type: "ConnectionEdge",
|
|
64137
|
+
update: where === "first" ? "prepend" : "append",
|
|
64138
|
+
selection: {
|
|
64139
|
+
fields: {
|
|
64140
|
+
node: {
|
|
64141
|
+
type: listType,
|
|
64142
|
+
keyRaw: "node",
|
|
64143
|
+
selection: {
|
|
64144
|
+
...selection2,
|
|
64145
|
+
fields: {
|
|
64146
|
+
...selection2.fields,
|
|
64147
|
+
__typename: {
|
|
64148
|
+
keyRaw: "__typename",
|
|
64149
|
+
type: "String"
|
|
64150
|
+
}
|
|
64151
|
+
}
|
|
64152
|
+
}
|
|
64153
|
+
}
|
|
64131
64154
|
}
|
|
64132
64155
|
}
|
|
64133
64156
|
}
|
|
@@ -64143,15 +64166,20 @@ var List = class {
|
|
|
64143
64166
|
};
|
|
64144
64167
|
} else {
|
|
64145
64168
|
insertSelection = {
|
|
64146
|
-
|
|
64147
|
-
|
|
64148
|
-
|
|
64149
|
-
|
|
64150
|
-
|
|
64151
|
-
|
|
64152
|
-
|
|
64153
|
-
|
|
64154
|
-
|
|
64169
|
+
fields: {
|
|
64170
|
+
newEntries: {
|
|
64171
|
+
keyRaw: this.key,
|
|
64172
|
+
type: listType,
|
|
64173
|
+
update: where === "first" ? "prepend" : "append",
|
|
64174
|
+
selection: {
|
|
64175
|
+
...selection2,
|
|
64176
|
+
fields: {
|
|
64177
|
+
...selection2.fields,
|
|
64178
|
+
__typename: {
|
|
64179
|
+
keyRaw: "__typename",
|
|
64180
|
+
type: "String"
|
|
64181
|
+
}
|
|
64182
|
+
}
|
|
64155
64183
|
}
|
|
64156
64184
|
}
|
|
64157
64185
|
}
|
|
@@ -64211,7 +64239,7 @@ var List = class {
|
|
|
64211
64239
|
const subscribers = this.cache._internal_unstable.subscriptions.get(this.recordID, this.key);
|
|
64212
64240
|
this.cache._internal_unstable.subscriptions.remove(
|
|
64213
64241
|
targetID,
|
|
64214
|
-
this.connection ? this.selection.edges.
|
|
64242
|
+
this.connection ? this.selection.fields.edges.selection : this.selection,
|
|
64215
64243
|
subscribers,
|
|
64216
64244
|
variables
|
|
64217
64245
|
);
|
|
@@ -64700,18 +64728,20 @@ var InMemorySubscriptions = class {
|
|
|
64700
64728
|
variables,
|
|
64701
64729
|
parentType
|
|
64702
64730
|
}) {
|
|
64703
|
-
|
|
64704
|
-
|
|
64731
|
+
const __typename = this.cache._internal_unstable.storage.get(parent, "__typename").value;
|
|
64732
|
+
let targetSelection = getFieldsForType(selection2, __typename);
|
|
64733
|
+
for (const fieldSelection of Object.values(targetSelection || {})) {
|
|
64734
|
+
const { keyRaw, selection: innerSelection, type } = fieldSelection;
|
|
64705
64735
|
const key = evaluateKey(keyRaw, variables);
|
|
64706
64736
|
this.addFieldSubscription({
|
|
64707
64737
|
id: parent,
|
|
64708
64738
|
key,
|
|
64709
|
-
|
|
64739
|
+
field: fieldSelection,
|
|
64710
64740
|
spec,
|
|
64711
64741
|
parentType: parentType || spec.rootType,
|
|
64712
64742
|
variables
|
|
64713
64743
|
});
|
|
64714
|
-
if (
|
|
64744
|
+
if (innerSelection) {
|
|
64715
64745
|
const { value: linkedRecord } = this.cache._internal_unstable.storage.get(
|
|
64716
64746
|
parent,
|
|
64717
64747
|
key
|
|
@@ -64724,7 +64754,7 @@ var InMemorySubscriptions = class {
|
|
|
64724
64754
|
this.add({
|
|
64725
64755
|
parent: child,
|
|
64726
64756
|
spec,
|
|
64727
|
-
selection:
|
|
64757
|
+
selection: innerSelection,
|
|
64728
64758
|
variables,
|
|
64729
64759
|
parentType: type
|
|
64730
64760
|
});
|
|
@@ -64735,7 +64765,7 @@ var InMemorySubscriptions = class {
|
|
|
64735
64765
|
addFieldSubscription({
|
|
64736
64766
|
id,
|
|
64737
64767
|
key,
|
|
64738
|
-
|
|
64768
|
+
field,
|
|
64739
64769
|
spec,
|
|
64740
64770
|
parentType,
|
|
64741
64771
|
variables
|
|
@@ -64762,8 +64792,8 @@ var InMemorySubscriptions = class {
|
|
|
64762
64792
|
const counts = this.referenceCounts[id][key];
|
|
64763
64793
|
counts.set(spec.set, (counts.get(spec.set) || 0) + 1);
|
|
64764
64794
|
this.cache._internal_unstable.lifetimes.resetLifetime(id, key);
|
|
64765
|
-
const {
|
|
64766
|
-
if (
|
|
64795
|
+
const { selection: selection2, list, filters } = field;
|
|
64796
|
+
if (selection2 && list) {
|
|
64767
64797
|
this.cache._internal_unstable.lists.add({
|
|
64768
64798
|
name: list.name,
|
|
64769
64799
|
connection: list.connection,
|
|
@@ -64771,7 +64801,7 @@ var InMemorySubscriptions = class {
|
|
|
64771
64801
|
recordType: this.cache._internal_unstable.storage.get(id, "__typename")?.value || parentType,
|
|
64772
64802
|
listType: list.type,
|
|
64773
64803
|
key,
|
|
64774
|
-
selection:
|
|
64804
|
+
selection: selection2,
|
|
64775
64805
|
filters: Object.entries(filters || {}).reduce((acc, [key2, { kind, value }]) => {
|
|
64776
64806
|
return {
|
|
64777
64807
|
...acc,
|
|
@@ -64788,20 +64818,21 @@ var InMemorySubscriptions = class {
|
|
|
64788
64818
|
subscribers,
|
|
64789
64819
|
parentType
|
|
64790
64820
|
}) {
|
|
64791
|
-
|
|
64792
|
-
|
|
64821
|
+
let targetSelection = getFieldsForType(selection2, parentType);
|
|
64822
|
+
for (const fieldSelection of Object.values(targetSelection)) {
|
|
64823
|
+
const { type: linkedType, keyRaw, selection: innerSelection } = fieldSelection;
|
|
64793
64824
|
const key = evaluateKey(keyRaw, variables);
|
|
64794
64825
|
for (const spec of subscribers) {
|
|
64795
64826
|
this.addFieldSubscription({
|
|
64796
64827
|
id: parent,
|
|
64797
64828
|
key,
|
|
64798
|
-
|
|
64829
|
+
field: fieldSelection,
|
|
64799
64830
|
spec,
|
|
64800
64831
|
parentType,
|
|
64801
64832
|
variables
|
|
64802
64833
|
});
|
|
64803
64834
|
}
|
|
64804
|
-
if (
|
|
64835
|
+
if (innerSelection) {
|
|
64805
64836
|
const { value: link } = this.cache._internal_unstable.storage.get(parent, key);
|
|
64806
64837
|
const children = !Array.isArray(link) ? [link] : flattenList(link);
|
|
64807
64838
|
for (const linkedRecord of children) {
|
|
@@ -64810,7 +64841,7 @@ var InMemorySubscriptions = class {
|
|
|
64810
64841
|
}
|
|
64811
64842
|
this.addMany({
|
|
64812
64843
|
parent: linkedRecord,
|
|
64813
|
-
selection:
|
|
64844
|
+
selection: innerSelection,
|
|
64814
64845
|
variables,
|
|
64815
64846
|
subscribers,
|
|
64816
64847
|
parentType: linkedType
|
|
@@ -64822,22 +64853,20 @@ var InMemorySubscriptions = class {
|
|
|
64822
64853
|
get(id, field) {
|
|
64823
64854
|
return this.subscribers[id]?.[field] || [];
|
|
64824
64855
|
}
|
|
64825
|
-
remove(id,
|
|
64856
|
+
remove(id, selection2, targets, variables, visited = []) {
|
|
64826
64857
|
visited.push(id);
|
|
64827
64858
|
const linkedIDs = [];
|
|
64828
|
-
for (const
|
|
64829
|
-
const key = evaluateKey(
|
|
64859
|
+
for (const fieldSelection of Object.values(selection2.fields || {})) {
|
|
64860
|
+
const key = evaluateKey(fieldSelection.keyRaw, variables);
|
|
64830
64861
|
this.removeSubscribers(id, key, targets);
|
|
64831
|
-
if (!
|
|
64862
|
+
if (!fieldSelection.selection?.fields) {
|
|
64832
64863
|
continue;
|
|
64833
64864
|
}
|
|
64834
|
-
if (selection2.list) {
|
|
64835
|
-
}
|
|
64836
64865
|
const { value: previousValue } = this.cache._internal_unstable.storage.get(id, key);
|
|
64837
64866
|
const links = !Array.isArray(previousValue) ? [previousValue] : flattenList(previousValue);
|
|
64838
64867
|
for (const link of links) {
|
|
64839
64868
|
if (link !== null) {
|
|
64840
|
-
linkedIDs.push([link,
|
|
64869
|
+
linkedIDs.push([link, fieldSelection.selection || {}]);
|
|
64841
64870
|
}
|
|
64842
64871
|
}
|
|
64843
64872
|
}
|
|
@@ -65015,8 +65044,9 @@ var CacheInternal = class {
|
|
|
65015
65044
|
if (this._disabled) {
|
|
65016
65045
|
return [];
|
|
65017
65046
|
}
|
|
65047
|
+
let targetSelection = getFieldsForType(selection2, data["__typename"]);
|
|
65018
65048
|
for (const [field, value] of Object.entries(data)) {
|
|
65019
|
-
if (!selection2 || !
|
|
65049
|
+
if (!selection2 || !targetSelection[field]) {
|
|
65020
65050
|
throw new Error(
|
|
65021
65051
|
"Could not find field listing in selection for " + field + " @ " + JSON.stringify(selection2)
|
|
65022
65052
|
);
|
|
@@ -65024,11 +65054,11 @@ var CacheInternal = class {
|
|
|
65024
65054
|
let {
|
|
65025
65055
|
type: linkedType,
|
|
65026
65056
|
keyRaw,
|
|
65027
|
-
|
|
65057
|
+
selection: fieldSelection,
|
|
65028
65058
|
operations,
|
|
65029
65059
|
abstract: isAbstract,
|
|
65030
65060
|
update
|
|
65031
|
-
} =
|
|
65061
|
+
} = targetSelection[field];
|
|
65032
65062
|
const key = evaluateKey(keyRaw, variables);
|
|
65033
65063
|
const currentSubscribers = this.subscriptions.get(parent, key);
|
|
65034
65064
|
const { value: previousValue, displayLayers } = this.storage.get(parent, key);
|
|
@@ -65036,7 +65066,7 @@ var CacheInternal = class {
|
|
|
65036
65066
|
if (displayLayer) {
|
|
65037
65067
|
this.lifetimes.resetLifetime(parent, key);
|
|
65038
65068
|
}
|
|
65039
|
-
if (!
|
|
65069
|
+
if (!fieldSelection) {
|
|
65040
65070
|
let newValue = value;
|
|
65041
65071
|
if (Array.isArray(value) && applyUpdates && update) {
|
|
65042
65072
|
if (update === "append") {
|
|
@@ -65056,7 +65086,7 @@ var CacheInternal = class {
|
|
|
65056
65086
|
}
|
|
65057
65087
|
const previousLinks = flattenList([previousValue]);
|
|
65058
65088
|
for (const link of previousLinks) {
|
|
65059
|
-
this.subscriptions.remove(link,
|
|
65089
|
+
this.subscriptions.remove(link, fieldSelection, currentSubscribers, variables);
|
|
65060
65090
|
}
|
|
65061
65091
|
layer.writeLink(parent, key, null);
|
|
65062
65092
|
toNotify.push(...currentSubscribers);
|
|
@@ -65082,14 +65112,14 @@ var CacheInternal = class {
|
|
|
65082
65112
|
if (previousValue && typeof previousValue === "string") {
|
|
65083
65113
|
this.subscriptions.remove(
|
|
65084
65114
|
previousValue,
|
|
65085
|
-
|
|
65115
|
+
fieldSelection,
|
|
65086
65116
|
currentSubscribers,
|
|
65087
65117
|
variables
|
|
65088
65118
|
);
|
|
65089
65119
|
}
|
|
65090
65120
|
this.subscriptions.addMany({
|
|
65091
65121
|
parent: linkedID,
|
|
65092
|
-
selection:
|
|
65122
|
+
selection: fieldSelection,
|
|
65093
65123
|
subscribers: currentSubscribers,
|
|
65094
65124
|
variables,
|
|
65095
65125
|
parentType: linkedType
|
|
@@ -65099,14 +65129,14 @@ var CacheInternal = class {
|
|
|
65099
65129
|
if (linkedID) {
|
|
65100
65130
|
this.writeSelection({
|
|
65101
65131
|
root,
|
|
65102
|
-
selection:
|
|
65132
|
+
selection: fieldSelection,
|
|
65103
65133
|
parent: linkedID,
|
|
65104
65134
|
data: value,
|
|
65105
65135
|
variables,
|
|
65106
65136
|
toNotify,
|
|
65107
65137
|
applyUpdates,
|
|
65108
65138
|
layer,
|
|
65109
|
-
forceNotify
|
|
65139
|
+
forceNotify
|
|
65110
65140
|
});
|
|
65111
65141
|
}
|
|
65112
65142
|
} else if (Array.isArray(value) && (typeof previousValue === "undefined" || Array.isArray(previousValue))) {
|
|
@@ -65135,7 +65165,7 @@ var CacheInternal = class {
|
|
|
65135
65165
|
key,
|
|
65136
65166
|
linkedType,
|
|
65137
65167
|
variables,
|
|
65138
|
-
fields,
|
|
65168
|
+
fields: fieldSelection,
|
|
65139
65169
|
layer,
|
|
65140
65170
|
forceNotify
|
|
65141
65171
|
});
|
|
@@ -65185,7 +65215,7 @@ var CacheInternal = class {
|
|
|
65185
65215
|
if (linkedIDs.includes(lostID) || !lostID) {
|
|
65186
65216
|
continue;
|
|
65187
65217
|
}
|
|
65188
|
-
this.subscriptions.remove(lostID,
|
|
65218
|
+
this.subscriptions.remove(lostID, fieldSelection, currentSubscribers, variables);
|
|
65189
65219
|
}
|
|
65190
65220
|
if (contentChanged || oldIDs.length === 0 && newIDs.length === 0) {
|
|
65191
65221
|
layer.writeLink(parent, key, linkedIDs);
|
|
@@ -65196,7 +65226,7 @@ var CacheInternal = class {
|
|
|
65196
65226
|
}
|
|
65197
65227
|
this.subscriptions.addMany({
|
|
65198
65228
|
parent: id,
|
|
65199
|
-
selection:
|
|
65229
|
+
selection: fieldSelection,
|
|
65200
65230
|
subscribers: currentSubscribers,
|
|
65201
65231
|
variables,
|
|
65202
65232
|
parentType: linkedType
|
|
@@ -65221,9 +65251,14 @@ var CacheInternal = class {
|
|
|
65221
65251
|
}
|
|
65222
65252
|
const targets = Array.isArray(value) ? value : [value];
|
|
65223
65253
|
for (const target of targets) {
|
|
65224
|
-
if (operation.action === "insert" && target instanceof Object &&
|
|
65225
|
-
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).addToList(
|
|
65226
|
-
|
|
65254
|
+
if (operation.action === "insert" && target instanceof Object && fieldSelection && operation.list) {
|
|
65255
|
+
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).addToList(
|
|
65256
|
+
fieldSelection,
|
|
65257
|
+
target,
|
|
65258
|
+
variables,
|
|
65259
|
+
operation.position || "last"
|
|
65260
|
+
);
|
|
65261
|
+
} else if (operation.action === "remove" && target instanceof Object && fieldSelection && operation.list) {
|
|
65227
65262
|
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables);
|
|
65228
65263
|
} else if (operation.action === "delete" && operation.type) {
|
|
65229
65264
|
if (typeof target !== "string") {
|
|
@@ -65234,8 +65269,13 @@ var CacheInternal = class {
|
|
|
65234
65269
|
continue;
|
|
65235
65270
|
}
|
|
65236
65271
|
this.cache.delete(targetID);
|
|
65237
|
-
} else if (operation.action === "toggle" && target instanceof Object &&
|
|
65238
|
-
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement(
|
|
65272
|
+
} else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
|
|
65273
|
+
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement(
|
|
65274
|
+
fieldSelection,
|
|
65275
|
+
target,
|
|
65276
|
+
variables,
|
|
65277
|
+
operation.position || "last"
|
|
65278
|
+
);
|
|
65239
65279
|
}
|
|
65240
65280
|
}
|
|
65241
65281
|
}
|
|
@@ -65255,9 +65295,12 @@ var CacheInternal = class {
|
|
|
65255
65295
|
let hasData = false;
|
|
65256
65296
|
let partial = false;
|
|
65257
65297
|
let cascadeNull = false;
|
|
65258
|
-
|
|
65259
|
-
|
|
65260
|
-
|
|
65298
|
+
const typename = this.storage.get(parent, "__typename").value;
|
|
65299
|
+
let targetSelection = getFieldsForType(selection2, typename);
|
|
65300
|
+
for (const [
|
|
65301
|
+
attributeName,
|
|
65302
|
+
{ type, keyRaw, selection: fieldSelection, nullable, list }
|
|
65303
|
+
] of Object.entries(targetSelection)) {
|
|
65261
65304
|
const key = evaluateKey(keyRaw, variables);
|
|
65262
65305
|
const { value } = this.storage.get(parent, key);
|
|
65263
65306
|
let nextStep = stepsFromConnection;
|
|
@@ -65280,7 +65323,7 @@ var CacheInternal = class {
|
|
|
65280
65323
|
if (typeof value !== "undefined") {
|
|
65281
65324
|
hasData = true;
|
|
65282
65325
|
}
|
|
65283
|
-
} else if (!
|
|
65326
|
+
} else if (!fieldSelection) {
|
|
65284
65327
|
const fnUnmarshal = this.config?.scalars?.[type]?.unmarshal;
|
|
65285
65328
|
if (fnUnmarshal) {
|
|
65286
65329
|
target[attributeName] = fnUnmarshal(value);
|
|
@@ -65290,7 +65333,7 @@ var CacheInternal = class {
|
|
|
65290
65333
|
hasData = true;
|
|
65291
65334
|
} else if (Array.isArray(value)) {
|
|
65292
65335
|
const listValue = this.hydrateNestedList({
|
|
65293
|
-
fields,
|
|
65336
|
+
fields: fieldSelection,
|
|
65294
65337
|
variables,
|
|
65295
65338
|
linkedList: value,
|
|
65296
65339
|
stepsFromConnection: nextStep
|
|
@@ -65305,7 +65348,7 @@ var CacheInternal = class {
|
|
|
65305
65348
|
} else {
|
|
65306
65349
|
const objectFields = this.getSelection({
|
|
65307
65350
|
parent: value,
|
|
65308
|
-
selection:
|
|
65351
|
+
selection: fieldSelection,
|
|
65309
65352
|
variables,
|
|
65310
65353
|
stepsFromConnection: nextStep
|
|
65311
65354
|
});
|
|
@@ -67039,7 +67082,7 @@ var Config = class {
|
|
|
67039
67082
|
typeConfig;
|
|
67040
67083
|
configFile;
|
|
67041
67084
|
logLevel;
|
|
67042
|
-
|
|
67085
|
+
defaultFragmentMasking = "enable";
|
|
67043
67086
|
configIsRoute = null;
|
|
67044
67087
|
routesDir;
|
|
67045
67088
|
schemaPollInterval;
|
|
@@ -67052,6 +67095,11 @@ var Config = class {
|
|
|
67052
67095
|
...configFile
|
|
67053
67096
|
}) {
|
|
67054
67097
|
this.configFile = defaultConfigValues(configFile);
|
|
67098
|
+
if (configFile.disableMasking !== void 0) {
|
|
67099
|
+
throw new HoudiniError({
|
|
67100
|
+
message: `"disableMasking" was replaced by "defaultFragmentMasking". Please update your config file.`
|
|
67101
|
+
});
|
|
67102
|
+
}
|
|
67055
67103
|
let {
|
|
67056
67104
|
schema,
|
|
67057
67105
|
schemaPath = "./schema.graphql",
|
|
@@ -67068,7 +67116,7 @@ var Config = class {
|
|
|
67068
67116
|
defaultKeys,
|
|
67069
67117
|
types: types15 = {},
|
|
67070
67118
|
logLevel,
|
|
67071
|
-
|
|
67119
|
+
defaultFragmentMasking = "enable",
|
|
67072
67120
|
schemaPollInterval = 2e3,
|
|
67073
67121
|
schemaPollHeaders = {},
|
|
67074
67122
|
projectDir
|
|
@@ -67087,7 +67135,11 @@ var Config = class {
|
|
|
67087
67135
|
logLevel = LogLevel.Summary;
|
|
67088
67136
|
}
|
|
67089
67137
|
this.schemaPath = schemaPath;
|
|
67090
|
-
|
|
67138
|
+
if (apiUrl && apiUrl.startsWith("env:")) {
|
|
67139
|
+
this.apiUrl = process.env[apiUrl.slice("env:".length)];
|
|
67140
|
+
} else {
|
|
67141
|
+
this.apiUrl = apiUrl;
|
|
67142
|
+
}
|
|
67091
67143
|
this.filepath = filepath;
|
|
67092
67144
|
this.exclude = Array.isArray(exclude) ? exclude : [exclude];
|
|
67093
67145
|
this.module = module2;
|
|
@@ -67099,10 +67151,10 @@ var Config = class {
|
|
|
67099
67151
|
this.defaultCachePolicy = defaultCachePolicy;
|
|
67100
67152
|
this.defaultPartial = defaultPartial;
|
|
67101
67153
|
this.internalListPosition = defaultListPosition === "append" ? "last" : "first";
|
|
67102
|
-
this.defaultListTarget
|
|
67154
|
+
this.defaultListTarget = defaultListTarget;
|
|
67103
67155
|
this.definitionsFolder = definitionsPath;
|
|
67104
67156
|
this.logLevel = (logLevel || LogLevel.Summary).toLowerCase();
|
|
67105
|
-
this.
|
|
67157
|
+
this.defaultFragmentMasking = defaultFragmentMasking;
|
|
67106
67158
|
this.routesDir = join2(this.projectRoot, "src", "routes");
|
|
67107
67159
|
this.schemaPollInterval = schemaPollInterval;
|
|
67108
67160
|
this.schemaPollHeaders = schemaPollHeaders;
|
|
@@ -67296,8 +67348,14 @@ var Config = class {
|
|
|
67296
67348
|
pluginDirectory(name2) {
|
|
67297
67349
|
return houdini_mode.is_testing ? resolve("../../../", name2) : join2(this.rootDir, "plugins", name2);
|
|
67298
67350
|
}
|
|
67299
|
-
get
|
|
67300
|
-
return "
|
|
67351
|
+
get manualLoadDirective() {
|
|
67352
|
+
return "manual_load";
|
|
67353
|
+
}
|
|
67354
|
+
get maskEnableDirective() {
|
|
67355
|
+
return "mask_enable";
|
|
67356
|
+
}
|
|
67357
|
+
get maskDisableDirective() {
|
|
67358
|
+
return "mask_disable";
|
|
67301
67359
|
}
|
|
67302
67360
|
get listDirective() {
|
|
67303
67361
|
return "list";
|
|
@@ -67309,9 +67367,9 @@ var Config = class {
|
|
|
67309
67367
|
return "append";
|
|
67310
67368
|
}
|
|
67311
67369
|
get listParentDirective() {
|
|
67312
|
-
return
|
|
67370
|
+
return "parentID";
|
|
67313
67371
|
}
|
|
67314
|
-
get
|
|
67372
|
+
get deprecatedlistDirectiveParentIDArg() {
|
|
67315
67373
|
return "parentID";
|
|
67316
67374
|
}
|
|
67317
67375
|
get listAllListsDirective() {
|
|
@@ -67397,7 +67455,7 @@ var Config = class {
|
|
|
67397
67455
|
this.listDirective,
|
|
67398
67456
|
this.listPrependDirective,
|
|
67399
67457
|
this.listAppendDirective,
|
|
67400
|
-
this.
|
|
67458
|
+
this.listParentDirective,
|
|
67401
67459
|
this.listAllListsDirective,
|
|
67402
67460
|
this.whenDirective,
|
|
67403
67461
|
this.whenNotDirective,
|
|
@@ -67405,7 +67463,9 @@ var Config = class {
|
|
|
67405
67463
|
this.withDirective,
|
|
67406
67464
|
this.paginateDirective,
|
|
67407
67465
|
this.cacheDirective,
|
|
67408
|
-
this.
|
|
67466
|
+
this.manualLoadDirective,
|
|
67467
|
+
this.maskEnableDirective,
|
|
67468
|
+
this.maskDisableDirective
|
|
67409
67469
|
].includes(name2.value) || this.isDeleteDirective(name2.value);
|
|
67410
67470
|
}
|
|
67411
67471
|
isListFragment(name2) {
|
|
@@ -67969,13 +68029,17 @@ function flattenSelections({
|
|
|
67969
68029
|
config: config3,
|
|
67970
68030
|
filepath,
|
|
67971
68031
|
selections,
|
|
67972
|
-
fragmentDefinitions
|
|
68032
|
+
fragmentDefinitions,
|
|
68033
|
+
applyFragments,
|
|
68034
|
+
ignoreMaskDisable
|
|
67973
68035
|
}) {
|
|
67974
68036
|
const fields = new FieldCollection({
|
|
67975
68037
|
config: config3,
|
|
67976
68038
|
filepath,
|
|
67977
68039
|
selections,
|
|
67978
|
-
fragmentDefinitions
|
|
68040
|
+
fragmentDefinitions,
|
|
68041
|
+
applyFragments,
|
|
68042
|
+
ignoreMaskDisable: !!ignoreMaskDisable
|
|
67979
68043
|
});
|
|
67980
68044
|
return fields.toSelectionSet();
|
|
67981
68045
|
}
|
|
@@ -67986,9 +68050,13 @@ var FieldCollection = class {
|
|
|
67986
68050
|
fields;
|
|
67987
68051
|
inlineFragments;
|
|
67988
68052
|
fragmentSpreads;
|
|
68053
|
+
applyFragments;
|
|
68054
|
+
ignoreMaskDisable;
|
|
67989
68055
|
constructor(args) {
|
|
67990
68056
|
this.config = args.config;
|
|
67991
68057
|
this.fragmentDefinitions = args.fragmentDefinitions;
|
|
68058
|
+
this.applyFragments = args.applyFragments;
|
|
68059
|
+
this.ignoreMaskDisable = args.ignoreMaskDisable;
|
|
67992
68060
|
this.fields = {};
|
|
67993
68061
|
this.inlineFragments = {};
|
|
67994
68062
|
this.fragmentSpreads = {};
|
|
@@ -68017,31 +68085,28 @@ var FieldCollection = class {
|
|
|
68017
68085
|
}
|
|
68018
68086
|
}
|
|
68019
68087
|
if (selection2.kind === "InlineFragment" && selection2.typeCondition) {
|
|
68020
|
-
|
|
68021
|
-
if (!this.inlineFragments[key]) {
|
|
68022
|
-
this.inlineFragments[key] = {
|
|
68023
|
-
astNode: selection2,
|
|
68024
|
-
selection: this.empty()
|
|
68025
|
-
};
|
|
68026
|
-
}
|
|
68027
|
-
for (const subselect of selection2.selectionSet?.selections || []) {
|
|
68028
|
-
this.inlineFragments[key].selection.add(subselect);
|
|
68029
|
-
}
|
|
68088
|
+
this.walkInlineFragment(selection2);
|
|
68030
68089
|
return;
|
|
68031
68090
|
}
|
|
68032
68091
|
if (selection2.kind === "FragmentSpread") {
|
|
68033
68092
|
this.fragmentSpreads[selection2.name.value] = selection2;
|
|
68034
|
-
|
|
68035
|
-
|
|
68093
|
+
let includeFragments = this.config.defaultFragmentMasking === "disable";
|
|
68094
|
+
const maskEnableDirective = selection2.directives?.find(
|
|
68095
|
+
({ name: name2 }) => name2.value === this.config.maskEnableDirective
|
|
68036
68096
|
);
|
|
68037
|
-
|
|
68038
|
-
|
|
68097
|
+
if (maskEnableDirective) {
|
|
68098
|
+
includeFragments = false;
|
|
68099
|
+
}
|
|
68100
|
+
const maskDisableDirective = selection2.directives?.find(
|
|
68101
|
+
({ name: name2 }) => name2.value === this.config.maskDisableDirective
|
|
68039
68102
|
);
|
|
68040
|
-
|
|
68041
|
-
|
|
68042
|
-
includeFragments = !maskArgument.value.value;
|
|
68103
|
+
if (maskDisableDirective) {
|
|
68104
|
+
includeFragments = true;
|
|
68043
68105
|
}
|
|
68044
|
-
if (
|
|
68106
|
+
if (this.ignoreMaskDisable) {
|
|
68107
|
+
includeFragments = true;
|
|
68108
|
+
}
|
|
68109
|
+
if (!includeFragments || !this.applyFragments) {
|
|
68045
68110
|
return;
|
|
68046
68111
|
}
|
|
68047
68112
|
const definition = this.fragmentDefinitions[selection2.name.value];
|
|
@@ -68051,9 +68116,20 @@ var FieldCollection = class {
|
|
|
68051
68116
|
message: "Could not find referenced fragment definition: " + selection2.name.value
|
|
68052
68117
|
});
|
|
68053
68118
|
}
|
|
68054
|
-
|
|
68055
|
-
|
|
68056
|
-
|
|
68119
|
+
this.add({
|
|
68120
|
+
kind: "InlineFragment",
|
|
68121
|
+
typeCondition: {
|
|
68122
|
+
kind: "NamedType",
|
|
68123
|
+
name: {
|
|
68124
|
+
kind: "Name",
|
|
68125
|
+
value: definition.typeCondition.name.value
|
|
68126
|
+
}
|
|
68127
|
+
},
|
|
68128
|
+
selectionSet: {
|
|
68129
|
+
kind: "SelectionSet",
|
|
68130
|
+
selections: [...definition.selectionSet.selections]
|
|
68131
|
+
}
|
|
68132
|
+
});
|
|
68057
68133
|
}
|
|
68058
68134
|
}
|
|
68059
68135
|
toSelectionSet() {
|
|
@@ -68069,12 +68145,30 @@ var FieldCollection = class {
|
|
|
68069
68145
|
})
|
|
68070
68146
|
).concat(Object.values(this.fragmentSpreads));
|
|
68071
68147
|
}
|
|
68148
|
+
walkInlineFragment(selection2) {
|
|
68149
|
+
const key = selection2.typeCondition.name.value;
|
|
68150
|
+
if (!this.inlineFragments[key]) {
|
|
68151
|
+
this.inlineFragments[key] = {
|
|
68152
|
+
astNode: selection2,
|
|
68153
|
+
selection: this.empty()
|
|
68154
|
+
};
|
|
68155
|
+
}
|
|
68156
|
+
for (const subselect of selection2.selectionSet.selections || []) {
|
|
68157
|
+
if (subselect.kind !== "InlineFragment" || !subselect.typeCondition) {
|
|
68158
|
+
this.inlineFragments[key].selection.add(subselect);
|
|
68159
|
+
continue;
|
|
68160
|
+
}
|
|
68161
|
+
this.walkInlineFragment(subselect);
|
|
68162
|
+
}
|
|
68163
|
+
}
|
|
68072
68164
|
empty() {
|
|
68073
68165
|
return new FieldCollection({
|
|
68074
68166
|
config: this.config,
|
|
68075
68167
|
fragmentDefinitions: this.fragmentDefinitions,
|
|
68076
68168
|
selections: [],
|
|
68077
|
-
filepath: this.filepath
|
|
68169
|
+
filepath: this.filepath,
|
|
68170
|
+
applyFragments: this.applyFragments,
|
|
68171
|
+
ignoreMaskDisable: this.ignoreMaskDisable
|
|
68078
68172
|
});
|
|
68079
68173
|
}
|
|
68080
68174
|
};
|
|
@@ -68429,11 +68523,6 @@ function operationObject({
|
|
|
68429
68523
|
const when = internalDirectives.find(({ name: name2 }) => name2.value === "when");
|
|
68430
68524
|
const when_not = internalDirectives.find(({ name: name2 }) => name2.value === "when_not");
|
|
68431
68525
|
let parentIDArg = parent?.arguments?.find((argument) => argument.name.value === "value");
|
|
68432
|
-
if (!parentIDArg) {
|
|
68433
|
-
parentIDArg = (append || prepend)?.arguments?.find(
|
|
68434
|
-
({ name: name2 }) => name2.value === config3.listDirectiveParentIDArg
|
|
68435
|
-
);
|
|
68436
|
-
}
|
|
68437
68526
|
if (parentIDArg) {
|
|
68438
68527
|
if (parentIDArg.value.kind === "StringValue") {
|
|
68439
68528
|
parentID = parentIDArg.value.value;
|
|
@@ -69424,6 +69513,8 @@ function selection({
|
|
|
69424
69513
|
markEdges
|
|
69425
69514
|
}) {
|
|
69426
69515
|
let object = {};
|
|
69516
|
+
const typeMap = {};
|
|
69517
|
+
const abstractTypes = [];
|
|
69427
69518
|
for (const field of selections) {
|
|
69428
69519
|
if (field.kind === "FragmentSpread" && includeFragments) {
|
|
69429
69520
|
const fragmentDefinition = document.document.definitions.find(
|
|
@@ -69450,20 +69541,68 @@ function selection({
|
|
|
69450
69541
|
})
|
|
69451
69542
|
);
|
|
69452
69543
|
} else if (field.kind === "InlineFragment") {
|
|
69453
|
-
|
|
69454
|
-
|
|
69455
|
-
object,
|
|
69456
|
-
selection({
|
|
69457
|
-
config: config3,
|
|
69544
|
+
if (!field.typeCondition || field.typeCondition.name.value === rootType) {
|
|
69545
|
+
object.fields = deepMerge(
|
|
69458
69546
|
filepath,
|
|
69459
|
-
|
|
69460
|
-
|
|
69461
|
-
|
|
69462
|
-
|
|
69463
|
-
|
|
69464
|
-
|
|
69465
|
-
|
|
69466
|
-
|
|
69547
|
+
object.fields || {},
|
|
69548
|
+
selection({
|
|
69549
|
+
config: config3,
|
|
69550
|
+
filepath,
|
|
69551
|
+
rootType: field.typeCondition?.name.value || rootType,
|
|
69552
|
+
operations,
|
|
69553
|
+
selections: field.selectionSet.selections,
|
|
69554
|
+
path: path2,
|
|
69555
|
+
includeFragments,
|
|
69556
|
+
document
|
|
69557
|
+
}).fields || {}
|
|
69558
|
+
);
|
|
69559
|
+
} else {
|
|
69560
|
+
if (!object.abstractFields) {
|
|
69561
|
+
object.abstractFields = {
|
|
69562
|
+
fields: {},
|
|
69563
|
+
typeMap: {}
|
|
69564
|
+
};
|
|
69565
|
+
}
|
|
69566
|
+
const parentType = config3.schema.getType(rootType);
|
|
69567
|
+
const typeConditionName = field.typeCondition.name.value;
|
|
69568
|
+
const typeCondition = config3.schema.getType(typeConditionName);
|
|
69569
|
+
const possibleTypes = [];
|
|
69570
|
+
if (!graphql12.isAbstractType(typeCondition)) {
|
|
69571
|
+
} else if (graphql12.isAbstractType(parentType)) {
|
|
69572
|
+
const possibleParentTypes = config3.schema.getPossibleTypes(parentType).map((type) => type.name);
|
|
69573
|
+
for (const possible of config3.schema.getPossibleTypes(typeCondition)) {
|
|
69574
|
+
if (possibleParentTypes.includes(possible.name)) {
|
|
69575
|
+
possibleTypes.push(possible.name);
|
|
69576
|
+
}
|
|
69577
|
+
}
|
|
69578
|
+
} else {
|
|
69579
|
+
possibleTypes.push(rootType);
|
|
69580
|
+
}
|
|
69581
|
+
if (possibleTypes.length > 0) {
|
|
69582
|
+
for (const type of possibleTypes) {
|
|
69583
|
+
const existing = typeMap[type];
|
|
69584
|
+
if (!existing || !existing.includes(type)) {
|
|
69585
|
+
typeMap[type] = [typeConditionName].concat(existing || []);
|
|
69586
|
+
}
|
|
69587
|
+
if (!abstractTypes.includes(typeConditionName)) {
|
|
69588
|
+
abstractTypes.push(typeConditionName);
|
|
69589
|
+
}
|
|
69590
|
+
}
|
|
69591
|
+
}
|
|
69592
|
+
object.abstractFields.fields = {
|
|
69593
|
+
...object.abstractFields.fields,
|
|
69594
|
+
[field.typeCondition.name.value]: selection({
|
|
69595
|
+
config: config3,
|
|
69596
|
+
filepath,
|
|
69597
|
+
rootType: field.typeCondition?.name.value || rootType,
|
|
69598
|
+
operations,
|
|
69599
|
+
selections: field.selectionSet.selections,
|
|
69600
|
+
path: path2,
|
|
69601
|
+
includeFragments,
|
|
69602
|
+
document
|
|
69603
|
+
}).fields
|
|
69604
|
+
};
|
|
69605
|
+
}
|
|
69467
69606
|
} else if (field.kind === "Field") {
|
|
69468
69607
|
const type = config3.schema.getType(rootType);
|
|
69469
69608
|
if (!type) {
|
|
@@ -69521,7 +69660,7 @@ function selection({
|
|
|
69521
69660
|
}
|
|
69522
69661
|
if (field.selectionSet) {
|
|
69523
69662
|
const edgesMark = paginated && document.refetch?.method === "cursor" ? document.refetch.update : markEdges;
|
|
69524
|
-
fieldObj.
|
|
69663
|
+
fieldObj.selection = selection({
|
|
69525
69664
|
config: config3,
|
|
69526
69665
|
filepath,
|
|
69527
69666
|
rootType: typeName,
|
|
@@ -69545,11 +69684,49 @@ function selection({
|
|
|
69545
69684
|
if (graphql12.isInterfaceType(fieldType) || graphql12.isUnionType(fieldType)) {
|
|
69546
69685
|
fieldObj.abstract = true;
|
|
69547
69686
|
}
|
|
69548
|
-
object
|
|
69549
|
-
|
|
69550
|
-
fieldObj
|
|
69551
|
-
|
|
69552
|
-
|
|
69687
|
+
object.fields = {
|
|
69688
|
+
...object.fields,
|
|
69689
|
+
[attributeName]: fieldObj
|
|
69690
|
+
};
|
|
69691
|
+
}
|
|
69692
|
+
}
|
|
69693
|
+
if (Object.keys(object.fields || {}).length > 0 && object.abstractFields && Object.keys(object.abstractFields.fields).length > 0) {
|
|
69694
|
+
for (const [typeName, possibles] of Object.entries(typeMap)) {
|
|
69695
|
+
let overlap = false;
|
|
69696
|
+
for (const possible of possibles) {
|
|
69697
|
+
if (object.abstractFields.fields[typeName]) {
|
|
69698
|
+
object.abstractFields.fields[typeName] = deepMerge(
|
|
69699
|
+
filepath,
|
|
69700
|
+
object.abstractFields.fields[typeName] || {},
|
|
69701
|
+
object.abstractFields.fields[possible]
|
|
69702
|
+
);
|
|
69703
|
+
overlap = true;
|
|
69704
|
+
}
|
|
69705
|
+
}
|
|
69706
|
+
if (overlap) {
|
|
69707
|
+
delete typeMap[typeName];
|
|
69708
|
+
}
|
|
69709
|
+
}
|
|
69710
|
+
for (const [type, options] of Object.entries(typeMap)) {
|
|
69711
|
+
if (options.length > 1) {
|
|
69712
|
+
object.abstractFields.fields[type] = deepMerge(
|
|
69713
|
+
filepath,
|
|
69714
|
+
...options.map((opt) => object.abstractFields.fields[opt] || {})
|
|
69715
|
+
);
|
|
69716
|
+
delete typeMap[type];
|
|
69717
|
+
}
|
|
69718
|
+
}
|
|
69719
|
+
for (const [type, sel] of Object.entries(object.abstractFields?.fields || {})) {
|
|
69720
|
+
object.abstractFields.fields[type] = deepMerge(filepath, sel || {}, object.fields);
|
|
69721
|
+
}
|
|
69722
|
+
for (const [type, options] of Object.entries(typeMap)) {
|
|
69723
|
+
object.abstractFields.typeMap[type] = options[0];
|
|
69724
|
+
}
|
|
69725
|
+
const usedTypes = Object.values(object.abstractFields.typeMap);
|
|
69726
|
+
for (const type of abstractTypes) {
|
|
69727
|
+
if (!usedTypes.includes(type)) {
|
|
69728
|
+
delete object.abstractFields.fields[type];
|
|
69729
|
+
}
|
|
69553
69730
|
}
|
|
69554
69731
|
}
|
|
69555
69732
|
return object;
|
|
@@ -69684,6 +69861,22 @@ function artifactGenerator(stats) {
|
|
|
69684
69861
|
selectionSet = matchingFragment.selectionSet;
|
|
69685
69862
|
}
|
|
69686
69863
|
const inputs = operations[0]?.variableDefinitions;
|
|
69864
|
+
const mergedSelection = flattenSelections({
|
|
69865
|
+
config: config3,
|
|
69866
|
+
filepath: doc.filename,
|
|
69867
|
+
selections: selectionSet.selections,
|
|
69868
|
+
fragmentDefinitions: doc.document.definitions.filter(
|
|
69869
|
+
(definition) => definition.kind === "FragmentDefinition"
|
|
69870
|
+
).reduce(
|
|
69871
|
+
(prev, definition) => ({
|
|
69872
|
+
...prev,
|
|
69873
|
+
[definition.name.value]: definition
|
|
69874
|
+
}),
|
|
69875
|
+
{}
|
|
69876
|
+
),
|
|
69877
|
+
ignoreMaskDisable: docKind === "HoudiniQuery",
|
|
69878
|
+
applyFragments: docKind !== "HoudiniFragment"
|
|
69879
|
+
});
|
|
69687
69880
|
const artifact = {
|
|
69688
69881
|
name: name2,
|
|
69689
69882
|
kind: docKind,
|
|
@@ -69695,7 +69888,7 @@ function artifactGenerator(stats) {
|
|
|
69695
69888
|
config: config3,
|
|
69696
69889
|
filepath: doc.filename,
|
|
69697
69890
|
rootType,
|
|
69698
|
-
selections:
|
|
69891
|
+
selections: mergedSelection,
|
|
69699
69892
|
operations: operationsByPath(
|
|
69700
69893
|
config3,
|
|
69701
69894
|
doc.filename,
|
|
@@ -69991,6 +70184,17 @@ function inlineType({
|
|
|
69991
70184
|
continue;
|
|
69992
70185
|
}
|
|
69993
70186
|
const possibleParents = config3.schema.getPossibleTypes(type).map((t2) => t2.name);
|
|
70187
|
+
const freeSelections = [];
|
|
70188
|
+
const typeSpecificSelections = {};
|
|
70189
|
+
for (const node of selection2.selectionSet.selections) {
|
|
70190
|
+
if (node.kind !== "InlineFragment") {
|
|
70191
|
+
freeSelections.push(node);
|
|
70192
|
+
} else if (node.typeCondition) {
|
|
70193
|
+
typeSpecificSelections[node.typeCondition.name.value] = node.selectionSet.selections;
|
|
70194
|
+
} else {
|
|
70195
|
+
freeSelections.push(...node.selectionSet.selections);
|
|
70196
|
+
}
|
|
70197
|
+
}
|
|
69994
70198
|
for (const possibleType of config3.schema.getPossibleTypes(fragmentType)) {
|
|
69995
70199
|
if (!possibleParents.includes(possibleType.name)) {
|
|
69996
70200
|
continue;
|
|
@@ -69998,7 +70202,12 @@ function inlineType({
|
|
|
69998
70202
|
if (!inlineFragments[possibleType.name]) {
|
|
69999
70203
|
inlineFragments[possibleType.name] = [];
|
|
70000
70204
|
}
|
|
70001
|
-
inlineFragments[possibleType.name].push(...
|
|
70205
|
+
inlineFragments[possibleType.name].push(...freeSelections);
|
|
70206
|
+
if (typeSpecificSelections[possibleType.name]) {
|
|
70207
|
+
inlineFragments[possibleType.name].push(
|
|
70208
|
+
...typeSpecificSelections[possibleType.name]
|
|
70209
|
+
);
|
|
70210
|
+
}
|
|
70002
70211
|
}
|
|
70003
70212
|
} else if (selection2.kind === "InlineFragment" && !selection2.typeCondition) {
|
|
70004
70213
|
selectedFields.push(...selection2.selectionSet.selections);
|
|
@@ -70010,12 +70219,7 @@ function inlineType({
|
|
|
70010
70219
|
...(selectedFields || []).filter(
|
|
70011
70220
|
(field) => field.kind === "Field"
|
|
70012
70221
|
).map((selection2) => {
|
|
70013
|
-
const {
|
|
70014
|
-
config3.schema,
|
|
70015
|
-
filepath,
|
|
70016
|
-
rootObj,
|
|
70017
|
-
selection2
|
|
70018
|
-
);
|
|
70222
|
+
const { field } = selectionTypeInfo(config3.schema, filepath, rootObj, selection2);
|
|
70019
70223
|
const attributeName = selection2.alias?.value || selection2.name.value;
|
|
70020
70224
|
let attributeType = inlineType({
|
|
70021
70225
|
config: config3,
|
|
@@ -70214,7 +70418,8 @@ async function typescriptGenerator(config3, docs) {
|
|
|
70214
70418
|
config: config3,
|
|
70215
70419
|
filepath: filename,
|
|
70216
70420
|
selections: definition.selectionSet.selections,
|
|
70217
|
-
fragmentDefinitions
|
|
70421
|
+
fragmentDefinitions,
|
|
70422
|
+
applyFragments: definition.kind === "OperationDefinition"
|
|
70218
70423
|
});
|
|
70219
70424
|
if (definition?.kind === "OperationDefinition") {
|
|
70220
70425
|
await generateOperationTypeDefs(
|
|
@@ -70727,14 +70932,12 @@ directive @${config3.paginateDirective}(${config3.paginateNameArg}: String) on F
|
|
|
70727
70932
|
"""
|
|
70728
70933
|
@${config3.listPrependDirective} is used to tell the runtime to add the result to the end of the list
|
|
70729
70934
|
"""
|
|
70730
|
-
directive @${config3.listPrependDirective}
|
|
70731
|
-
${config3.listDirectiveParentIDArg}: ID
|
|
70732
|
-
) on FRAGMENT_SPREAD
|
|
70935
|
+
directive @${config3.listPrependDirective} on FRAGMENT_SPREAD
|
|
70733
70936
|
|
|
70734
70937
|
"""
|
|
70735
70938
|
@${config3.listAppendDirective} is used to tell the runtime to add the result to the start of the list
|
|
70736
70939
|
"""
|
|
70737
|
-
directive @${config3.listAppendDirective}
|
|
70940
|
+
directive @${config3.listAppendDirective} on FRAGMENT_SPREAD
|
|
70738
70941
|
|
|
70739
70942
|
"""
|
|
70740
70943
|
@${config3.listAllListsDirective} is used to tell the runtime to add the result to all list
|
|
@@ -70768,18 +70971,19 @@ directive @${config3.argumentsDirective} on FRAGMENT_DEFINITION
|
|
|
70768
70971
|
directive @${config3.cacheDirective}(${config3.cachePolicyArg}: CachePolicy, ${config3.cachePartialArg}: Boolean) on QUERY
|
|
70769
70972
|
|
|
70770
70973
|
"""
|
|
70771
|
-
@${config3.
|
|
70974
|
+
@${config3.manualLoadDirective} is used to disable automatic fetch (no load, no auto fetch in component), you will have to do it manually.
|
|
70975
|
+
"""
|
|
70976
|
+
directive @${config3.manualLoadDirective} on QUERY
|
|
70977
|
+
|
|
70978
|
+
"""
|
|
70979
|
+
@${config3.maskEnableDirective} to enable masking on fragment (overwriting the global conf)
|
|
70980
|
+
"""
|
|
70981
|
+
directive @${config3.maskEnableDirective} on FRAGMENT_SPREAD
|
|
70982
|
+
|
|
70983
|
+
"""
|
|
70984
|
+
@${config3.maskDisableDirective} to disable masking on fragment (overwriting the global conf)
|
|
70772
70985
|
"""
|
|
70773
|
-
directive @${config3.
|
|
70774
|
-
"""
|
|
70775
|
-
Opt-in to an automatic load function (only valid when used at queries)
|
|
70776
|
-
"""
|
|
70777
|
-
load: Boolean! = true
|
|
70778
|
-
"""
|
|
70779
|
-
Mask fragment fields (only valid when used at a fragment spread)
|
|
70780
|
-
"""
|
|
70781
|
-
mask: Boolean! = ${config3.disableMasking ? "false" : "true"}
|
|
70782
|
-
) on QUERY | FRAGMENT_SPREAD
|
|
70986
|
+
directive @${config3.maskDisableDirective} on FRAGMENT_SPREAD
|
|
70783
70987
|
`;
|
|
70784
70988
|
let currentSchema = graphql21.printSchema(config3.schema);
|
|
70785
70989
|
if (!currentSchema.includes(`directive @${config3.listDirective}`)) {
|
|
@@ -71272,26 +71476,42 @@ async function typeCheck(config3, docs) {
|
|
|
71272
71476
|
),
|
|
71273
71477
|
targetField.selectionSet
|
|
71274
71478
|
);
|
|
71275
|
-
|
|
71276
|
-
if (
|
|
71277
|
-
|
|
71278
|
-
|
|
71279
|
-
|
|
71280
|
-
|
|
71281
|
-
|
|
71282
|
-
|
|
71283
|
-
|
|
71284
|
-
|
|
71285
|
-
|
|
71286
|
-
|
|
71287
|
-
|
|
71288
|
-
|
|
71289
|
-
|
|
71290
|
-
|
|
71291
|
-
|
|
71292
|
-
)
|
|
71479
|
+
let targetTypes = [type];
|
|
71480
|
+
if (graphql25.isUnionType(type)) {
|
|
71481
|
+
targetTypes = config3.schema.getPossibleTypes(type);
|
|
71482
|
+
} else if (graphql25.isInterfaceType(type)) {
|
|
71483
|
+
try {
|
|
71484
|
+
for (const key of config3.keyFieldsForType(type.name)) {
|
|
71485
|
+
if (!type.getFields()[key]) {
|
|
71486
|
+
throw new Error("continue");
|
|
71487
|
+
}
|
|
71488
|
+
}
|
|
71489
|
+
} catch {
|
|
71490
|
+
targetTypes = config3.schema.getPossibleTypes(type);
|
|
71491
|
+
}
|
|
71492
|
+
}
|
|
71493
|
+
for (const targetType of targetTypes) {
|
|
71494
|
+
const missingIDFields = config3.keyFieldsForType(targetType.name).filter((fieldName) => !targetType.getFields()[fieldName]);
|
|
71495
|
+
if (missingIDFields.length > 0) {
|
|
71496
|
+
if (error) {
|
|
71497
|
+
errors.push(
|
|
71498
|
+
new HoudiniError({
|
|
71499
|
+
filepath: filename,
|
|
71500
|
+
message: error
|
|
71501
|
+
})
|
|
71502
|
+
);
|
|
71503
|
+
} else {
|
|
71504
|
+
errors.push(
|
|
71505
|
+
new HoudiniError({
|
|
71506
|
+
filepath: filename,
|
|
71507
|
+
message: `@${config3.listDirective} can only be applied to types with the necessary id fields: ${missingIDFields.join(
|
|
71508
|
+
", "
|
|
71509
|
+
)}.`
|
|
71510
|
+
})
|
|
71511
|
+
);
|
|
71512
|
+
}
|
|
71513
|
+
return;
|
|
71293
71514
|
}
|
|
71294
|
-
return;
|
|
71295
71515
|
}
|
|
71296
71516
|
lists.push(listName);
|
|
71297
71517
|
listTypes.push(type.name);
|
|
@@ -71321,6 +71541,7 @@ async function typeCheck(config3, docs) {
|
|
|
71321
71541
|
fragments
|
|
71322
71542
|
}),
|
|
71323
71543
|
checkMutationOperation(config3),
|
|
71544
|
+
checkMaskDirective(config3),
|
|
71324
71545
|
nodeDirectives(config3, [config3.paginateDirective]),
|
|
71325
71546
|
knownArguments(config3),
|
|
71326
71547
|
validateFragmentArguments(config3, filepath, fragments),
|
|
@@ -71385,10 +71606,14 @@ var validateLists = ({
|
|
|
71385
71606
|
]);
|
|
71386
71607
|
if (directive) {
|
|
71387
71608
|
let parentArg = directive.arguments?.find(
|
|
71388
|
-
(arg) => arg.name.value === config3.
|
|
71609
|
+
(arg) => arg.name.value === config3.deprecatedlistDirectiveParentIDArg
|
|
71389
71610
|
);
|
|
71390
71611
|
if (parentArg) {
|
|
71391
|
-
|
|
71612
|
+
ctx.reportError(
|
|
71613
|
+
new graphql25.GraphQLError(
|
|
71614
|
+
`@${config3.deprecatedlistDirectiveParentIDArg} should be defined only in it's own directive now`
|
|
71615
|
+
)
|
|
71616
|
+
);
|
|
71392
71617
|
}
|
|
71393
71618
|
}
|
|
71394
71619
|
if (parentIdFound) {
|
|
@@ -71784,6 +72009,28 @@ function checkMutationOperation(config3) {
|
|
|
71784
72009
|
};
|
|
71785
72010
|
};
|
|
71786
72011
|
}
|
|
72012
|
+
function checkMaskDirective(config3) {
|
|
72013
|
+
return function(ctx) {
|
|
72014
|
+
return {
|
|
72015
|
+
FragmentSpread(node, _, __, ___, ancestors) {
|
|
72016
|
+
const maskEnableDirective = node.directives?.find(
|
|
72017
|
+
(c) => c.name.value === config3.maskEnableDirective
|
|
72018
|
+
);
|
|
72019
|
+
const maskDisableDirective = node.directives?.find(
|
|
72020
|
+
(c) => c.name.value === config3.maskDisableDirective
|
|
72021
|
+
);
|
|
72022
|
+
if (maskEnableDirective && maskDisableDirective) {
|
|
72023
|
+
ctx.reportError(
|
|
72024
|
+
new graphql25.GraphQLError(
|
|
72025
|
+
`You can't apply both @${config3.maskEnableDirective} and @${config3.maskDisableDirective} at the same time`
|
|
72026
|
+
)
|
|
72027
|
+
);
|
|
72028
|
+
return;
|
|
72029
|
+
}
|
|
72030
|
+
}
|
|
72031
|
+
};
|
|
72032
|
+
};
|
|
72033
|
+
}
|
|
71787
72034
|
function getAndVerifyNodeInterface(config3) {
|
|
71788
72035
|
const { schema } = config3;
|
|
71789
72036
|
const nodeInterface = schema.getType("Node");
|
|
@@ -72081,12 +72328,7 @@ async function collectDocuments(config3) {
|
|
|
72081
72328
|
}
|
|
72082
72329
|
async function processJSFile(config3, contents) {
|
|
72083
72330
|
const documents = [];
|
|
72084
|
-
|
|
72085
|
-
var program = (await parseJS(contents)).script;
|
|
72086
|
-
} catch (e2) {
|
|
72087
|
-
console.log(contents);
|
|
72088
|
-
throw e2;
|
|
72089
|
-
}
|
|
72331
|
+
var program = (await parseJS(contents)).script;
|
|
72090
72332
|
await find_graphql(config3, program, {
|
|
72091
72333
|
tag({ tagContent }) {
|
|
72092
72334
|
documents.push(tagContent);
|
|
@@ -72298,8 +72540,11 @@ function HoudiniWatchSchemaPlugin(opts = {}) {
|
|
|
72298
72540
|
if (interval <= 0) {
|
|
72299
72541
|
return;
|
|
72300
72542
|
}
|
|
72301
|
-
|
|
72302
|
-
|
|
72543
|
+
async function sleepAndStartPullLoop(interval2) {
|
|
72544
|
+
await sleep(interval2);
|
|
72545
|
+
await pull(true);
|
|
72546
|
+
}
|
|
72547
|
+
sleepAndStartPullLoop(interval);
|
|
72303
72548
|
},
|
|
72304
72549
|
buildEnd() {
|
|
72305
72550
|
go = false;
|