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-esm/index.js
CHANGED
|
@@ -6779,7 +6779,7 @@ var require_definition = __commonJS({
|
|
|
6779
6779
|
exports.assertObjectType = assertObjectType;
|
|
6780
6780
|
exports.isInterfaceType = isInterfaceType12;
|
|
6781
6781
|
exports.assertInterfaceType = assertInterfaceType;
|
|
6782
|
-
exports.isUnionType =
|
|
6782
|
+
exports.isUnionType = isUnionType13;
|
|
6783
6783
|
exports.assertUnionType = assertUnionType;
|
|
6784
6784
|
exports.isEnumType = isEnumType9;
|
|
6785
6785
|
exports.assertEnumType = assertEnumType;
|
|
@@ -6797,7 +6797,7 @@ var require_definition = __commonJS({
|
|
|
6797
6797
|
exports.assertLeafType = assertLeafType;
|
|
6798
6798
|
exports.isCompositeType = isCompositeType;
|
|
6799
6799
|
exports.assertCompositeType = assertCompositeType;
|
|
6800
|
-
exports.isAbstractType =
|
|
6800
|
+
exports.isAbstractType = isAbstractType2;
|
|
6801
6801
|
exports.assertAbstractType = assertAbstractType;
|
|
6802
6802
|
exports.GraphQLList = GraphQLList6;
|
|
6803
6803
|
exports.GraphQLNonNull = GraphQLNonNull6;
|
|
@@ -6852,7 +6852,7 @@ var require_definition = __commonJS({
|
|
|
6852
6852
|
return Constructor;
|
|
6853
6853
|
}
|
|
6854
6854
|
function isType(type) {
|
|
6855
|
-
return isScalarType12(type) || isObjectType11(type) || isInterfaceType12(type) ||
|
|
6855
|
+
return isScalarType12(type) || isObjectType11(type) || isInterfaceType12(type) || isUnionType13(type) || isEnumType9(type) || isInputObjectType7(type) || isListType8(type) || isNonNullType10(type);
|
|
6856
6856
|
}
|
|
6857
6857
|
function assertType(type) {
|
|
6858
6858
|
if (!isType(type)) {
|
|
@@ -6887,11 +6887,11 @@ var require_definition = __commonJS({
|
|
|
6887
6887
|
}
|
|
6888
6888
|
return type;
|
|
6889
6889
|
}
|
|
6890
|
-
function
|
|
6890
|
+
function isUnionType13(type) {
|
|
6891
6891
|
return (0, _instanceOf.default)(type, GraphQLUnionType3);
|
|
6892
6892
|
}
|
|
6893
6893
|
function assertUnionType(type) {
|
|
6894
|
-
if (!
|
|
6894
|
+
if (!isUnionType13(type)) {
|
|
6895
6895
|
throw new Error("Expected ".concat((0, _inspect.default)(type), " to be a GraphQL Union type."));
|
|
6896
6896
|
}
|
|
6897
6897
|
return type;
|
|
@@ -6942,7 +6942,7 @@ var require_definition = __commonJS({
|
|
|
6942
6942
|
return type;
|
|
6943
6943
|
}
|
|
6944
6944
|
function isOutputType(type) {
|
|
6945
|
-
return isScalarType12(type) || isObjectType11(type) || isInterfaceType12(type) ||
|
|
6945
|
+
return isScalarType12(type) || isObjectType11(type) || isInterfaceType12(type) || isUnionType13(type) || isEnumType9(type) || isWrappingType(type) && isOutputType(type.ofType);
|
|
6946
6946
|
}
|
|
6947
6947
|
function assertOutputType(type) {
|
|
6948
6948
|
if (!isOutputType(type)) {
|
|
@@ -6960,7 +6960,7 @@ var require_definition = __commonJS({
|
|
|
6960
6960
|
return type;
|
|
6961
6961
|
}
|
|
6962
6962
|
function isCompositeType(type) {
|
|
6963
|
-
return isObjectType11(type) || isInterfaceType12(type) ||
|
|
6963
|
+
return isObjectType11(type) || isInterfaceType12(type) || isUnionType13(type);
|
|
6964
6964
|
}
|
|
6965
6965
|
function assertCompositeType(type) {
|
|
6966
6966
|
if (!isCompositeType(type)) {
|
|
@@ -6968,11 +6968,11 @@ var require_definition = __commonJS({
|
|
|
6968
6968
|
}
|
|
6969
6969
|
return type;
|
|
6970
6970
|
}
|
|
6971
|
-
function
|
|
6972
|
-
return isInterfaceType12(type) ||
|
|
6971
|
+
function isAbstractType2(type) {
|
|
6972
|
+
return isInterfaceType12(type) || isUnionType13(type);
|
|
6973
6973
|
}
|
|
6974
6974
|
function assertAbstractType(type) {
|
|
6975
|
-
if (!
|
|
6975
|
+
if (!isAbstractType2(type)) {
|
|
6976
6976
|
throw new Error("Expected ".concat((0, _inspect.default)(type), " to be a GraphQL abstract type."));
|
|
6977
6977
|
}
|
|
6978
6978
|
return type;
|
|
@@ -7039,7 +7039,7 @@ var require_definition = __commonJS({
|
|
|
7039
7039
|
}
|
|
7040
7040
|
}
|
|
7041
7041
|
function isNamedType4(type) {
|
|
7042
|
-
return isScalarType12(type) || isObjectType11(type) || isInterfaceType12(type) ||
|
|
7042
|
+
return isScalarType12(type) || isObjectType11(type) || isInterfaceType12(type) || isUnionType13(type) || isEnumType9(type) || isInputObjectType7(type);
|
|
7043
7043
|
}
|
|
7044
7044
|
function assertNamedType(type) {
|
|
7045
7045
|
if (!isNamedType4(type)) {
|
|
@@ -63884,6 +63884,20 @@ function deepEquals(objA, objB, map = /* @__PURE__ */ new WeakMap()) {
|
|
|
63884
63884
|
return true;
|
|
63885
63885
|
}
|
|
63886
63886
|
|
|
63887
|
+
// src/runtime/lib/selection.ts
|
|
63888
|
+
function getFieldsForType(selection2, __typename) {
|
|
63889
|
+
let targetSelection = selection2.fields || {};
|
|
63890
|
+
if (selection2.abstractFields && __typename) {
|
|
63891
|
+
const mappedType = selection2.abstractFields.typeMap[__typename];
|
|
63892
|
+
if (mappedType) {
|
|
63893
|
+
targetSelection = selection2.abstractFields.fields[mappedType];
|
|
63894
|
+
} else if (selection2.abstractFields.fields[__typename]) {
|
|
63895
|
+
targetSelection = selection2.abstractFields.fields[__typename];
|
|
63896
|
+
}
|
|
63897
|
+
}
|
|
63898
|
+
return targetSelection;
|
|
63899
|
+
}
|
|
63900
|
+
|
|
63887
63901
|
// src/runtime/cache/gc.ts
|
|
63888
63902
|
var GarbageCollector = class {
|
|
63889
63903
|
cache;
|
|
@@ -64106,23 +64120,32 @@ var List = class {
|
|
|
64106
64120
|
let insertData = data;
|
|
64107
64121
|
if (this.connection) {
|
|
64108
64122
|
insertSelection = {
|
|
64109
|
-
|
|
64110
|
-
|
|
64111
|
-
|
|
64112
|
-
|
|
64113
|
-
|
|
64114
|
-
keyRaw: "edges",
|
|
64115
|
-
type: "ConnectionEdge",
|
|
64116
|
-
update: where === "first" ? "prepend" : "append",
|
|
64123
|
+
fields: {
|
|
64124
|
+
newEntry: {
|
|
64125
|
+
keyRaw: this.key,
|
|
64126
|
+
type: "Connection",
|
|
64127
|
+
selection: {
|
|
64117
64128
|
fields: {
|
|
64118
|
-
|
|
64119
|
-
|
|
64120
|
-
|
|
64121
|
-
|
|
64122
|
-
|
|
64123
|
-
|
|
64124
|
-
|
|
64125
|
-
|
|
64129
|
+
edges: {
|
|
64130
|
+
keyRaw: "edges",
|
|
64131
|
+
type: "ConnectionEdge",
|
|
64132
|
+
update: where === "first" ? "prepend" : "append",
|
|
64133
|
+
selection: {
|
|
64134
|
+
fields: {
|
|
64135
|
+
node: {
|
|
64136
|
+
type: listType,
|
|
64137
|
+
keyRaw: "node",
|
|
64138
|
+
selection: {
|
|
64139
|
+
...selection2,
|
|
64140
|
+
fields: {
|
|
64141
|
+
...selection2.fields,
|
|
64142
|
+
__typename: {
|
|
64143
|
+
keyRaw: "__typename",
|
|
64144
|
+
type: "String"
|
|
64145
|
+
}
|
|
64146
|
+
}
|
|
64147
|
+
}
|
|
64148
|
+
}
|
|
64126
64149
|
}
|
|
64127
64150
|
}
|
|
64128
64151
|
}
|
|
@@ -64138,15 +64161,20 @@ var List = class {
|
|
|
64138
64161
|
};
|
|
64139
64162
|
} else {
|
|
64140
64163
|
insertSelection = {
|
|
64141
|
-
|
|
64142
|
-
|
|
64143
|
-
|
|
64144
|
-
|
|
64145
|
-
|
|
64146
|
-
|
|
64147
|
-
|
|
64148
|
-
|
|
64149
|
-
|
|
64164
|
+
fields: {
|
|
64165
|
+
newEntries: {
|
|
64166
|
+
keyRaw: this.key,
|
|
64167
|
+
type: listType,
|
|
64168
|
+
update: where === "first" ? "prepend" : "append",
|
|
64169
|
+
selection: {
|
|
64170
|
+
...selection2,
|
|
64171
|
+
fields: {
|
|
64172
|
+
...selection2.fields,
|
|
64173
|
+
__typename: {
|
|
64174
|
+
keyRaw: "__typename",
|
|
64175
|
+
type: "String"
|
|
64176
|
+
}
|
|
64177
|
+
}
|
|
64150
64178
|
}
|
|
64151
64179
|
}
|
|
64152
64180
|
}
|
|
@@ -64206,7 +64234,7 @@ var List = class {
|
|
|
64206
64234
|
const subscribers = this.cache._internal_unstable.subscriptions.get(this.recordID, this.key);
|
|
64207
64235
|
this.cache._internal_unstable.subscriptions.remove(
|
|
64208
64236
|
targetID,
|
|
64209
|
-
this.connection ? this.selection.edges.
|
|
64237
|
+
this.connection ? this.selection.fields.edges.selection : this.selection,
|
|
64210
64238
|
subscribers,
|
|
64211
64239
|
variables
|
|
64212
64240
|
);
|
|
@@ -64695,18 +64723,20 @@ var InMemorySubscriptions = class {
|
|
|
64695
64723
|
variables,
|
|
64696
64724
|
parentType
|
|
64697
64725
|
}) {
|
|
64698
|
-
|
|
64699
|
-
|
|
64726
|
+
const __typename = this.cache._internal_unstable.storage.get(parent, "__typename").value;
|
|
64727
|
+
let targetSelection = getFieldsForType(selection2, __typename);
|
|
64728
|
+
for (const fieldSelection of Object.values(targetSelection || {})) {
|
|
64729
|
+
const { keyRaw, selection: innerSelection, type } = fieldSelection;
|
|
64700
64730
|
const key = evaluateKey(keyRaw, variables);
|
|
64701
64731
|
this.addFieldSubscription({
|
|
64702
64732
|
id: parent,
|
|
64703
64733
|
key,
|
|
64704
|
-
|
|
64734
|
+
field: fieldSelection,
|
|
64705
64735
|
spec,
|
|
64706
64736
|
parentType: parentType || spec.rootType,
|
|
64707
64737
|
variables
|
|
64708
64738
|
});
|
|
64709
|
-
if (
|
|
64739
|
+
if (innerSelection) {
|
|
64710
64740
|
const { value: linkedRecord } = this.cache._internal_unstable.storage.get(
|
|
64711
64741
|
parent,
|
|
64712
64742
|
key
|
|
@@ -64719,7 +64749,7 @@ var InMemorySubscriptions = class {
|
|
|
64719
64749
|
this.add({
|
|
64720
64750
|
parent: child,
|
|
64721
64751
|
spec,
|
|
64722
|
-
selection:
|
|
64752
|
+
selection: innerSelection,
|
|
64723
64753
|
variables,
|
|
64724
64754
|
parentType: type
|
|
64725
64755
|
});
|
|
@@ -64730,7 +64760,7 @@ var InMemorySubscriptions = class {
|
|
|
64730
64760
|
addFieldSubscription({
|
|
64731
64761
|
id,
|
|
64732
64762
|
key,
|
|
64733
|
-
|
|
64763
|
+
field,
|
|
64734
64764
|
spec,
|
|
64735
64765
|
parentType,
|
|
64736
64766
|
variables
|
|
@@ -64757,8 +64787,8 @@ var InMemorySubscriptions = class {
|
|
|
64757
64787
|
const counts = this.referenceCounts[id][key];
|
|
64758
64788
|
counts.set(spec.set, (counts.get(spec.set) || 0) + 1);
|
|
64759
64789
|
this.cache._internal_unstable.lifetimes.resetLifetime(id, key);
|
|
64760
|
-
const {
|
|
64761
|
-
if (
|
|
64790
|
+
const { selection: selection2, list, filters } = field;
|
|
64791
|
+
if (selection2 && list) {
|
|
64762
64792
|
this.cache._internal_unstable.lists.add({
|
|
64763
64793
|
name: list.name,
|
|
64764
64794
|
connection: list.connection,
|
|
@@ -64766,7 +64796,7 @@ var InMemorySubscriptions = class {
|
|
|
64766
64796
|
recordType: this.cache._internal_unstable.storage.get(id, "__typename")?.value || parentType,
|
|
64767
64797
|
listType: list.type,
|
|
64768
64798
|
key,
|
|
64769
|
-
selection:
|
|
64799
|
+
selection: selection2,
|
|
64770
64800
|
filters: Object.entries(filters || {}).reduce((acc, [key2, { kind, value }]) => {
|
|
64771
64801
|
return {
|
|
64772
64802
|
...acc,
|
|
@@ -64783,20 +64813,21 @@ var InMemorySubscriptions = class {
|
|
|
64783
64813
|
subscribers,
|
|
64784
64814
|
parentType
|
|
64785
64815
|
}) {
|
|
64786
|
-
|
|
64787
|
-
|
|
64816
|
+
let targetSelection = getFieldsForType(selection2, parentType);
|
|
64817
|
+
for (const fieldSelection of Object.values(targetSelection)) {
|
|
64818
|
+
const { type: linkedType, keyRaw, selection: innerSelection } = fieldSelection;
|
|
64788
64819
|
const key = evaluateKey(keyRaw, variables);
|
|
64789
64820
|
for (const spec of subscribers) {
|
|
64790
64821
|
this.addFieldSubscription({
|
|
64791
64822
|
id: parent,
|
|
64792
64823
|
key,
|
|
64793
|
-
|
|
64824
|
+
field: fieldSelection,
|
|
64794
64825
|
spec,
|
|
64795
64826
|
parentType,
|
|
64796
64827
|
variables
|
|
64797
64828
|
});
|
|
64798
64829
|
}
|
|
64799
|
-
if (
|
|
64830
|
+
if (innerSelection) {
|
|
64800
64831
|
const { value: link } = this.cache._internal_unstable.storage.get(parent, key);
|
|
64801
64832
|
const children = !Array.isArray(link) ? [link] : flattenList(link);
|
|
64802
64833
|
for (const linkedRecord of children) {
|
|
@@ -64805,7 +64836,7 @@ var InMemorySubscriptions = class {
|
|
|
64805
64836
|
}
|
|
64806
64837
|
this.addMany({
|
|
64807
64838
|
parent: linkedRecord,
|
|
64808
|
-
selection:
|
|
64839
|
+
selection: innerSelection,
|
|
64809
64840
|
variables,
|
|
64810
64841
|
subscribers,
|
|
64811
64842
|
parentType: linkedType
|
|
@@ -64817,22 +64848,20 @@ var InMemorySubscriptions = class {
|
|
|
64817
64848
|
get(id, field) {
|
|
64818
64849
|
return this.subscribers[id]?.[field] || [];
|
|
64819
64850
|
}
|
|
64820
|
-
remove(id,
|
|
64851
|
+
remove(id, selection2, targets, variables, visited = []) {
|
|
64821
64852
|
visited.push(id);
|
|
64822
64853
|
const linkedIDs = [];
|
|
64823
|
-
for (const
|
|
64824
|
-
const key = evaluateKey(
|
|
64854
|
+
for (const fieldSelection of Object.values(selection2.fields || {})) {
|
|
64855
|
+
const key = evaluateKey(fieldSelection.keyRaw, variables);
|
|
64825
64856
|
this.removeSubscribers(id, key, targets);
|
|
64826
|
-
if (!
|
|
64857
|
+
if (!fieldSelection.selection?.fields) {
|
|
64827
64858
|
continue;
|
|
64828
64859
|
}
|
|
64829
|
-
if (selection2.list) {
|
|
64830
|
-
}
|
|
64831
64860
|
const { value: previousValue } = this.cache._internal_unstable.storage.get(id, key);
|
|
64832
64861
|
const links = !Array.isArray(previousValue) ? [previousValue] : flattenList(previousValue);
|
|
64833
64862
|
for (const link of links) {
|
|
64834
64863
|
if (link !== null) {
|
|
64835
|
-
linkedIDs.push([link,
|
|
64864
|
+
linkedIDs.push([link, fieldSelection.selection || {}]);
|
|
64836
64865
|
}
|
|
64837
64866
|
}
|
|
64838
64867
|
}
|
|
@@ -65010,8 +65039,9 @@ var CacheInternal = class {
|
|
|
65010
65039
|
if (this._disabled) {
|
|
65011
65040
|
return [];
|
|
65012
65041
|
}
|
|
65042
|
+
let targetSelection = getFieldsForType(selection2, data["__typename"]);
|
|
65013
65043
|
for (const [field, value] of Object.entries(data)) {
|
|
65014
|
-
if (!selection2 || !
|
|
65044
|
+
if (!selection2 || !targetSelection[field]) {
|
|
65015
65045
|
throw new Error(
|
|
65016
65046
|
"Could not find field listing in selection for " + field + " @ " + JSON.stringify(selection2)
|
|
65017
65047
|
);
|
|
@@ -65019,11 +65049,11 @@ var CacheInternal = class {
|
|
|
65019
65049
|
let {
|
|
65020
65050
|
type: linkedType,
|
|
65021
65051
|
keyRaw,
|
|
65022
|
-
|
|
65052
|
+
selection: fieldSelection,
|
|
65023
65053
|
operations,
|
|
65024
65054
|
abstract: isAbstract,
|
|
65025
65055
|
update
|
|
65026
|
-
} =
|
|
65056
|
+
} = targetSelection[field];
|
|
65027
65057
|
const key = evaluateKey(keyRaw, variables);
|
|
65028
65058
|
const currentSubscribers = this.subscriptions.get(parent, key);
|
|
65029
65059
|
const { value: previousValue, displayLayers } = this.storage.get(parent, key);
|
|
@@ -65031,7 +65061,7 @@ var CacheInternal = class {
|
|
|
65031
65061
|
if (displayLayer) {
|
|
65032
65062
|
this.lifetimes.resetLifetime(parent, key);
|
|
65033
65063
|
}
|
|
65034
|
-
if (!
|
|
65064
|
+
if (!fieldSelection) {
|
|
65035
65065
|
let newValue = value;
|
|
65036
65066
|
if (Array.isArray(value) && applyUpdates && update) {
|
|
65037
65067
|
if (update === "append") {
|
|
@@ -65051,7 +65081,7 @@ var CacheInternal = class {
|
|
|
65051
65081
|
}
|
|
65052
65082
|
const previousLinks = flattenList([previousValue]);
|
|
65053
65083
|
for (const link of previousLinks) {
|
|
65054
|
-
this.subscriptions.remove(link,
|
|
65084
|
+
this.subscriptions.remove(link, fieldSelection, currentSubscribers, variables);
|
|
65055
65085
|
}
|
|
65056
65086
|
layer.writeLink(parent, key, null);
|
|
65057
65087
|
toNotify.push(...currentSubscribers);
|
|
@@ -65077,14 +65107,14 @@ var CacheInternal = class {
|
|
|
65077
65107
|
if (previousValue && typeof previousValue === "string") {
|
|
65078
65108
|
this.subscriptions.remove(
|
|
65079
65109
|
previousValue,
|
|
65080
|
-
|
|
65110
|
+
fieldSelection,
|
|
65081
65111
|
currentSubscribers,
|
|
65082
65112
|
variables
|
|
65083
65113
|
);
|
|
65084
65114
|
}
|
|
65085
65115
|
this.subscriptions.addMany({
|
|
65086
65116
|
parent: linkedID,
|
|
65087
|
-
selection:
|
|
65117
|
+
selection: fieldSelection,
|
|
65088
65118
|
subscribers: currentSubscribers,
|
|
65089
65119
|
variables,
|
|
65090
65120
|
parentType: linkedType
|
|
@@ -65094,14 +65124,14 @@ var CacheInternal = class {
|
|
|
65094
65124
|
if (linkedID) {
|
|
65095
65125
|
this.writeSelection({
|
|
65096
65126
|
root,
|
|
65097
|
-
selection:
|
|
65127
|
+
selection: fieldSelection,
|
|
65098
65128
|
parent: linkedID,
|
|
65099
65129
|
data: value,
|
|
65100
65130
|
variables,
|
|
65101
65131
|
toNotify,
|
|
65102
65132
|
applyUpdates,
|
|
65103
65133
|
layer,
|
|
65104
|
-
forceNotify
|
|
65134
|
+
forceNotify
|
|
65105
65135
|
});
|
|
65106
65136
|
}
|
|
65107
65137
|
} else if (Array.isArray(value) && (typeof previousValue === "undefined" || Array.isArray(previousValue))) {
|
|
@@ -65130,7 +65160,7 @@ var CacheInternal = class {
|
|
|
65130
65160
|
key,
|
|
65131
65161
|
linkedType,
|
|
65132
65162
|
variables,
|
|
65133
|
-
fields,
|
|
65163
|
+
fields: fieldSelection,
|
|
65134
65164
|
layer,
|
|
65135
65165
|
forceNotify
|
|
65136
65166
|
});
|
|
@@ -65180,7 +65210,7 @@ var CacheInternal = class {
|
|
|
65180
65210
|
if (linkedIDs.includes(lostID) || !lostID) {
|
|
65181
65211
|
continue;
|
|
65182
65212
|
}
|
|
65183
|
-
this.subscriptions.remove(lostID,
|
|
65213
|
+
this.subscriptions.remove(lostID, fieldSelection, currentSubscribers, variables);
|
|
65184
65214
|
}
|
|
65185
65215
|
if (contentChanged || oldIDs.length === 0 && newIDs.length === 0) {
|
|
65186
65216
|
layer.writeLink(parent, key, linkedIDs);
|
|
@@ -65191,7 +65221,7 @@ var CacheInternal = class {
|
|
|
65191
65221
|
}
|
|
65192
65222
|
this.subscriptions.addMany({
|
|
65193
65223
|
parent: id,
|
|
65194
|
-
selection:
|
|
65224
|
+
selection: fieldSelection,
|
|
65195
65225
|
subscribers: currentSubscribers,
|
|
65196
65226
|
variables,
|
|
65197
65227
|
parentType: linkedType
|
|
@@ -65216,9 +65246,14 @@ var CacheInternal = class {
|
|
|
65216
65246
|
}
|
|
65217
65247
|
const targets = Array.isArray(value) ? value : [value];
|
|
65218
65248
|
for (const target of targets) {
|
|
65219
|
-
if (operation.action === "insert" && target instanceof Object &&
|
|
65220
|
-
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).addToList(
|
|
65221
|
-
|
|
65249
|
+
if (operation.action === "insert" && target instanceof Object && fieldSelection && operation.list) {
|
|
65250
|
+
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).addToList(
|
|
65251
|
+
fieldSelection,
|
|
65252
|
+
target,
|
|
65253
|
+
variables,
|
|
65254
|
+
operation.position || "last"
|
|
65255
|
+
);
|
|
65256
|
+
} else if (operation.action === "remove" && target instanceof Object && fieldSelection && operation.list) {
|
|
65222
65257
|
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables);
|
|
65223
65258
|
} else if (operation.action === "delete" && operation.type) {
|
|
65224
65259
|
if (typeof target !== "string") {
|
|
@@ -65229,8 +65264,13 @@ var CacheInternal = class {
|
|
|
65229
65264
|
continue;
|
|
65230
65265
|
}
|
|
65231
65266
|
this.cache.delete(targetID);
|
|
65232
|
-
} else if (operation.action === "toggle" && target instanceof Object &&
|
|
65233
|
-
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement(
|
|
65267
|
+
} else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
|
|
65268
|
+
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement(
|
|
65269
|
+
fieldSelection,
|
|
65270
|
+
target,
|
|
65271
|
+
variables,
|
|
65272
|
+
operation.position || "last"
|
|
65273
|
+
);
|
|
65234
65274
|
}
|
|
65235
65275
|
}
|
|
65236
65276
|
}
|
|
@@ -65250,9 +65290,12 @@ var CacheInternal = class {
|
|
|
65250
65290
|
let hasData = false;
|
|
65251
65291
|
let partial = false;
|
|
65252
65292
|
let cascadeNull = false;
|
|
65253
|
-
|
|
65254
|
-
|
|
65255
|
-
|
|
65293
|
+
const typename = this.storage.get(parent, "__typename").value;
|
|
65294
|
+
let targetSelection = getFieldsForType(selection2, typename);
|
|
65295
|
+
for (const [
|
|
65296
|
+
attributeName,
|
|
65297
|
+
{ type, keyRaw, selection: fieldSelection, nullable, list }
|
|
65298
|
+
] of Object.entries(targetSelection)) {
|
|
65256
65299
|
const key = evaluateKey(keyRaw, variables);
|
|
65257
65300
|
const { value } = this.storage.get(parent, key);
|
|
65258
65301
|
let nextStep = stepsFromConnection;
|
|
@@ -65275,7 +65318,7 @@ var CacheInternal = class {
|
|
|
65275
65318
|
if (typeof value !== "undefined") {
|
|
65276
65319
|
hasData = true;
|
|
65277
65320
|
}
|
|
65278
|
-
} else if (!
|
|
65321
|
+
} else if (!fieldSelection) {
|
|
65279
65322
|
const fnUnmarshal = this.config?.scalars?.[type]?.unmarshal;
|
|
65280
65323
|
if (fnUnmarshal) {
|
|
65281
65324
|
target[attributeName] = fnUnmarshal(value);
|
|
@@ -65285,7 +65328,7 @@ var CacheInternal = class {
|
|
|
65285
65328
|
hasData = true;
|
|
65286
65329
|
} else if (Array.isArray(value)) {
|
|
65287
65330
|
const listValue = this.hydrateNestedList({
|
|
65288
|
-
fields,
|
|
65331
|
+
fields: fieldSelection,
|
|
65289
65332
|
variables,
|
|
65290
65333
|
linkedList: value,
|
|
65291
65334
|
stepsFromConnection: nextStep
|
|
@@ -65300,7 +65343,7 @@ var CacheInternal = class {
|
|
|
65300
65343
|
} else {
|
|
65301
65344
|
const objectFields = this.getSelection({
|
|
65302
65345
|
parent: value,
|
|
65303
|
-
selection:
|
|
65346
|
+
selection: fieldSelection,
|
|
65304
65347
|
variables,
|
|
65305
65348
|
stepsFromConnection: nextStep
|
|
65306
65349
|
});
|
|
@@ -67033,7 +67076,7 @@ var Config = class {
|
|
|
67033
67076
|
typeConfig;
|
|
67034
67077
|
configFile;
|
|
67035
67078
|
logLevel;
|
|
67036
|
-
|
|
67079
|
+
defaultFragmentMasking = "enable";
|
|
67037
67080
|
configIsRoute = null;
|
|
67038
67081
|
routesDir;
|
|
67039
67082
|
schemaPollInterval;
|
|
@@ -67046,6 +67089,11 @@ var Config = class {
|
|
|
67046
67089
|
...configFile
|
|
67047
67090
|
}) {
|
|
67048
67091
|
this.configFile = defaultConfigValues(configFile);
|
|
67092
|
+
if (configFile.disableMasking !== void 0) {
|
|
67093
|
+
throw new HoudiniError({
|
|
67094
|
+
message: `"disableMasking" was replaced by "defaultFragmentMasking". Please update your config file.`
|
|
67095
|
+
});
|
|
67096
|
+
}
|
|
67049
67097
|
let {
|
|
67050
67098
|
schema,
|
|
67051
67099
|
schemaPath = "./schema.graphql",
|
|
@@ -67062,7 +67110,7 @@ var Config = class {
|
|
|
67062
67110
|
defaultKeys,
|
|
67063
67111
|
types: types15 = {},
|
|
67064
67112
|
logLevel,
|
|
67065
|
-
|
|
67113
|
+
defaultFragmentMasking = "enable",
|
|
67066
67114
|
schemaPollInterval = 2e3,
|
|
67067
67115
|
schemaPollHeaders = {},
|
|
67068
67116
|
projectDir
|
|
@@ -67081,7 +67129,11 @@ var Config = class {
|
|
|
67081
67129
|
logLevel = LogLevel.Summary;
|
|
67082
67130
|
}
|
|
67083
67131
|
this.schemaPath = schemaPath;
|
|
67084
|
-
|
|
67132
|
+
if (apiUrl && apiUrl.startsWith("env:")) {
|
|
67133
|
+
this.apiUrl = process.env[apiUrl.slice("env:".length)];
|
|
67134
|
+
} else {
|
|
67135
|
+
this.apiUrl = apiUrl;
|
|
67136
|
+
}
|
|
67085
67137
|
this.filepath = filepath;
|
|
67086
67138
|
this.exclude = Array.isArray(exclude) ? exclude : [exclude];
|
|
67087
67139
|
this.module = module;
|
|
@@ -67093,10 +67145,10 @@ var Config = class {
|
|
|
67093
67145
|
this.defaultCachePolicy = defaultCachePolicy;
|
|
67094
67146
|
this.defaultPartial = defaultPartial;
|
|
67095
67147
|
this.internalListPosition = defaultListPosition === "append" ? "last" : "first";
|
|
67096
|
-
this.defaultListTarget
|
|
67148
|
+
this.defaultListTarget = defaultListTarget;
|
|
67097
67149
|
this.definitionsFolder = definitionsPath;
|
|
67098
67150
|
this.logLevel = (logLevel || LogLevel.Summary).toLowerCase();
|
|
67099
|
-
this.
|
|
67151
|
+
this.defaultFragmentMasking = defaultFragmentMasking;
|
|
67100
67152
|
this.routesDir = join2(this.projectRoot, "src", "routes");
|
|
67101
67153
|
this.schemaPollInterval = schemaPollInterval;
|
|
67102
67154
|
this.schemaPollHeaders = schemaPollHeaders;
|
|
@@ -67290,8 +67342,14 @@ var Config = class {
|
|
|
67290
67342
|
pluginDirectory(name2) {
|
|
67291
67343
|
return houdini_mode.is_testing ? resolve("../../../", name2) : join2(this.rootDir, "plugins", name2);
|
|
67292
67344
|
}
|
|
67293
|
-
get
|
|
67294
|
-
return "
|
|
67345
|
+
get manualLoadDirective() {
|
|
67346
|
+
return "manual_load";
|
|
67347
|
+
}
|
|
67348
|
+
get maskEnableDirective() {
|
|
67349
|
+
return "mask_enable";
|
|
67350
|
+
}
|
|
67351
|
+
get maskDisableDirective() {
|
|
67352
|
+
return "mask_disable";
|
|
67295
67353
|
}
|
|
67296
67354
|
get listDirective() {
|
|
67297
67355
|
return "list";
|
|
@@ -67303,9 +67361,9 @@ var Config = class {
|
|
|
67303
67361
|
return "append";
|
|
67304
67362
|
}
|
|
67305
67363
|
get listParentDirective() {
|
|
67306
|
-
return
|
|
67364
|
+
return "parentID";
|
|
67307
67365
|
}
|
|
67308
|
-
get
|
|
67366
|
+
get deprecatedlistDirectiveParentIDArg() {
|
|
67309
67367
|
return "parentID";
|
|
67310
67368
|
}
|
|
67311
67369
|
get listAllListsDirective() {
|
|
@@ -67391,7 +67449,7 @@ var Config = class {
|
|
|
67391
67449
|
this.listDirective,
|
|
67392
67450
|
this.listPrependDirective,
|
|
67393
67451
|
this.listAppendDirective,
|
|
67394
|
-
this.
|
|
67452
|
+
this.listParentDirective,
|
|
67395
67453
|
this.listAllListsDirective,
|
|
67396
67454
|
this.whenDirective,
|
|
67397
67455
|
this.whenNotDirective,
|
|
@@ -67399,7 +67457,9 @@ var Config = class {
|
|
|
67399
67457
|
this.withDirective,
|
|
67400
67458
|
this.paginateDirective,
|
|
67401
67459
|
this.cacheDirective,
|
|
67402
|
-
this.
|
|
67460
|
+
this.manualLoadDirective,
|
|
67461
|
+
this.maskEnableDirective,
|
|
67462
|
+
this.maskDisableDirective
|
|
67403
67463
|
].includes(name2.value) || this.isDeleteDirective(name2.value);
|
|
67404
67464
|
}
|
|
67405
67465
|
isListFragment(name2) {
|
|
@@ -67963,13 +68023,17 @@ function flattenSelections({
|
|
|
67963
68023
|
config: config3,
|
|
67964
68024
|
filepath,
|
|
67965
68025
|
selections,
|
|
67966
|
-
fragmentDefinitions
|
|
68026
|
+
fragmentDefinitions,
|
|
68027
|
+
applyFragments,
|
|
68028
|
+
ignoreMaskDisable
|
|
67967
68029
|
}) {
|
|
67968
68030
|
const fields = new FieldCollection({
|
|
67969
68031
|
config: config3,
|
|
67970
68032
|
filepath,
|
|
67971
68033
|
selections,
|
|
67972
|
-
fragmentDefinitions
|
|
68034
|
+
fragmentDefinitions,
|
|
68035
|
+
applyFragments,
|
|
68036
|
+
ignoreMaskDisable: !!ignoreMaskDisable
|
|
67973
68037
|
});
|
|
67974
68038
|
return fields.toSelectionSet();
|
|
67975
68039
|
}
|
|
@@ -67980,9 +68044,13 @@ var FieldCollection = class {
|
|
|
67980
68044
|
fields;
|
|
67981
68045
|
inlineFragments;
|
|
67982
68046
|
fragmentSpreads;
|
|
68047
|
+
applyFragments;
|
|
68048
|
+
ignoreMaskDisable;
|
|
67983
68049
|
constructor(args) {
|
|
67984
68050
|
this.config = args.config;
|
|
67985
68051
|
this.fragmentDefinitions = args.fragmentDefinitions;
|
|
68052
|
+
this.applyFragments = args.applyFragments;
|
|
68053
|
+
this.ignoreMaskDisable = args.ignoreMaskDisable;
|
|
67986
68054
|
this.fields = {};
|
|
67987
68055
|
this.inlineFragments = {};
|
|
67988
68056
|
this.fragmentSpreads = {};
|
|
@@ -68011,31 +68079,28 @@ var FieldCollection = class {
|
|
|
68011
68079
|
}
|
|
68012
68080
|
}
|
|
68013
68081
|
if (selection2.kind === "InlineFragment" && selection2.typeCondition) {
|
|
68014
|
-
|
|
68015
|
-
if (!this.inlineFragments[key]) {
|
|
68016
|
-
this.inlineFragments[key] = {
|
|
68017
|
-
astNode: selection2,
|
|
68018
|
-
selection: this.empty()
|
|
68019
|
-
};
|
|
68020
|
-
}
|
|
68021
|
-
for (const subselect of selection2.selectionSet?.selections || []) {
|
|
68022
|
-
this.inlineFragments[key].selection.add(subselect);
|
|
68023
|
-
}
|
|
68082
|
+
this.walkInlineFragment(selection2);
|
|
68024
68083
|
return;
|
|
68025
68084
|
}
|
|
68026
68085
|
if (selection2.kind === "FragmentSpread") {
|
|
68027
68086
|
this.fragmentSpreads[selection2.name.value] = selection2;
|
|
68028
|
-
|
|
68029
|
-
|
|
68087
|
+
let includeFragments = this.config.defaultFragmentMasking === "disable";
|
|
68088
|
+
const maskEnableDirective = selection2.directives?.find(
|
|
68089
|
+
({ name: name2 }) => name2.value === this.config.maskEnableDirective
|
|
68030
68090
|
);
|
|
68031
|
-
|
|
68032
|
-
|
|
68091
|
+
if (maskEnableDirective) {
|
|
68092
|
+
includeFragments = false;
|
|
68093
|
+
}
|
|
68094
|
+
const maskDisableDirective = selection2.directives?.find(
|
|
68095
|
+
({ name: name2 }) => name2.value === this.config.maskDisableDirective
|
|
68033
68096
|
);
|
|
68034
|
-
|
|
68035
|
-
|
|
68036
|
-
includeFragments = !maskArgument.value.value;
|
|
68097
|
+
if (maskDisableDirective) {
|
|
68098
|
+
includeFragments = true;
|
|
68037
68099
|
}
|
|
68038
|
-
if (
|
|
68100
|
+
if (this.ignoreMaskDisable) {
|
|
68101
|
+
includeFragments = true;
|
|
68102
|
+
}
|
|
68103
|
+
if (!includeFragments || !this.applyFragments) {
|
|
68039
68104
|
return;
|
|
68040
68105
|
}
|
|
68041
68106
|
const definition = this.fragmentDefinitions[selection2.name.value];
|
|
@@ -68045,9 +68110,20 @@ var FieldCollection = class {
|
|
|
68045
68110
|
message: "Could not find referenced fragment definition: " + selection2.name.value
|
|
68046
68111
|
});
|
|
68047
68112
|
}
|
|
68048
|
-
|
|
68049
|
-
|
|
68050
|
-
|
|
68113
|
+
this.add({
|
|
68114
|
+
kind: "InlineFragment",
|
|
68115
|
+
typeCondition: {
|
|
68116
|
+
kind: "NamedType",
|
|
68117
|
+
name: {
|
|
68118
|
+
kind: "Name",
|
|
68119
|
+
value: definition.typeCondition.name.value
|
|
68120
|
+
}
|
|
68121
|
+
},
|
|
68122
|
+
selectionSet: {
|
|
68123
|
+
kind: "SelectionSet",
|
|
68124
|
+
selections: [...definition.selectionSet.selections]
|
|
68125
|
+
}
|
|
68126
|
+
});
|
|
68051
68127
|
}
|
|
68052
68128
|
}
|
|
68053
68129
|
toSelectionSet() {
|
|
@@ -68063,12 +68139,30 @@ var FieldCollection = class {
|
|
|
68063
68139
|
})
|
|
68064
68140
|
).concat(Object.values(this.fragmentSpreads));
|
|
68065
68141
|
}
|
|
68142
|
+
walkInlineFragment(selection2) {
|
|
68143
|
+
const key = selection2.typeCondition.name.value;
|
|
68144
|
+
if (!this.inlineFragments[key]) {
|
|
68145
|
+
this.inlineFragments[key] = {
|
|
68146
|
+
astNode: selection2,
|
|
68147
|
+
selection: this.empty()
|
|
68148
|
+
};
|
|
68149
|
+
}
|
|
68150
|
+
for (const subselect of selection2.selectionSet.selections || []) {
|
|
68151
|
+
if (subselect.kind !== "InlineFragment" || !subselect.typeCondition) {
|
|
68152
|
+
this.inlineFragments[key].selection.add(subselect);
|
|
68153
|
+
continue;
|
|
68154
|
+
}
|
|
68155
|
+
this.walkInlineFragment(subselect);
|
|
68156
|
+
}
|
|
68157
|
+
}
|
|
68066
68158
|
empty() {
|
|
68067
68159
|
return new FieldCollection({
|
|
68068
68160
|
config: this.config,
|
|
68069
68161
|
fragmentDefinitions: this.fragmentDefinitions,
|
|
68070
68162
|
selections: [],
|
|
68071
|
-
filepath: this.filepath
|
|
68163
|
+
filepath: this.filepath,
|
|
68164
|
+
applyFragments: this.applyFragments,
|
|
68165
|
+
ignoreMaskDisable: this.ignoreMaskDisable
|
|
68072
68166
|
});
|
|
68073
68167
|
}
|
|
68074
68168
|
};
|
|
@@ -68423,11 +68517,6 @@ function operationObject({
|
|
|
68423
68517
|
const when = internalDirectives.find(({ name: name2 }) => name2.value === "when");
|
|
68424
68518
|
const when_not = internalDirectives.find(({ name: name2 }) => name2.value === "when_not");
|
|
68425
68519
|
let parentIDArg = parent?.arguments?.find((argument) => argument.name.value === "value");
|
|
68426
|
-
if (!parentIDArg) {
|
|
68427
|
-
parentIDArg = (append || prepend)?.arguments?.find(
|
|
68428
|
-
({ name: name2 }) => name2.value === config3.listDirectiveParentIDArg
|
|
68429
|
-
);
|
|
68430
|
-
}
|
|
68431
68520
|
if (parentIDArg) {
|
|
68432
68521
|
if (parentIDArg.value.kind === "StringValue") {
|
|
68433
68522
|
parentID = parentIDArg.value.value;
|
|
@@ -69418,6 +69507,8 @@ function selection({
|
|
|
69418
69507
|
markEdges
|
|
69419
69508
|
}) {
|
|
69420
69509
|
let object = {};
|
|
69510
|
+
const typeMap = {};
|
|
69511
|
+
const abstractTypes = [];
|
|
69421
69512
|
for (const field of selections) {
|
|
69422
69513
|
if (field.kind === "FragmentSpread" && includeFragments) {
|
|
69423
69514
|
const fragmentDefinition = document.document.definitions.find(
|
|
@@ -69444,20 +69535,68 @@ function selection({
|
|
|
69444
69535
|
})
|
|
69445
69536
|
);
|
|
69446
69537
|
} else if (field.kind === "InlineFragment") {
|
|
69447
|
-
|
|
69448
|
-
|
|
69449
|
-
object,
|
|
69450
|
-
selection({
|
|
69451
|
-
config: config3,
|
|
69538
|
+
if (!field.typeCondition || field.typeCondition.name.value === rootType) {
|
|
69539
|
+
object.fields = deepMerge(
|
|
69452
69540
|
filepath,
|
|
69453
|
-
|
|
69454
|
-
|
|
69455
|
-
|
|
69456
|
-
|
|
69457
|
-
|
|
69458
|
-
|
|
69459
|
-
|
|
69460
|
-
|
|
69541
|
+
object.fields || {},
|
|
69542
|
+
selection({
|
|
69543
|
+
config: config3,
|
|
69544
|
+
filepath,
|
|
69545
|
+
rootType: field.typeCondition?.name.value || rootType,
|
|
69546
|
+
operations,
|
|
69547
|
+
selections: field.selectionSet.selections,
|
|
69548
|
+
path: path2,
|
|
69549
|
+
includeFragments,
|
|
69550
|
+
document
|
|
69551
|
+
}).fields || {}
|
|
69552
|
+
);
|
|
69553
|
+
} else {
|
|
69554
|
+
if (!object.abstractFields) {
|
|
69555
|
+
object.abstractFields = {
|
|
69556
|
+
fields: {},
|
|
69557
|
+
typeMap: {}
|
|
69558
|
+
};
|
|
69559
|
+
}
|
|
69560
|
+
const parentType = config3.schema.getType(rootType);
|
|
69561
|
+
const typeConditionName = field.typeCondition.name.value;
|
|
69562
|
+
const typeCondition = config3.schema.getType(typeConditionName);
|
|
69563
|
+
const possibleTypes = [];
|
|
69564
|
+
if (!graphql12.isAbstractType(typeCondition)) {
|
|
69565
|
+
} else if (graphql12.isAbstractType(parentType)) {
|
|
69566
|
+
const possibleParentTypes = config3.schema.getPossibleTypes(parentType).map((type) => type.name);
|
|
69567
|
+
for (const possible of config3.schema.getPossibleTypes(typeCondition)) {
|
|
69568
|
+
if (possibleParentTypes.includes(possible.name)) {
|
|
69569
|
+
possibleTypes.push(possible.name);
|
|
69570
|
+
}
|
|
69571
|
+
}
|
|
69572
|
+
} else {
|
|
69573
|
+
possibleTypes.push(rootType);
|
|
69574
|
+
}
|
|
69575
|
+
if (possibleTypes.length > 0) {
|
|
69576
|
+
for (const type of possibleTypes) {
|
|
69577
|
+
const existing = typeMap[type];
|
|
69578
|
+
if (!existing || !existing.includes(type)) {
|
|
69579
|
+
typeMap[type] = [typeConditionName].concat(existing || []);
|
|
69580
|
+
}
|
|
69581
|
+
if (!abstractTypes.includes(typeConditionName)) {
|
|
69582
|
+
abstractTypes.push(typeConditionName);
|
|
69583
|
+
}
|
|
69584
|
+
}
|
|
69585
|
+
}
|
|
69586
|
+
object.abstractFields.fields = {
|
|
69587
|
+
...object.abstractFields.fields,
|
|
69588
|
+
[field.typeCondition.name.value]: selection({
|
|
69589
|
+
config: config3,
|
|
69590
|
+
filepath,
|
|
69591
|
+
rootType: field.typeCondition?.name.value || rootType,
|
|
69592
|
+
operations,
|
|
69593
|
+
selections: field.selectionSet.selections,
|
|
69594
|
+
path: path2,
|
|
69595
|
+
includeFragments,
|
|
69596
|
+
document
|
|
69597
|
+
}).fields
|
|
69598
|
+
};
|
|
69599
|
+
}
|
|
69461
69600
|
} else if (field.kind === "Field") {
|
|
69462
69601
|
const type = config3.schema.getType(rootType);
|
|
69463
69602
|
if (!type) {
|
|
@@ -69515,7 +69654,7 @@ function selection({
|
|
|
69515
69654
|
}
|
|
69516
69655
|
if (field.selectionSet) {
|
|
69517
69656
|
const edgesMark = paginated && document.refetch?.method === "cursor" ? document.refetch.update : markEdges;
|
|
69518
|
-
fieldObj.
|
|
69657
|
+
fieldObj.selection = selection({
|
|
69519
69658
|
config: config3,
|
|
69520
69659
|
filepath,
|
|
69521
69660
|
rootType: typeName,
|
|
@@ -69539,11 +69678,49 @@ function selection({
|
|
|
69539
69678
|
if (graphql12.isInterfaceType(fieldType) || graphql12.isUnionType(fieldType)) {
|
|
69540
69679
|
fieldObj.abstract = true;
|
|
69541
69680
|
}
|
|
69542
|
-
object
|
|
69543
|
-
|
|
69544
|
-
fieldObj
|
|
69545
|
-
|
|
69546
|
-
|
|
69681
|
+
object.fields = {
|
|
69682
|
+
...object.fields,
|
|
69683
|
+
[attributeName]: fieldObj
|
|
69684
|
+
};
|
|
69685
|
+
}
|
|
69686
|
+
}
|
|
69687
|
+
if (Object.keys(object.fields || {}).length > 0 && object.abstractFields && Object.keys(object.abstractFields.fields).length > 0) {
|
|
69688
|
+
for (const [typeName, possibles] of Object.entries(typeMap)) {
|
|
69689
|
+
let overlap = false;
|
|
69690
|
+
for (const possible of possibles) {
|
|
69691
|
+
if (object.abstractFields.fields[typeName]) {
|
|
69692
|
+
object.abstractFields.fields[typeName] = deepMerge(
|
|
69693
|
+
filepath,
|
|
69694
|
+
object.abstractFields.fields[typeName] || {},
|
|
69695
|
+
object.abstractFields.fields[possible]
|
|
69696
|
+
);
|
|
69697
|
+
overlap = true;
|
|
69698
|
+
}
|
|
69699
|
+
}
|
|
69700
|
+
if (overlap) {
|
|
69701
|
+
delete typeMap[typeName];
|
|
69702
|
+
}
|
|
69703
|
+
}
|
|
69704
|
+
for (const [type, options] of Object.entries(typeMap)) {
|
|
69705
|
+
if (options.length > 1) {
|
|
69706
|
+
object.abstractFields.fields[type] = deepMerge(
|
|
69707
|
+
filepath,
|
|
69708
|
+
...options.map((opt) => object.abstractFields.fields[opt] || {})
|
|
69709
|
+
);
|
|
69710
|
+
delete typeMap[type];
|
|
69711
|
+
}
|
|
69712
|
+
}
|
|
69713
|
+
for (const [type, sel] of Object.entries(object.abstractFields?.fields || {})) {
|
|
69714
|
+
object.abstractFields.fields[type] = deepMerge(filepath, sel || {}, object.fields);
|
|
69715
|
+
}
|
|
69716
|
+
for (const [type, options] of Object.entries(typeMap)) {
|
|
69717
|
+
object.abstractFields.typeMap[type] = options[0];
|
|
69718
|
+
}
|
|
69719
|
+
const usedTypes = Object.values(object.abstractFields.typeMap);
|
|
69720
|
+
for (const type of abstractTypes) {
|
|
69721
|
+
if (!usedTypes.includes(type)) {
|
|
69722
|
+
delete object.abstractFields.fields[type];
|
|
69723
|
+
}
|
|
69547
69724
|
}
|
|
69548
69725
|
}
|
|
69549
69726
|
return object;
|
|
@@ -69678,6 +69855,22 @@ function artifactGenerator(stats) {
|
|
|
69678
69855
|
selectionSet = matchingFragment.selectionSet;
|
|
69679
69856
|
}
|
|
69680
69857
|
const inputs = operations[0]?.variableDefinitions;
|
|
69858
|
+
const mergedSelection = flattenSelections({
|
|
69859
|
+
config: config3,
|
|
69860
|
+
filepath: doc.filename,
|
|
69861
|
+
selections: selectionSet.selections,
|
|
69862
|
+
fragmentDefinitions: doc.document.definitions.filter(
|
|
69863
|
+
(definition) => definition.kind === "FragmentDefinition"
|
|
69864
|
+
).reduce(
|
|
69865
|
+
(prev, definition) => ({
|
|
69866
|
+
...prev,
|
|
69867
|
+
[definition.name.value]: definition
|
|
69868
|
+
}),
|
|
69869
|
+
{}
|
|
69870
|
+
),
|
|
69871
|
+
ignoreMaskDisable: docKind === "HoudiniQuery",
|
|
69872
|
+
applyFragments: docKind !== "HoudiniFragment"
|
|
69873
|
+
});
|
|
69681
69874
|
const artifact = {
|
|
69682
69875
|
name: name2,
|
|
69683
69876
|
kind: docKind,
|
|
@@ -69689,7 +69882,7 @@ function artifactGenerator(stats) {
|
|
|
69689
69882
|
config: config3,
|
|
69690
69883
|
filepath: doc.filename,
|
|
69691
69884
|
rootType,
|
|
69692
|
-
selections:
|
|
69885
|
+
selections: mergedSelection,
|
|
69693
69886
|
operations: operationsByPath(
|
|
69694
69887
|
config3,
|
|
69695
69888
|
doc.filename,
|
|
@@ -69985,6 +70178,17 @@ function inlineType({
|
|
|
69985
70178
|
continue;
|
|
69986
70179
|
}
|
|
69987
70180
|
const possibleParents = config3.schema.getPossibleTypes(type).map((t2) => t2.name);
|
|
70181
|
+
const freeSelections = [];
|
|
70182
|
+
const typeSpecificSelections = {};
|
|
70183
|
+
for (const node of selection2.selectionSet.selections) {
|
|
70184
|
+
if (node.kind !== "InlineFragment") {
|
|
70185
|
+
freeSelections.push(node);
|
|
70186
|
+
} else if (node.typeCondition) {
|
|
70187
|
+
typeSpecificSelections[node.typeCondition.name.value] = node.selectionSet.selections;
|
|
70188
|
+
} else {
|
|
70189
|
+
freeSelections.push(...node.selectionSet.selections);
|
|
70190
|
+
}
|
|
70191
|
+
}
|
|
69988
70192
|
for (const possibleType of config3.schema.getPossibleTypes(fragmentType)) {
|
|
69989
70193
|
if (!possibleParents.includes(possibleType.name)) {
|
|
69990
70194
|
continue;
|
|
@@ -69992,7 +70196,12 @@ function inlineType({
|
|
|
69992
70196
|
if (!inlineFragments[possibleType.name]) {
|
|
69993
70197
|
inlineFragments[possibleType.name] = [];
|
|
69994
70198
|
}
|
|
69995
|
-
inlineFragments[possibleType.name].push(...
|
|
70199
|
+
inlineFragments[possibleType.name].push(...freeSelections);
|
|
70200
|
+
if (typeSpecificSelections[possibleType.name]) {
|
|
70201
|
+
inlineFragments[possibleType.name].push(
|
|
70202
|
+
...typeSpecificSelections[possibleType.name]
|
|
70203
|
+
);
|
|
70204
|
+
}
|
|
69996
70205
|
}
|
|
69997
70206
|
} else if (selection2.kind === "InlineFragment" && !selection2.typeCondition) {
|
|
69998
70207
|
selectedFields.push(...selection2.selectionSet.selections);
|
|
@@ -70004,12 +70213,7 @@ function inlineType({
|
|
|
70004
70213
|
...(selectedFields || []).filter(
|
|
70005
70214
|
(field) => field.kind === "Field"
|
|
70006
70215
|
).map((selection2) => {
|
|
70007
|
-
const {
|
|
70008
|
-
config3.schema,
|
|
70009
|
-
filepath,
|
|
70010
|
-
rootObj,
|
|
70011
|
-
selection2
|
|
70012
|
-
);
|
|
70216
|
+
const { field } = selectionTypeInfo(config3.schema, filepath, rootObj, selection2);
|
|
70013
70217
|
const attributeName = selection2.alias?.value || selection2.name.value;
|
|
70014
70218
|
let attributeType = inlineType({
|
|
70015
70219
|
config: config3,
|
|
@@ -70208,7 +70412,8 @@ async function typescriptGenerator(config3, docs) {
|
|
|
70208
70412
|
config: config3,
|
|
70209
70413
|
filepath: filename,
|
|
70210
70414
|
selections: definition.selectionSet.selections,
|
|
70211
|
-
fragmentDefinitions
|
|
70415
|
+
fragmentDefinitions,
|
|
70416
|
+
applyFragments: definition.kind === "OperationDefinition"
|
|
70212
70417
|
});
|
|
70213
70418
|
if (definition?.kind === "OperationDefinition") {
|
|
70214
70419
|
await generateOperationTypeDefs(
|
|
@@ -70721,14 +70926,12 @@ directive @${config3.paginateDirective}(${config3.paginateNameArg}: String) on F
|
|
|
70721
70926
|
"""
|
|
70722
70927
|
@${config3.listPrependDirective} is used to tell the runtime to add the result to the end of the list
|
|
70723
70928
|
"""
|
|
70724
|
-
directive @${config3.listPrependDirective}
|
|
70725
|
-
${config3.listDirectiveParentIDArg}: ID
|
|
70726
|
-
) on FRAGMENT_SPREAD
|
|
70929
|
+
directive @${config3.listPrependDirective} on FRAGMENT_SPREAD
|
|
70727
70930
|
|
|
70728
70931
|
"""
|
|
70729
70932
|
@${config3.listAppendDirective} is used to tell the runtime to add the result to the start of the list
|
|
70730
70933
|
"""
|
|
70731
|
-
directive @${config3.listAppendDirective}
|
|
70934
|
+
directive @${config3.listAppendDirective} on FRAGMENT_SPREAD
|
|
70732
70935
|
|
|
70733
70936
|
"""
|
|
70734
70937
|
@${config3.listAllListsDirective} is used to tell the runtime to add the result to all list
|
|
@@ -70762,18 +70965,19 @@ directive @${config3.argumentsDirective} on FRAGMENT_DEFINITION
|
|
|
70762
70965
|
directive @${config3.cacheDirective}(${config3.cachePolicyArg}: CachePolicy, ${config3.cachePartialArg}: Boolean) on QUERY
|
|
70763
70966
|
|
|
70764
70967
|
"""
|
|
70765
|
-
@${config3.
|
|
70968
|
+
@${config3.manualLoadDirective} is used to disable automatic fetch (no load, no auto fetch in component), you will have to do it manually.
|
|
70969
|
+
"""
|
|
70970
|
+
directive @${config3.manualLoadDirective} on QUERY
|
|
70971
|
+
|
|
70972
|
+
"""
|
|
70973
|
+
@${config3.maskEnableDirective} to enable masking on fragment (overwriting the global conf)
|
|
70974
|
+
"""
|
|
70975
|
+
directive @${config3.maskEnableDirective} on FRAGMENT_SPREAD
|
|
70976
|
+
|
|
70977
|
+
"""
|
|
70978
|
+
@${config3.maskDisableDirective} to disable masking on fragment (overwriting the global conf)
|
|
70766
70979
|
"""
|
|
70767
|
-
directive @${config3.
|
|
70768
|
-
"""
|
|
70769
|
-
Opt-in to an automatic load function (only valid when used at queries)
|
|
70770
|
-
"""
|
|
70771
|
-
load: Boolean! = true
|
|
70772
|
-
"""
|
|
70773
|
-
Mask fragment fields (only valid when used at a fragment spread)
|
|
70774
|
-
"""
|
|
70775
|
-
mask: Boolean! = ${config3.disableMasking ? "false" : "true"}
|
|
70776
|
-
) on QUERY | FRAGMENT_SPREAD
|
|
70980
|
+
directive @${config3.maskDisableDirective} on FRAGMENT_SPREAD
|
|
70777
70981
|
`;
|
|
70778
70982
|
let currentSchema = graphql21.printSchema(config3.schema);
|
|
70779
70983
|
if (!currentSchema.includes(`directive @${config3.listDirective}`)) {
|
|
@@ -71266,26 +71470,42 @@ async function typeCheck(config3, docs) {
|
|
|
71266
71470
|
),
|
|
71267
71471
|
targetField.selectionSet
|
|
71268
71472
|
);
|
|
71269
|
-
|
|
71270
|
-
if (
|
|
71271
|
-
|
|
71272
|
-
|
|
71273
|
-
|
|
71274
|
-
|
|
71275
|
-
|
|
71276
|
-
|
|
71277
|
-
|
|
71278
|
-
|
|
71279
|
-
|
|
71280
|
-
|
|
71281
|
-
|
|
71282
|
-
|
|
71283
|
-
|
|
71284
|
-
|
|
71285
|
-
|
|
71286
|
-
)
|
|
71473
|
+
let targetTypes = [type];
|
|
71474
|
+
if (graphql25.isUnionType(type)) {
|
|
71475
|
+
targetTypes = config3.schema.getPossibleTypes(type);
|
|
71476
|
+
} else if (graphql25.isInterfaceType(type)) {
|
|
71477
|
+
try {
|
|
71478
|
+
for (const key of config3.keyFieldsForType(type.name)) {
|
|
71479
|
+
if (!type.getFields()[key]) {
|
|
71480
|
+
throw new Error("continue");
|
|
71481
|
+
}
|
|
71482
|
+
}
|
|
71483
|
+
} catch {
|
|
71484
|
+
targetTypes = config3.schema.getPossibleTypes(type);
|
|
71485
|
+
}
|
|
71486
|
+
}
|
|
71487
|
+
for (const targetType of targetTypes) {
|
|
71488
|
+
const missingIDFields = config3.keyFieldsForType(targetType.name).filter((fieldName) => !targetType.getFields()[fieldName]);
|
|
71489
|
+
if (missingIDFields.length > 0) {
|
|
71490
|
+
if (error) {
|
|
71491
|
+
errors.push(
|
|
71492
|
+
new HoudiniError({
|
|
71493
|
+
filepath: filename,
|
|
71494
|
+
message: error
|
|
71495
|
+
})
|
|
71496
|
+
);
|
|
71497
|
+
} else {
|
|
71498
|
+
errors.push(
|
|
71499
|
+
new HoudiniError({
|
|
71500
|
+
filepath: filename,
|
|
71501
|
+
message: `@${config3.listDirective} can only be applied to types with the necessary id fields: ${missingIDFields.join(
|
|
71502
|
+
", "
|
|
71503
|
+
)}.`
|
|
71504
|
+
})
|
|
71505
|
+
);
|
|
71506
|
+
}
|
|
71507
|
+
return;
|
|
71287
71508
|
}
|
|
71288
|
-
return;
|
|
71289
71509
|
}
|
|
71290
71510
|
lists.push(listName);
|
|
71291
71511
|
listTypes.push(type.name);
|
|
@@ -71315,6 +71535,7 @@ async function typeCheck(config3, docs) {
|
|
|
71315
71535
|
fragments
|
|
71316
71536
|
}),
|
|
71317
71537
|
checkMutationOperation(config3),
|
|
71538
|
+
checkMaskDirective(config3),
|
|
71318
71539
|
nodeDirectives(config3, [config3.paginateDirective]),
|
|
71319
71540
|
knownArguments(config3),
|
|
71320
71541
|
validateFragmentArguments(config3, filepath, fragments),
|
|
@@ -71379,10 +71600,14 @@ var validateLists = ({
|
|
|
71379
71600
|
]);
|
|
71380
71601
|
if (directive) {
|
|
71381
71602
|
let parentArg = directive.arguments?.find(
|
|
71382
|
-
(arg) => arg.name.value === config3.
|
|
71603
|
+
(arg) => arg.name.value === config3.deprecatedlistDirectiveParentIDArg
|
|
71383
71604
|
);
|
|
71384
71605
|
if (parentArg) {
|
|
71385
|
-
|
|
71606
|
+
ctx.reportError(
|
|
71607
|
+
new graphql25.GraphQLError(
|
|
71608
|
+
`@${config3.deprecatedlistDirectiveParentIDArg} should be defined only in it's own directive now`
|
|
71609
|
+
)
|
|
71610
|
+
);
|
|
71386
71611
|
}
|
|
71387
71612
|
}
|
|
71388
71613
|
if (parentIdFound) {
|
|
@@ -71778,6 +72003,28 @@ function checkMutationOperation(config3) {
|
|
|
71778
72003
|
};
|
|
71779
72004
|
};
|
|
71780
72005
|
}
|
|
72006
|
+
function checkMaskDirective(config3) {
|
|
72007
|
+
return function(ctx) {
|
|
72008
|
+
return {
|
|
72009
|
+
FragmentSpread(node, _, __, ___, ancestors) {
|
|
72010
|
+
const maskEnableDirective = node.directives?.find(
|
|
72011
|
+
(c) => c.name.value === config3.maskEnableDirective
|
|
72012
|
+
);
|
|
72013
|
+
const maskDisableDirective = node.directives?.find(
|
|
72014
|
+
(c) => c.name.value === config3.maskDisableDirective
|
|
72015
|
+
);
|
|
72016
|
+
if (maskEnableDirective && maskDisableDirective) {
|
|
72017
|
+
ctx.reportError(
|
|
72018
|
+
new graphql25.GraphQLError(
|
|
72019
|
+
`You can't apply both @${config3.maskEnableDirective} and @${config3.maskDisableDirective} at the same time`
|
|
72020
|
+
)
|
|
72021
|
+
);
|
|
72022
|
+
return;
|
|
72023
|
+
}
|
|
72024
|
+
}
|
|
72025
|
+
};
|
|
72026
|
+
};
|
|
72027
|
+
}
|
|
71781
72028
|
function getAndVerifyNodeInterface(config3) {
|
|
71782
72029
|
const { schema } = config3;
|
|
71783
72030
|
const nodeInterface = schema.getType("Node");
|
|
@@ -72075,12 +72322,7 @@ async function collectDocuments(config3) {
|
|
|
72075
72322
|
}
|
|
72076
72323
|
async function processJSFile(config3, contents) {
|
|
72077
72324
|
const documents = [];
|
|
72078
|
-
|
|
72079
|
-
var program = (await parseJS(contents)).script;
|
|
72080
|
-
} catch (e2) {
|
|
72081
|
-
console.log(contents);
|
|
72082
|
-
throw e2;
|
|
72083
|
-
}
|
|
72325
|
+
var program = (await parseJS(contents)).script;
|
|
72084
72326
|
await find_graphql(config3, program, {
|
|
72085
72327
|
tag({ tagContent }) {
|
|
72086
72328
|
documents.push(tagContent);
|
|
@@ -72292,8 +72534,11 @@ function HoudiniWatchSchemaPlugin(opts = {}) {
|
|
|
72292
72534
|
if (interval <= 0) {
|
|
72293
72535
|
return;
|
|
72294
72536
|
}
|
|
72295
|
-
|
|
72296
|
-
|
|
72537
|
+
async function sleepAndStartPullLoop(interval2) {
|
|
72538
|
+
await sleep(interval2);
|
|
72539
|
+
await pull(true);
|
|
72540
|
+
}
|
|
72541
|
+
sleepAndStartPullLoop(interval);
|
|
72297
72542
|
},
|
|
72298
72543
|
buildEnd() {
|
|
72299
72544
|
go = false;
|