houdini 1.0.11 → 1.1.1-next.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 +659 -330
- package/build/cmd-esm/index.js +659 -330
- package/build/codegen/generators/artifacts/selection.d.ts +5 -2
- package/build/codegen/generators/typescript/inlineType.d.ts +1 -1
- package/build/codegen/transforms/{composeQueries.d.ts → collectDefinitions.d.ts} +1 -1
- package/build/codegen/transforms/fragmentVariables.d.ts +2 -4
- package/build/codegen/transforms/index.d.ts +1 -1
- package/build/codegen/utils/flattenSelections.d.ts +2 -2
- package/build/codegen-cjs/index.js +604 -326
- package/build/codegen-esm/index.js +604 -326
- package/build/lib/config.d.ts +10 -1
- package/build/lib/deepMerge.d.ts +1 -1
- package/build/lib/types.d.ts +1 -0
- package/build/lib-cjs/index.js +261 -115
- package/build/lib-esm/index.js +260 -115
- package/build/runtime/cache/cache.d.ts +17 -6
- package/build/runtime/client/documentStore.d.ts +1 -0
- package/build/runtime/client/plugins/cache.d.ts +3 -2
- package/build/runtime/client/plugins/fragment.d.ts +2 -0
- package/build/runtime/client/plugins/index.d.ts +1 -0
- package/build/runtime/lib/scalars.d.ts +0 -1
- package/build/runtime/lib/types.d.ts +55 -7
- package/build/runtime-cjs/cache/cache.d.ts +17 -6
- package/build/runtime-cjs/cache/cache.js +89 -21
- package/build/runtime-cjs/cache/lists.js +2 -1
- package/build/runtime-cjs/cache/subscription.js +11 -2
- package/build/runtime-cjs/client/documentStore.d.ts +1 -0
- package/build/runtime-cjs/client/documentStore.js +5 -14
- package/build/runtime-cjs/client/index.js +2 -1
- package/build/runtime-cjs/client/plugins/cache.d.ts +3 -2
- package/build/runtime-cjs/client/plugins/cache.js +19 -3
- package/build/runtime-cjs/client/plugins/fetch.js +4 -1
- package/build/runtime-cjs/client/plugins/fragment.d.ts +2 -0
- package/build/runtime-cjs/client/plugins/fragment.js +76 -0
- package/build/runtime-cjs/client/plugins/index.d.ts +1 -0
- package/build/runtime-cjs/client/plugins/index.js +1 -0
- package/build/runtime-cjs/client/plugins/query.js +3 -5
- package/build/runtime-cjs/lib/scalars.d.ts +0 -1
- package/build/runtime-cjs/lib/scalars.js +2 -43
- package/build/runtime-cjs/lib/types.d.ts +55 -7
- package/build/runtime-cjs/lib/types.js +5 -2
- package/build/runtime-cjs/public/tests/test.js +4 -2
- package/build/runtime-esm/cache/cache.d.ts +17 -6
- package/build/runtime-esm/cache/cache.js +89 -22
- package/build/runtime-esm/cache/lists.js +2 -1
- package/build/runtime-esm/cache/subscription.js +11 -2
- package/build/runtime-esm/client/documentStore.d.ts +1 -0
- package/build/runtime-esm/client/documentStore.js +6 -15
- package/build/runtime-esm/client/index.js +3 -1
- package/build/runtime-esm/client/plugins/cache.d.ts +3 -2
- package/build/runtime-esm/client/plugins/cache.js +19 -3
- package/build/runtime-esm/client/plugins/fetch.js +5 -2
- package/build/runtime-esm/client/plugins/fragment.d.ts +2 -0
- package/build/runtime-esm/client/plugins/fragment.js +46 -0
- package/build/runtime-esm/client/plugins/index.d.ts +1 -0
- package/build/runtime-esm/client/plugins/index.js +1 -0
- package/build/runtime-esm/client/plugins/query.js +3 -5
- package/build/runtime-esm/lib/scalars.d.ts +0 -1
- package/build/runtime-esm/lib/scalars.js +1 -41
- package/build/runtime-esm/lib/types.d.ts +55 -7
- package/build/runtime-esm/lib/types.js +3 -1
- package/build/runtime-esm/public/tests/test.js +4 -2
- package/build/test-cjs/index.js +658 -329
- package/build/test-esm/index.js +658 -329
- package/build/vite-cjs/index.js +657 -328
- package/build/vite-esm/index.js +657 -328
- package/package.json +2 -2
package/build/lib-esm/index.js
CHANGED
|
@@ -6810,8 +6810,8 @@ var require_KnownFragmentNamesRule = __commonJS({
|
|
|
6810
6810
|
return {
|
|
6811
6811
|
FragmentSpread: function FragmentSpread(node) {
|
|
6812
6812
|
var fragmentName = node.name.value;
|
|
6813
|
-
var
|
|
6814
|
-
if (!
|
|
6813
|
+
var fragment2 = context.getFragment(fragmentName);
|
|
6814
|
+
if (!fragment2) {
|
|
6815
6815
|
context.reportError(new _GraphQLError.GraphQLError('Unknown fragment "'.concat(fragmentName, '".'), node.name));
|
|
6816
6816
|
}
|
|
6817
6817
|
}
|
|
@@ -6847,8 +6847,8 @@ var require_NoUnusedFragmentsRule = __commonJS({
|
|
|
6847
6847
|
for (var _i2 = 0; _i2 < operationDefs.length; _i2++) {
|
|
6848
6848
|
var operation = operationDefs[_i2];
|
|
6849
6849
|
for (var _i4 = 0, _context$getRecursive2 = context.getRecursivelyReferencedFragments(operation); _i4 < _context$getRecursive2.length; _i4++) {
|
|
6850
|
-
var
|
|
6851
|
-
fragmentNameUsed[
|
|
6850
|
+
var fragment2 = _context$getRecursive2[_i4];
|
|
6851
|
+
fragmentNameUsed[fragment2.name.value] = true;
|
|
6852
6852
|
}
|
|
6853
6853
|
}
|
|
6854
6854
|
for (var _i6 = 0; _i6 < fragmentDefs.length; _i6++) {
|
|
@@ -6938,13 +6938,13 @@ var require_NoFragmentCyclesRule = __commonJS({
|
|
|
6938
6938
|
return false;
|
|
6939
6939
|
}
|
|
6940
6940
|
};
|
|
6941
|
-
function detectCycleRecursive(
|
|
6942
|
-
if (visitedFrags[
|
|
6941
|
+
function detectCycleRecursive(fragment2) {
|
|
6942
|
+
if (visitedFrags[fragment2.name.value]) {
|
|
6943
6943
|
return;
|
|
6944
6944
|
}
|
|
6945
|
-
var fragmentName =
|
|
6945
|
+
var fragmentName = fragment2.name.value;
|
|
6946
6946
|
visitedFrags[fragmentName] = true;
|
|
6947
|
-
var spreadNodes = context.getFragmentSpreads(
|
|
6947
|
+
var spreadNodes = context.getFragmentSpreads(fragment2.selectionSet);
|
|
6948
6948
|
if (spreadNodes.length === 0) {
|
|
6949
6949
|
return;
|
|
6950
6950
|
}
|
|
@@ -7765,11 +7765,11 @@ var require_OverlappingFieldsCanBeMergedRule = __commonJS({
|
|
|
7765
7765
|
return conflicts;
|
|
7766
7766
|
}
|
|
7767
7767
|
function collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, fieldMap, fragmentName) {
|
|
7768
|
-
var
|
|
7769
|
-
if (!
|
|
7768
|
+
var fragment2 = context.getFragment(fragmentName);
|
|
7769
|
+
if (!fragment2) {
|
|
7770
7770
|
return;
|
|
7771
7771
|
}
|
|
7772
|
-
var _getReferencedFieldsA = getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames,
|
|
7772
|
+
var _getReferencedFieldsA = getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragment2), fieldMap2 = _getReferencedFieldsA[0], fragmentNames2 = _getReferencedFieldsA[1];
|
|
7773
7773
|
if (fieldMap === fieldMap2) {
|
|
7774
7774
|
return;
|
|
7775
7775
|
}
|
|
@@ -7940,13 +7940,13 @@ var require_OverlappingFieldsCanBeMergedRule = __commonJS({
|
|
|
7940
7940
|
}
|
|
7941
7941
|
return cached;
|
|
7942
7942
|
}
|
|
7943
|
-
function getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames,
|
|
7944
|
-
var cached = cachedFieldsAndFragmentNames.get(
|
|
7943
|
+
function getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragment2) {
|
|
7944
|
+
var cached = cachedFieldsAndFragmentNames.get(fragment2.selectionSet);
|
|
7945
7945
|
if (cached) {
|
|
7946
7946
|
return cached;
|
|
7947
7947
|
}
|
|
7948
|
-
var fragmentType = (0, _typeFromAST.typeFromAST)(context.getSchema(),
|
|
7949
|
-
return getFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragmentType,
|
|
7948
|
+
var fragmentType = (0, _typeFromAST.typeFromAST)(context.getSchema(), fragment2.typeCondition);
|
|
7949
|
+
return getFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragmentType, fragment2.selectionSet);
|
|
7950
7950
|
}
|
|
7951
7951
|
function _collectFieldsAndFragmentNames(context, parentType, selectionSet, nodeAndDefs, fragmentNames) {
|
|
7952
7952
|
for (var _i9 = 0, _selectionSet$selecti2 = selectionSet.selections; _i9 < _selectionSet$selecti2.length; _i9++) {
|
|
@@ -8532,10 +8532,10 @@ var require_ValidationContext = __commonJS({
|
|
|
8532
8532
|
var fragName = spread.name.value;
|
|
8533
8533
|
if (collectedNames[fragName] !== true) {
|
|
8534
8534
|
collectedNames[fragName] = true;
|
|
8535
|
-
var
|
|
8536
|
-
if (
|
|
8537
|
-
fragments.push(
|
|
8538
|
-
nodesToVisit.push(
|
|
8535
|
+
var fragment2 = this.getFragment(fragName);
|
|
8536
|
+
if (fragment2) {
|
|
8537
|
+
fragments.push(fragment2);
|
|
8538
|
+
nodesToVisit.push(fragment2.selectionSet);
|
|
8539
8539
|
}
|
|
8540
8540
|
}
|
|
8541
8541
|
}
|
|
@@ -9474,11 +9474,11 @@ var require_execute = __commonJS({
|
|
|
9474
9474
|
continue;
|
|
9475
9475
|
}
|
|
9476
9476
|
visitedFragmentNames[fragName] = true;
|
|
9477
|
-
var
|
|
9478
|
-
if (!
|
|
9477
|
+
var fragment2 = exeContext.fragments[fragName];
|
|
9478
|
+
if (!fragment2 || !doesFragmentConditionMatch(exeContext, fragment2, runtimeType)) {
|
|
9479
9479
|
continue;
|
|
9480
9480
|
}
|
|
9481
|
-
collectFields(exeContext, runtimeType,
|
|
9481
|
+
collectFields(exeContext, runtimeType, fragment2.selectionSet, fields, visitedFragmentNames);
|
|
9482
9482
|
break;
|
|
9483
9483
|
}
|
|
9484
9484
|
}
|
|
@@ -9496,8 +9496,8 @@ var require_execute = __commonJS({
|
|
|
9496
9496
|
}
|
|
9497
9497
|
return true;
|
|
9498
9498
|
}
|
|
9499
|
-
function doesFragmentConditionMatch(exeContext,
|
|
9500
|
-
var typeConditionNode =
|
|
9499
|
+
function doesFragmentConditionMatch(exeContext, fragment2, type) {
|
|
9500
|
+
var typeConditionNode = fragment2.typeCondition;
|
|
9501
9501
|
if (!typeConditionNode) {
|
|
9502
9502
|
return true;
|
|
9503
9503
|
}
|
|
@@ -61765,45 +61765,6 @@ function marshalInputs({
|
|
|
61765
61765
|
})
|
|
61766
61766
|
);
|
|
61767
61767
|
}
|
|
61768
|
-
function unmarshalSelection(config, selection, data) {
|
|
61769
|
-
if (data === null || typeof data === "undefined") {
|
|
61770
|
-
return data;
|
|
61771
|
-
}
|
|
61772
|
-
if (Array.isArray(data)) {
|
|
61773
|
-
return data.map((val) => unmarshalSelection(config, selection, val));
|
|
61774
|
-
}
|
|
61775
|
-
const targetSelection = getFieldsForType(selection, data["__typename"]);
|
|
61776
|
-
return Object.fromEntries(
|
|
61777
|
-
Object.entries(data).map(([fieldName, value]) => {
|
|
61778
|
-
const { type, selection: selection2 } = targetSelection[fieldName];
|
|
61779
|
-
if (!type) {
|
|
61780
|
-
return [fieldName, value];
|
|
61781
|
-
}
|
|
61782
|
-
if (selection2) {
|
|
61783
|
-
return [
|
|
61784
|
-
fieldName,
|
|
61785
|
-
unmarshalSelection(config, selection2, value)
|
|
61786
|
-
];
|
|
61787
|
-
}
|
|
61788
|
-
if (value === null) {
|
|
61789
|
-
return [fieldName, value];
|
|
61790
|
-
}
|
|
61791
|
-
if (config.scalars?.[type]?.marshal) {
|
|
61792
|
-
const unmarshalFn = config.scalars[type]?.unmarshal;
|
|
61793
|
-
if (!unmarshalFn) {
|
|
61794
|
-
throw new Error(
|
|
61795
|
-
`scalar type ${type} is missing an \`unmarshal\` function. see https://github.com/AlecAivazis/houdini#%EF%B8%8Fcustom-scalars`
|
|
61796
|
-
);
|
|
61797
|
-
}
|
|
61798
|
-
if (Array.isArray(value)) {
|
|
61799
|
-
return [fieldName, value.map(unmarshalFn)];
|
|
61800
|
-
}
|
|
61801
|
-
return [fieldName, unmarshalFn(value)];
|
|
61802
|
-
}
|
|
61803
|
-
return [fieldName, value];
|
|
61804
|
-
})
|
|
61805
|
-
);
|
|
61806
|
-
}
|
|
61807
61768
|
function isScalar(config, type) {
|
|
61808
61769
|
return ["String", "Boolean", "Float", "ID", "Int"].concat(Object.keys(config.scalars || {})).includes(type);
|
|
61809
61770
|
}
|
|
@@ -61839,6 +61800,7 @@ var DataSource = {
|
|
|
61839
61800
|
Network: "network",
|
|
61840
61801
|
Ssr: "ssr"
|
|
61841
61802
|
};
|
|
61803
|
+
var fragmentKey = " $fragments";
|
|
61842
61804
|
|
|
61843
61805
|
// src/runtime/lib/store.ts
|
|
61844
61806
|
var subscriber_queue = [];
|
|
@@ -63492,7 +63454,10 @@ function flatten(source) {
|
|
|
63492
63454
|
var fetch2 = (target) => {
|
|
63493
63455
|
return () => {
|
|
63494
63456
|
return {
|
|
63495
|
-
async network(ctx, { client: client2, resolve: resolve2, marshalVariables: marshalVariables2 }) {
|
|
63457
|
+
async network(ctx, { client: client2, initialValue, resolve: resolve2, marshalVariables: marshalVariables2 }) {
|
|
63458
|
+
if (ctx.artifact.kind === ArtifactKind.Fragment) {
|
|
63459
|
+
return resolve2(ctx, initialValue);
|
|
63460
|
+
}
|
|
63496
63461
|
const fetch3 = ctx.fetch ?? globalThis.fetch;
|
|
63497
63462
|
const fetchParams2 = {
|
|
63498
63463
|
text: ctx.text,
|
|
@@ -63948,7 +63913,8 @@ var List = class {
|
|
|
63948
63913
|
this.cache._internal_unstable.getSelection({
|
|
63949
63914
|
parent: spec.parentID || this.manager.rootID,
|
|
63950
63915
|
selection: spec.selection,
|
|
63951
|
-
variables: spec.variables?.() || {}
|
|
63916
|
+
variables: spec.variables?.() || {},
|
|
63917
|
+
ignoreMasking: false
|
|
63952
63918
|
}).data
|
|
63953
63919
|
);
|
|
63954
63920
|
}
|
|
@@ -64568,7 +64534,17 @@ var InMemorySubscriptions = class {
|
|
|
64568
64534
|
const __typename = this.cache._internal_unstable.storage.get(parent, "__typename").value;
|
|
64569
64535
|
let targetSelection = getFieldsForType(selection, __typename);
|
|
64570
64536
|
for (const fieldSelection of Object.values(targetSelection || {})) {
|
|
64571
|
-
const {
|
|
64537
|
+
const {
|
|
64538
|
+
keyRaw,
|
|
64539
|
+
selection: innerSelection,
|
|
64540
|
+
type,
|
|
64541
|
+
list,
|
|
64542
|
+
filters,
|
|
64543
|
+
visible
|
|
64544
|
+
} = fieldSelection;
|
|
64545
|
+
if (!visible) {
|
|
64546
|
+
continue;
|
|
64547
|
+
}
|
|
64572
64548
|
const key = evaluateKey(keyRaw, variables);
|
|
64573
64549
|
let targetSelection2;
|
|
64574
64550
|
if (innerSelection) {
|
|
@@ -64642,7 +64618,6 @@ var InMemorySubscriptions = class {
|
|
|
64642
64618
|
const counts = this.referenceCounts[id][key];
|
|
64643
64619
|
counts.set(spec.set, (counts.get(spec.set) || 0) + 1);
|
|
64644
64620
|
this.cache._internal_unstable.lifetimes.resetLifetime(id, key);
|
|
64645
|
-
const { selection: innerSelection } = selection[1]?.[key] ?? {};
|
|
64646
64621
|
}
|
|
64647
64622
|
registerList({
|
|
64648
64623
|
list,
|
|
@@ -64796,7 +64771,7 @@ var InMemorySubscriptions = class {
|
|
|
64796
64771
|
// src/runtime/cache/cache.ts
|
|
64797
64772
|
var Cache = class {
|
|
64798
64773
|
_internal_unstable;
|
|
64799
|
-
constructor(config) {
|
|
64774
|
+
constructor({ disabled, ...config } = {}) {
|
|
64800
64775
|
this._internal_unstable = new CacheInternal({
|
|
64801
64776
|
cache: this,
|
|
64802
64777
|
storage: new InMemoryStorage(),
|
|
@@ -64804,9 +64779,10 @@ var Cache = class {
|
|
|
64804
64779
|
lists: new ListManager(this, rootID),
|
|
64805
64780
|
lifetimes: new GarbageCollector(this),
|
|
64806
64781
|
staleManager: new StaleManager(this),
|
|
64807
|
-
schema: new SchemaManager(this)
|
|
64782
|
+
schema: new SchemaManager(this),
|
|
64783
|
+
disabled: disabled ?? typeof globalThis.window === "undefined"
|
|
64808
64784
|
});
|
|
64809
|
-
if (config) {
|
|
64785
|
+
if (Object.keys(config).length > 0) {
|
|
64810
64786
|
this.setConfig(defaultConfigValues(config));
|
|
64811
64787
|
}
|
|
64812
64788
|
}
|
|
@@ -64825,7 +64801,8 @@ var Cache = class {
|
|
|
64825
64801
|
this._internal_unstable.getSelection({
|
|
64826
64802
|
parent: spec.parentID || rootID,
|
|
64827
64803
|
selection: spec.selection,
|
|
64828
|
-
variables: spec.variables?.() || {}
|
|
64804
|
+
variables: spec.variables?.() || {},
|
|
64805
|
+
ignoreMasking: false
|
|
64829
64806
|
}).data
|
|
64830
64807
|
);
|
|
64831
64808
|
}
|
|
@@ -64900,16 +64877,13 @@ var Cache = class {
|
|
|
64900
64877
|
getFieldTime(id, field) {
|
|
64901
64878
|
return this._internal_unstable.staleManager.getFieldTime(id, field);
|
|
64902
64879
|
}
|
|
64880
|
+
config() {
|
|
64881
|
+
return this._internal_unstable.config;
|
|
64882
|
+
}
|
|
64903
64883
|
};
|
|
64904
64884
|
var CacheInternal = class {
|
|
64905
64885
|
_disabled = false;
|
|
64906
|
-
|
|
64907
|
-
plugins: {
|
|
64908
|
-
"houdini-svelte": {
|
|
64909
|
-
client: ""
|
|
64910
|
-
}
|
|
64911
|
-
}
|
|
64912
|
-
});
|
|
64886
|
+
_config;
|
|
64913
64887
|
storage;
|
|
64914
64888
|
subscriptions;
|
|
64915
64889
|
lists;
|
|
@@ -64924,7 +64898,9 @@ var CacheInternal = class {
|
|
|
64924
64898
|
cache,
|
|
64925
64899
|
lifetimes,
|
|
64926
64900
|
staleManager,
|
|
64927
|
-
schema
|
|
64901
|
+
schema,
|
|
64902
|
+
disabled,
|
|
64903
|
+
config
|
|
64928
64904
|
}) {
|
|
64929
64905
|
this.storage = storage;
|
|
64930
64906
|
this.subscriptions = subscriptions;
|
|
@@ -64933,7 +64909,8 @@ var CacheInternal = class {
|
|
|
64933
64909
|
this.lifetimes = lifetimes;
|
|
64934
64910
|
this.staleManager = staleManager;
|
|
64935
64911
|
this.schema = schema;
|
|
64936
|
-
this.
|
|
64912
|
+
this._config = config;
|
|
64913
|
+
this._disabled = disabled;
|
|
64937
64914
|
try {
|
|
64938
64915
|
if (process.env.HOUDINI_TEST === "true") {
|
|
64939
64916
|
this._disabled = false;
|
|
@@ -64941,8 +64918,11 @@ var CacheInternal = class {
|
|
|
64941
64918
|
} catch {
|
|
64942
64919
|
}
|
|
64943
64920
|
}
|
|
64921
|
+
get config() {
|
|
64922
|
+
return this._config ?? getCurrentConfig();
|
|
64923
|
+
}
|
|
64944
64924
|
setConfig(config) {
|
|
64945
|
-
this.
|
|
64925
|
+
this._config = config;
|
|
64946
64926
|
}
|
|
64947
64927
|
writeSelection({
|
|
64948
64928
|
data,
|
|
@@ -65219,12 +65199,24 @@ var CacheInternal = class {
|
|
|
65219
65199
|
selection,
|
|
65220
65200
|
parent = rootID,
|
|
65221
65201
|
variables,
|
|
65222
|
-
stepsFromConnection = null
|
|
65202
|
+
stepsFromConnection = null,
|
|
65203
|
+
ignoreMasking
|
|
65223
65204
|
}) {
|
|
65224
65205
|
if (parent === null) {
|
|
65225
65206
|
return { data: null, partial: false, stale: false, hasData: true };
|
|
65226
65207
|
}
|
|
65227
65208
|
const target = {};
|
|
65209
|
+
if (selection.fragments) {
|
|
65210
|
+
target[fragmentKey] = Object.fromEntries(
|
|
65211
|
+
Object.entries(selection.fragments).map(([key, value]) => [
|
|
65212
|
+
key,
|
|
65213
|
+
{
|
|
65214
|
+
parent,
|
|
65215
|
+
variables: evaluateFragmentVariables(value, variables ?? {})
|
|
65216
|
+
}
|
|
65217
|
+
])
|
|
65218
|
+
);
|
|
65219
|
+
}
|
|
65228
65220
|
let hasData = false;
|
|
65229
65221
|
let partial = false;
|
|
65230
65222
|
let cascadeNull = false;
|
|
@@ -65233,8 +65225,11 @@ var CacheInternal = class {
|
|
|
65233
65225
|
let targetSelection = getFieldsForType(selection, typename);
|
|
65234
65226
|
for (const [
|
|
65235
65227
|
attributeName,
|
|
65236
|
-
{ type, keyRaw, selection: fieldSelection, nullable, list }
|
|
65228
|
+
{ type, keyRaw, selection: fieldSelection, nullable, list, visible }
|
|
65237
65229
|
] of Object.entries(targetSelection)) {
|
|
65230
|
+
if (!visible && !ignoreMasking) {
|
|
65231
|
+
continue;
|
|
65232
|
+
}
|
|
65238
65233
|
const key = evaluateKey(keyRaw, variables);
|
|
65239
65234
|
const { value } = this.storage.get(parent, key);
|
|
65240
65235
|
const dt_field = this.staleManager.getFieldTime(parent, key);
|
|
@@ -65274,7 +65269,8 @@ var CacheInternal = class {
|
|
|
65274
65269
|
fields: fieldSelection,
|
|
65275
65270
|
variables,
|
|
65276
65271
|
linkedList: value,
|
|
65277
|
-
stepsFromConnection: nextStep
|
|
65272
|
+
stepsFromConnection: nextStep,
|
|
65273
|
+
ignoreMasking: !!ignoreMasking
|
|
65278
65274
|
});
|
|
65279
65275
|
target[attributeName] = listValue.data;
|
|
65280
65276
|
if (listValue.partial) {
|
|
@@ -65291,7 +65287,8 @@ var CacheInternal = class {
|
|
|
65291
65287
|
parent: value,
|
|
65292
65288
|
selection: fieldSelection,
|
|
65293
65289
|
variables,
|
|
65294
|
-
stepsFromConnection: nextStep
|
|
65290
|
+
stepsFromConnection: nextStep,
|
|
65291
|
+
ignoreMasking
|
|
65295
65292
|
});
|
|
65296
65293
|
target[attributeName] = objectFields.data;
|
|
65297
65294
|
if (objectFields.partial) {
|
|
@@ -65335,7 +65332,8 @@ var CacheInternal = class {
|
|
|
65335
65332
|
fields,
|
|
65336
65333
|
variables,
|
|
65337
65334
|
linkedList,
|
|
65338
|
-
stepsFromConnection
|
|
65335
|
+
stepsFromConnection,
|
|
65336
|
+
ignoreMasking
|
|
65339
65337
|
}) {
|
|
65340
65338
|
const result = [];
|
|
65341
65339
|
let partialData = false;
|
|
@@ -65347,7 +65345,8 @@ var CacheInternal = class {
|
|
|
65347
65345
|
fields,
|
|
65348
65346
|
variables,
|
|
65349
65347
|
linkedList: entry,
|
|
65350
|
-
stepsFromConnection
|
|
65348
|
+
stepsFromConnection,
|
|
65349
|
+
ignoreMasking
|
|
65351
65350
|
});
|
|
65352
65351
|
result.push(nestedValue.data);
|
|
65353
65352
|
if (nestedValue.partial) {
|
|
@@ -65368,7 +65367,8 @@ var CacheInternal = class {
|
|
|
65368
65367
|
parent: entry,
|
|
65369
65368
|
selection: fields,
|
|
65370
65369
|
variables,
|
|
65371
|
-
stepsFromConnection
|
|
65370
|
+
stepsFromConnection,
|
|
65371
|
+
ignoreMasking
|
|
65372
65372
|
});
|
|
65373
65373
|
result.push(data);
|
|
65374
65374
|
if (partial) {
|
|
@@ -65471,16 +65471,58 @@ var CacheInternal = class {
|
|
|
65471
65471
|
}
|
|
65472
65472
|
}
|
|
65473
65473
|
};
|
|
65474
|
+
function evaluateFragmentVariables(variables, args) {
|
|
65475
|
+
return Object.fromEntries(
|
|
65476
|
+
Object.entries(variables).map(([key, value]) => [key, fragmentVariableValue(value, args)])
|
|
65477
|
+
);
|
|
65478
|
+
}
|
|
65479
|
+
function fragmentVariableValue(value, args) {
|
|
65480
|
+
if (value.kind === "StringValue") {
|
|
65481
|
+
return value.value;
|
|
65482
|
+
}
|
|
65483
|
+
if (value.kind === "BooleanValue") {
|
|
65484
|
+
return value.value;
|
|
65485
|
+
}
|
|
65486
|
+
if (value.kind === "EnumValue") {
|
|
65487
|
+
return value.value;
|
|
65488
|
+
}
|
|
65489
|
+
if (value.kind === "FloatValue") {
|
|
65490
|
+
return parseFloat(value.value);
|
|
65491
|
+
}
|
|
65492
|
+
if (value.kind === "IntValue") {
|
|
65493
|
+
return parseInt(value.value, 10);
|
|
65494
|
+
}
|
|
65495
|
+
if (value.kind === "NullValue") {
|
|
65496
|
+
return null;
|
|
65497
|
+
}
|
|
65498
|
+
if (value.kind === "Variable") {
|
|
65499
|
+
return args[value.name.value];
|
|
65500
|
+
}
|
|
65501
|
+
if (value.kind === "ListValue") {
|
|
65502
|
+
return value.values.map((value2) => fragmentVariableValue(value2, args));
|
|
65503
|
+
}
|
|
65504
|
+
if (value.kind === "ObjectValue") {
|
|
65505
|
+
return value.fields.reduce(
|
|
65506
|
+
(obj, field) => ({
|
|
65507
|
+
...obj,
|
|
65508
|
+
[field.name.value]: fragmentVariableValue(field.value, args)
|
|
65509
|
+
}),
|
|
65510
|
+
{}
|
|
65511
|
+
);
|
|
65512
|
+
}
|
|
65513
|
+
}
|
|
65474
65514
|
var rootID = "_ROOT_";
|
|
65475
65515
|
|
|
65476
65516
|
// src/runtime/cache/index.ts
|
|
65477
65517
|
var cache_default = new Cache();
|
|
65478
65518
|
|
|
65479
65519
|
// src/runtime/client/plugins/cache.ts
|
|
65520
|
+
var serverSide = typeof globalThis.window === "undefined";
|
|
65480
65521
|
var cachePolicy = ({
|
|
65481
65522
|
enabled,
|
|
65482
65523
|
setFetching,
|
|
65483
|
-
cache: localCache = cache_default
|
|
65524
|
+
cache: localCache = cache_default,
|
|
65525
|
+
serverSideFallback = true
|
|
65484
65526
|
}) => () => {
|
|
65485
65527
|
return {
|
|
65486
65528
|
network(ctx, { initialValue, next, resolve: resolve2, marshalVariables: marshalVariables2 }) {
|
|
@@ -65531,13 +65573,26 @@ var cachePolicy = ({
|
|
|
65531
65573
|
},
|
|
65532
65574
|
afterNetwork(ctx, { resolve: resolve2, value, marshalVariables: marshalVariables2 }) {
|
|
65533
65575
|
if (value.source !== DataSource.Cache && enabled && value.data && !ctx.cacheParams?.disableWrite) {
|
|
65534
|
-
|
|
65576
|
+
const targetCache = serverSide && serverSideFallback ? new Cache({ disabled: false }) : localCache;
|
|
65577
|
+
let layer;
|
|
65578
|
+
if (!serverSide && ctx.cacheParams?.layer) {
|
|
65579
|
+
layer = ctx.cacheParams.layer.id;
|
|
65580
|
+
}
|
|
65581
|
+
targetCache.write({
|
|
65535
65582
|
...ctx.cacheParams,
|
|
65536
|
-
layer
|
|
65583
|
+
layer,
|
|
65537
65584
|
selection: ctx.artifact.selection,
|
|
65538
65585
|
data: value.data,
|
|
65539
65586
|
variables: marshalVariables2(ctx)
|
|
65540
65587
|
});
|
|
65588
|
+
value = {
|
|
65589
|
+
...value,
|
|
65590
|
+
data: targetCache.read({
|
|
65591
|
+
selection: ctx.artifact.selection,
|
|
65592
|
+
variables: marshalVariables2(ctx),
|
|
65593
|
+
ignoreMasking: serverSide
|
|
65594
|
+
}).data
|
|
65595
|
+
};
|
|
65541
65596
|
}
|
|
65542
65597
|
resolve2(ctx, value);
|
|
65543
65598
|
}
|
|
@@ -65579,7 +65634,6 @@ var documentPlugin = (kind, source) => {
|
|
|
65579
65634
|
var query = documentPlugin(ArtifactKind.Query, function() {
|
|
65580
65635
|
let subscriptionSpec = null;
|
|
65581
65636
|
let lastVariables = null;
|
|
65582
|
-
let artifactName = "";
|
|
65583
65637
|
return {
|
|
65584
65638
|
start(ctx, { next }) {
|
|
65585
65639
|
ctx.variables = {
|
|
@@ -65589,8 +65643,7 @@ var query = documentPlugin(ArtifactKind.Query, function() {
|
|
|
65589
65643
|
next(ctx);
|
|
65590
65644
|
},
|
|
65591
65645
|
end(ctx, { resolve: resolve2, marshalVariables: marshalVariables2, variablesChanged: variablesChanged2 }) {
|
|
65592
|
-
if (variablesChanged2(ctx)) {
|
|
65593
|
-
artifactName = ctx.artifact.name;
|
|
65646
|
+
if (variablesChanged2(ctx) && !ctx.cacheParams?.disableSubscriptions) {
|
|
65594
65647
|
if (subscriptionSpec) {
|
|
65595
65648
|
cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.() || {});
|
|
65596
65649
|
}
|
|
@@ -65611,19 +65664,61 @@ var query = documentPlugin(ArtifactKind.Query, function() {
|
|
|
65611
65664
|
});
|
|
65612
65665
|
}
|
|
65613
65666
|
};
|
|
65614
|
-
cache_default.subscribe(subscriptionSpec, lastVariables
|
|
65667
|
+
cache_default.subscribe(subscriptionSpec, lastVariables);
|
|
65615
65668
|
}
|
|
65616
65669
|
resolve2(ctx);
|
|
65617
65670
|
},
|
|
65618
65671
|
cleanup() {
|
|
65619
65672
|
if (subscriptionSpec) {
|
|
65620
|
-
cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.()
|
|
65673
|
+
cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.());
|
|
65621
65674
|
lastVariables = null;
|
|
65622
65675
|
}
|
|
65623
65676
|
}
|
|
65624
65677
|
};
|
|
65625
65678
|
});
|
|
65626
65679
|
|
|
65680
|
+
// src/runtime/client/plugins/fragment.ts
|
|
65681
|
+
var fragment = documentPlugin(ArtifactKind.Fragment, function() {
|
|
65682
|
+
let subscriptionSpec = null;
|
|
65683
|
+
return {
|
|
65684
|
+
start(ctx, { next, resolve: resolve2, variablesChanged: variablesChanged2, marshalVariables: marshalVariables2 }) {
|
|
65685
|
+
if (!ctx.stuff.parentID) {
|
|
65686
|
+
return next(ctx);
|
|
65687
|
+
}
|
|
65688
|
+
if (variablesChanged2(ctx) && !ctx.cacheParams?.disableSubscriptions) {
|
|
65689
|
+
if (subscriptionSpec) {
|
|
65690
|
+
cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.() || {});
|
|
65691
|
+
}
|
|
65692
|
+
const variables = marshalVariables2(ctx);
|
|
65693
|
+
subscriptionSpec = {
|
|
65694
|
+
rootType: ctx.artifact.rootType,
|
|
65695
|
+
selection: ctx.artifact.selection,
|
|
65696
|
+
variables: () => variables,
|
|
65697
|
+
parentID: ctx.stuff.parentID,
|
|
65698
|
+
set: (newValue) => {
|
|
65699
|
+
resolve2(ctx, {
|
|
65700
|
+
data: newValue,
|
|
65701
|
+
errors: null,
|
|
65702
|
+
fetching: false,
|
|
65703
|
+
partial: false,
|
|
65704
|
+
stale: false,
|
|
65705
|
+
source: DataSource.Cache,
|
|
65706
|
+
variables
|
|
65707
|
+
});
|
|
65708
|
+
}
|
|
65709
|
+
};
|
|
65710
|
+
cache_default.subscribe(subscriptionSpec, variables);
|
|
65711
|
+
}
|
|
65712
|
+
next(ctx);
|
|
65713
|
+
},
|
|
65714
|
+
cleanup() {
|
|
65715
|
+
if (subscriptionSpec) {
|
|
65716
|
+
cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.());
|
|
65717
|
+
}
|
|
65718
|
+
}
|
|
65719
|
+
};
|
|
65720
|
+
});
|
|
65721
|
+
|
|
65627
65722
|
// src/runtime/client/plugins/mutation.ts
|
|
65628
65723
|
var mutation = documentPlugin(ArtifactKind.Mutation, () => {
|
|
65629
65724
|
return {
|
|
@@ -65957,8 +66052,8 @@ var DocumentStore = class extends Writable {
|
|
|
65957
66052
|
handlers = {
|
|
65958
66053
|
...common,
|
|
65959
66054
|
value,
|
|
65960
|
-
resolve: (ctx2,
|
|
65961
|
-
return common.resolve(ctx2,
|
|
66055
|
+
resolve: (ctx2, data) => {
|
|
66056
|
+
return common.resolve(ctx2, data ?? value);
|
|
65962
66057
|
}
|
|
65963
66058
|
};
|
|
65964
66059
|
} else if (direction === "error") {
|
|
@@ -66018,25 +66113,16 @@ var DocumentStore = class extends Writable {
|
|
|
66018
66113
|
value
|
|
66019
66114
|
);
|
|
66020
66115
|
}
|
|
66021
|
-
let data = value.data;
|
|
66022
|
-
try {
|
|
66023
|
-
data = unmarshalSelection(this.#configFile, this.#artifact.selection, data) ?? null;
|
|
66024
|
-
} catch {
|
|
66025
|
-
}
|
|
66026
|
-
const finalValue = {
|
|
66027
|
-
...value,
|
|
66028
|
-
data
|
|
66029
|
-
};
|
|
66030
66116
|
if (!ctx.promise.resolved) {
|
|
66031
|
-
ctx.promise.resolve(
|
|
66117
|
+
ctx.promise.resolve(value);
|
|
66032
66118
|
ctx.promise.resolved = true;
|
|
66033
66119
|
}
|
|
66034
66120
|
this.#lastContext = ctx.context.draft();
|
|
66035
66121
|
this.#lastVariables = this.#lastContext.stuff.inputs.marshaled;
|
|
66036
|
-
if (ctx.silenceEcho &&
|
|
66122
|
+
if (ctx.silenceEcho && value.data === this.state.data) {
|
|
66037
66123
|
return;
|
|
66038
66124
|
}
|
|
66039
|
-
this.set(
|
|
66125
|
+
this.set(value);
|
|
66040
66126
|
}
|
|
66041
66127
|
};
|
|
66042
66128
|
var ClientPluginContextWrapper = class {
|
|
@@ -66157,7 +66243,8 @@ var HoudiniClient = class {
|
|
|
66157
66243
|
fetchParams(fetchParams2),
|
|
66158
66244
|
pipeline2 ?? [
|
|
66159
66245
|
query,
|
|
66160
|
-
mutation
|
|
66246
|
+
mutation,
|
|
66247
|
+
fragment
|
|
66161
66248
|
].concat(
|
|
66162
66249
|
plugins2 ?? [],
|
|
66163
66250
|
injectedPlugins_default,
|
|
@@ -66312,6 +66399,7 @@ var Config = class {
|
|
|
66312
66399
|
this.schemaPollInterval = watchSchema?.interval ?? 2e3;
|
|
66313
66400
|
this.schemaPollHeaders = watchSchema?.headers ?? {};
|
|
66314
66401
|
this.rootDir = join2(this.projectRoot, "$houdini");
|
|
66402
|
+
this.#fragmentVariableMaps = {};
|
|
66315
66403
|
if (defaultKeys) {
|
|
66316
66404
|
this.defaultKeys = defaultKeys;
|
|
66317
66405
|
}
|
|
@@ -66461,7 +66549,7 @@ var Config = class {
|
|
|
66461
66549
|
return `$houdini/${this.artifactDirectoryName}/${name}`;
|
|
66462
66550
|
}
|
|
66463
66551
|
keyFieldsForType(type) {
|
|
66464
|
-
return keyFieldsForType(this.configFile, type);
|
|
66552
|
+
return this.schema.getQueryType()?.name === type ? [] : keyFieldsForType(this.configFile, type);
|
|
66465
66553
|
}
|
|
66466
66554
|
computeID(type, data) {
|
|
66467
66555
|
return computeID(this.configFile, type, data);
|
|
@@ -66480,7 +66568,7 @@ var Config = class {
|
|
|
66480
66568
|
({ kind }) => kind === graphql2.Kind.FRAGMENT_DEFINITION
|
|
66481
66569
|
);
|
|
66482
66570
|
if (fragmentDefinitions.length) {
|
|
66483
|
-
return fragmentDefinitions.
|
|
66571
|
+
return fragmentDefinitions[0].name.value;
|
|
66484
66572
|
}
|
|
66485
66573
|
throw new Error("Could not generate artifact name for document: " + graphql2.print(document));
|
|
66486
66574
|
}
|
|
@@ -66652,6 +66740,56 @@ var Config = class {
|
|
|
66652
66740
|
}, []) ?? [];
|
|
66653
66741
|
return !defaultDirectives.includes(name) && (internalDirectives.includes(name) || this.isDeleteDirective(name));
|
|
66654
66742
|
}
|
|
66743
|
+
#fragmentVariableMaps;
|
|
66744
|
+
registerFragmentVariablesHash({
|
|
66745
|
+
hash,
|
|
66746
|
+
args,
|
|
66747
|
+
fragment: fragment2
|
|
66748
|
+
}) {
|
|
66749
|
+
this.#fragmentVariableMaps[hash] = {
|
|
66750
|
+
args: this.#serializeValueMap(args),
|
|
66751
|
+
fragment: fragment2
|
|
66752
|
+
};
|
|
66753
|
+
}
|
|
66754
|
+
getFragmentVariablesHash(hash) {
|
|
66755
|
+
return this.#fragmentVariableMaps[hash] ?? {
|
|
66756
|
+
fragment: hash,
|
|
66757
|
+
args: {},
|
|
66758
|
+
hash
|
|
66759
|
+
};
|
|
66760
|
+
}
|
|
66761
|
+
#serializeValueMap(map) {
|
|
66762
|
+
if (!map) {
|
|
66763
|
+
return null;
|
|
66764
|
+
}
|
|
66765
|
+
return Object.fromEntries(
|
|
66766
|
+
Object.entries(map).map(([key, input]) => {
|
|
66767
|
+
const result = {
|
|
66768
|
+
kind: input.kind
|
|
66769
|
+
};
|
|
66770
|
+
if (typeof input === "object") {
|
|
66771
|
+
if ("value" in input) {
|
|
66772
|
+
result.value = input.value;
|
|
66773
|
+
}
|
|
66774
|
+
if ("values" in input) {
|
|
66775
|
+
result.values = input.values.map(
|
|
66776
|
+
(value) => this.#serializeValueMap({ foo: value }).foo
|
|
66777
|
+
);
|
|
66778
|
+
}
|
|
66779
|
+
if ("name" in input) {
|
|
66780
|
+
result.name = input.name;
|
|
66781
|
+
}
|
|
66782
|
+
if ("fields" in input) {
|
|
66783
|
+
result.fields = input.fields.map((field) => ({
|
|
66784
|
+
name: field.name,
|
|
66785
|
+
value: this.#serializeValueMap({ foo: field.value }).foo
|
|
66786
|
+
}));
|
|
66787
|
+
}
|
|
66788
|
+
}
|
|
66789
|
+
return [key, result];
|
|
66790
|
+
})
|
|
66791
|
+
);
|
|
66792
|
+
}
|
|
66655
66793
|
isListFragment(name) {
|
|
66656
66794
|
return name.endsWith(this.insertFragmentSuffix) || name.endsWith(this.removeFragmentSuffix) || name.endsWith(this.toggleFragmentSuffix);
|
|
66657
66795
|
}
|
|
@@ -67178,11 +67316,17 @@ function deepMerge(filepath, ...targets) {
|
|
|
67178
67316
|
if (targets.length === 1) {
|
|
67179
67317
|
return targets[0];
|
|
67180
67318
|
} else if (targets.length === 2) {
|
|
67181
|
-
return (0, import_deepmerge.default)(targets[0], targets[1]
|
|
67319
|
+
return (0, import_deepmerge.default)(targets[0], targets[1], {
|
|
67320
|
+
arrayMerge: (source, update) => [...new Set(source.concat(update))]
|
|
67321
|
+
});
|
|
67182
67322
|
}
|
|
67183
67323
|
return deepMerge(filepath, targets[0], deepMerge(filepath, ...targets.slice(1)));
|
|
67184
67324
|
} catch (e2) {
|
|
67185
|
-
throw new HoudiniError({
|
|
67325
|
+
throw new HoudiniError({
|
|
67326
|
+
filepath,
|
|
67327
|
+
message: "could not merge: " + targets,
|
|
67328
|
+
description: e2.message
|
|
67329
|
+
});
|
|
67186
67330
|
}
|
|
67187
67331
|
}
|
|
67188
67332
|
|
|
@@ -67449,6 +67593,7 @@ export {
|
|
|
67449
67593
|
fetch2 as fetch,
|
|
67450
67594
|
find_graphql,
|
|
67451
67595
|
formatErrors,
|
|
67596
|
+
fragmentKey,
|
|
67452
67597
|
fs_exports as fs,
|
|
67453
67598
|
getConfig,
|
|
67454
67599
|
getCurrentConfig,
|