houdini 1.0.10 → 1.1.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 +639 -325
- package/build/cmd-esm/index.js +639 -325
- 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 +584 -321
- package/build/codegen-esm/index.js +584 -321
- 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 +638 -324
- package/build/test-esm/index.js +638 -324
- package/build/vite-cjs/index.js +637 -323
- package/build/vite-esm/index.js +637 -323
- package/package.json +2 -2
package/build/cmd-cjs/index.js
CHANGED
|
@@ -5116,7 +5116,7 @@ var require_definition = __commonJS({
|
|
|
5116
5116
|
exports.assertLeafType = assertLeafType;
|
|
5117
5117
|
exports.isCompositeType = isCompositeType;
|
|
5118
5118
|
exports.assertCompositeType = assertCompositeType;
|
|
5119
|
-
exports.isAbstractType =
|
|
5119
|
+
exports.isAbstractType = isAbstractType4;
|
|
5120
5120
|
exports.assertAbstractType = assertAbstractType;
|
|
5121
5121
|
exports.GraphQLList = GraphQLList6;
|
|
5122
5122
|
exports.GraphQLNonNull = GraphQLNonNull6;
|
|
@@ -5287,11 +5287,11 @@ var require_definition = __commonJS({
|
|
|
5287
5287
|
}
|
|
5288
5288
|
return type;
|
|
5289
5289
|
}
|
|
5290
|
-
function
|
|
5290
|
+
function isAbstractType4(type) {
|
|
5291
5291
|
return isInterfaceType12(type) || isUnionType13(type);
|
|
5292
5292
|
}
|
|
5293
5293
|
function assertAbstractType(type) {
|
|
5294
|
-
if (!
|
|
5294
|
+
if (!isAbstractType4(type)) {
|
|
5295
5295
|
throw new Error("Expected ".concat((0, _inspect.default)(type), " to be a GraphQL abstract type."));
|
|
5296
5296
|
}
|
|
5297
5297
|
return type;
|
|
@@ -8555,8 +8555,8 @@ var require_KnownFragmentNamesRule = __commonJS({
|
|
|
8555
8555
|
return {
|
|
8556
8556
|
FragmentSpread: function FragmentSpread(node) {
|
|
8557
8557
|
var fragmentName = node.name.value;
|
|
8558
|
-
var
|
|
8559
|
-
if (!
|
|
8558
|
+
var fragment2 = context.getFragment(fragmentName);
|
|
8559
|
+
if (!fragment2) {
|
|
8560
8560
|
context.reportError(new _GraphQLError.GraphQLError('Unknown fragment "'.concat(fragmentName, '".'), node.name));
|
|
8561
8561
|
}
|
|
8562
8562
|
}
|
|
@@ -8592,8 +8592,8 @@ var require_NoUnusedFragmentsRule = __commonJS({
|
|
|
8592
8592
|
for (var _i2 = 0; _i2 < operationDefs.length; _i2++) {
|
|
8593
8593
|
var operation = operationDefs[_i2];
|
|
8594
8594
|
for (var _i4 = 0, _context$getRecursive2 = context.getRecursivelyReferencedFragments(operation); _i4 < _context$getRecursive2.length; _i4++) {
|
|
8595
|
-
var
|
|
8596
|
-
fragmentNameUsed[
|
|
8595
|
+
var fragment2 = _context$getRecursive2[_i4];
|
|
8596
|
+
fragmentNameUsed[fragment2.name.value] = true;
|
|
8597
8597
|
}
|
|
8598
8598
|
}
|
|
8599
8599
|
for (var _i6 = 0; _i6 < fragmentDefs.length; _i6++) {
|
|
@@ -8683,13 +8683,13 @@ var require_NoFragmentCyclesRule = __commonJS({
|
|
|
8683
8683
|
return false;
|
|
8684
8684
|
}
|
|
8685
8685
|
};
|
|
8686
|
-
function detectCycleRecursive(
|
|
8687
|
-
if (visitedFrags[
|
|
8686
|
+
function detectCycleRecursive(fragment2) {
|
|
8687
|
+
if (visitedFrags[fragment2.name.value]) {
|
|
8688
8688
|
return;
|
|
8689
8689
|
}
|
|
8690
|
-
var fragmentName =
|
|
8690
|
+
var fragmentName = fragment2.name.value;
|
|
8691
8691
|
visitedFrags[fragmentName] = true;
|
|
8692
|
-
var spreadNodes = context.getFragmentSpreads(
|
|
8692
|
+
var spreadNodes = context.getFragmentSpreads(fragment2.selectionSet);
|
|
8693
8693
|
if (spreadNodes.length === 0) {
|
|
8694
8694
|
return;
|
|
8695
8695
|
}
|
|
@@ -9510,11 +9510,11 @@ var require_OverlappingFieldsCanBeMergedRule = __commonJS({
|
|
|
9510
9510
|
return conflicts;
|
|
9511
9511
|
}
|
|
9512
9512
|
function collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, fieldMap, fragmentName) {
|
|
9513
|
-
var
|
|
9514
|
-
if (!
|
|
9513
|
+
var fragment2 = context.getFragment(fragmentName);
|
|
9514
|
+
if (!fragment2) {
|
|
9515
9515
|
return;
|
|
9516
9516
|
}
|
|
9517
|
-
var _getReferencedFieldsA = getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames,
|
|
9517
|
+
var _getReferencedFieldsA = getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragment2), fieldMap2 = _getReferencedFieldsA[0], fragmentNames2 = _getReferencedFieldsA[1];
|
|
9518
9518
|
if (fieldMap === fieldMap2) {
|
|
9519
9519
|
return;
|
|
9520
9520
|
}
|
|
@@ -9685,38 +9685,38 @@ var require_OverlappingFieldsCanBeMergedRule = __commonJS({
|
|
|
9685
9685
|
}
|
|
9686
9686
|
return cached;
|
|
9687
9687
|
}
|
|
9688
|
-
function getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames,
|
|
9689
|
-
var cached = cachedFieldsAndFragmentNames.get(
|
|
9688
|
+
function getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragment2) {
|
|
9689
|
+
var cached = cachedFieldsAndFragmentNames.get(fragment2.selectionSet);
|
|
9690
9690
|
if (cached) {
|
|
9691
9691
|
return cached;
|
|
9692
9692
|
}
|
|
9693
|
-
var fragmentType = (0, _typeFromAST.typeFromAST)(context.getSchema(),
|
|
9694
|
-
return getFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragmentType,
|
|
9693
|
+
var fragmentType = (0, _typeFromAST.typeFromAST)(context.getSchema(), fragment2.typeCondition);
|
|
9694
|
+
return getFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragmentType, fragment2.selectionSet);
|
|
9695
9695
|
}
|
|
9696
9696
|
function _collectFieldsAndFragmentNames(context, parentType, selectionSet, nodeAndDefs, fragmentNames) {
|
|
9697
9697
|
for (var _i9 = 0, _selectionSet$selecti2 = selectionSet.selections; _i9 < _selectionSet$selecti2.length; _i9++) {
|
|
9698
|
-
var
|
|
9699
|
-
switch (
|
|
9698
|
+
var selection = _selectionSet$selecti2[_i9];
|
|
9699
|
+
switch (selection.kind) {
|
|
9700
9700
|
case _kinds.Kind.FIELD: {
|
|
9701
|
-
var fieldName =
|
|
9701
|
+
var fieldName = selection.name.value;
|
|
9702
9702
|
var fieldDef = void 0;
|
|
9703
9703
|
if ((0, _definition.isObjectType)(parentType) || (0, _definition.isInterfaceType)(parentType)) {
|
|
9704
9704
|
fieldDef = parentType.getFields()[fieldName];
|
|
9705
9705
|
}
|
|
9706
|
-
var responseName =
|
|
9706
|
+
var responseName = selection.alias ? selection.alias.value : fieldName;
|
|
9707
9707
|
if (!nodeAndDefs[responseName]) {
|
|
9708
9708
|
nodeAndDefs[responseName] = [];
|
|
9709
9709
|
}
|
|
9710
|
-
nodeAndDefs[responseName].push([parentType,
|
|
9710
|
+
nodeAndDefs[responseName].push([parentType, selection, fieldDef]);
|
|
9711
9711
|
break;
|
|
9712
9712
|
}
|
|
9713
9713
|
case _kinds.Kind.FRAGMENT_SPREAD:
|
|
9714
|
-
fragmentNames[
|
|
9714
|
+
fragmentNames[selection.name.value] = true;
|
|
9715
9715
|
break;
|
|
9716
9716
|
case _kinds.Kind.INLINE_FRAGMENT: {
|
|
9717
|
-
var typeCondition =
|
|
9717
|
+
var typeCondition = selection.typeCondition;
|
|
9718
9718
|
var inlineFragmentType = typeCondition ? (0, _typeFromAST.typeFromAST)(context.getSchema(), typeCondition) : parentType;
|
|
9719
|
-
_collectFieldsAndFragmentNames(context, inlineFragmentType,
|
|
9719
|
+
_collectFieldsAndFragmentNames(context, inlineFragmentType, selection.selectionSet, nodeAndDefs, fragmentNames);
|
|
9720
9720
|
break;
|
|
9721
9721
|
}
|
|
9722
9722
|
}
|
|
@@ -10252,11 +10252,11 @@ var require_ValidationContext = __commonJS({
|
|
|
10252
10252
|
while (setsToVisit.length !== 0) {
|
|
10253
10253
|
var set = setsToVisit.pop();
|
|
10254
10254
|
for (var _i2 = 0, _set$selections2 = set.selections; _i2 < _set$selections2.length; _i2++) {
|
|
10255
|
-
var
|
|
10256
|
-
if (
|
|
10257
|
-
spreads.push(
|
|
10258
|
-
} else if (
|
|
10259
|
-
setsToVisit.push(
|
|
10255
|
+
var selection = _set$selections2[_i2];
|
|
10256
|
+
if (selection.kind === _kinds.Kind.FRAGMENT_SPREAD) {
|
|
10257
|
+
spreads.push(selection);
|
|
10258
|
+
} else if (selection.selectionSet) {
|
|
10259
|
+
setsToVisit.push(selection.selectionSet);
|
|
10260
10260
|
}
|
|
10261
10261
|
}
|
|
10262
10262
|
}
|
|
@@ -10277,10 +10277,10 @@ var require_ValidationContext = __commonJS({
|
|
|
10277
10277
|
var fragName = spread.name.value;
|
|
10278
10278
|
if (collectedNames[fragName] !== true) {
|
|
10279
10279
|
collectedNames[fragName] = true;
|
|
10280
|
-
var
|
|
10281
|
-
if (
|
|
10282
|
-
fragments.push(
|
|
10283
|
-
nodesToVisit.push(
|
|
10280
|
+
var fragment2 = this.getFragment(fragName);
|
|
10281
|
+
if (fragment2) {
|
|
10282
|
+
fragments.push(fragment2);
|
|
10283
|
+
nodesToVisit.push(fragment2.selectionSet);
|
|
10284
10284
|
}
|
|
10285
10285
|
}
|
|
10286
10286
|
}
|
|
@@ -11193,37 +11193,37 @@ var require_execute = __commonJS({
|
|
|
11193
11193
|
}
|
|
11194
11194
|
function collectFields(exeContext, runtimeType, selectionSet, fields, visitedFragmentNames) {
|
|
11195
11195
|
for (var _i6 = 0, _selectionSet$selecti2 = selectionSet.selections; _i6 < _selectionSet$selecti2.length; _i6++) {
|
|
11196
|
-
var
|
|
11197
|
-
switch (
|
|
11196
|
+
var selection = _selectionSet$selecti2[_i6];
|
|
11197
|
+
switch (selection.kind) {
|
|
11198
11198
|
case _kinds.Kind.FIELD: {
|
|
11199
|
-
if (!shouldIncludeNode(exeContext,
|
|
11199
|
+
if (!shouldIncludeNode(exeContext, selection)) {
|
|
11200
11200
|
continue;
|
|
11201
11201
|
}
|
|
11202
|
-
var name = getFieldEntryKey(
|
|
11202
|
+
var name = getFieldEntryKey(selection);
|
|
11203
11203
|
if (!fields[name]) {
|
|
11204
11204
|
fields[name] = [];
|
|
11205
11205
|
}
|
|
11206
|
-
fields[name].push(
|
|
11206
|
+
fields[name].push(selection);
|
|
11207
11207
|
break;
|
|
11208
11208
|
}
|
|
11209
11209
|
case _kinds.Kind.INLINE_FRAGMENT: {
|
|
11210
|
-
if (!shouldIncludeNode(exeContext,
|
|
11210
|
+
if (!shouldIncludeNode(exeContext, selection) || !doesFragmentConditionMatch(exeContext, selection, runtimeType)) {
|
|
11211
11211
|
continue;
|
|
11212
11212
|
}
|
|
11213
|
-
collectFields(exeContext, runtimeType,
|
|
11213
|
+
collectFields(exeContext, runtimeType, selection.selectionSet, fields, visitedFragmentNames);
|
|
11214
11214
|
break;
|
|
11215
11215
|
}
|
|
11216
11216
|
case _kinds.Kind.FRAGMENT_SPREAD: {
|
|
11217
|
-
var fragName =
|
|
11218
|
-
if (visitedFragmentNames[fragName] || !shouldIncludeNode(exeContext,
|
|
11217
|
+
var fragName = selection.name.value;
|
|
11218
|
+
if (visitedFragmentNames[fragName] || !shouldIncludeNode(exeContext, selection)) {
|
|
11219
11219
|
continue;
|
|
11220
11220
|
}
|
|
11221
11221
|
visitedFragmentNames[fragName] = true;
|
|
11222
|
-
var
|
|
11223
|
-
if (!
|
|
11222
|
+
var fragment2 = exeContext.fragments[fragName];
|
|
11223
|
+
if (!fragment2 || !doesFragmentConditionMatch(exeContext, fragment2, runtimeType)) {
|
|
11224
11224
|
continue;
|
|
11225
11225
|
}
|
|
11226
|
-
collectFields(exeContext, runtimeType,
|
|
11226
|
+
collectFields(exeContext, runtimeType, fragment2.selectionSet, fields, visitedFragmentNames);
|
|
11227
11227
|
break;
|
|
11228
11228
|
}
|
|
11229
11229
|
}
|
|
@@ -11241,8 +11241,8 @@ var require_execute = __commonJS({
|
|
|
11241
11241
|
}
|
|
11242
11242
|
return true;
|
|
11243
11243
|
}
|
|
11244
|
-
function doesFragmentConditionMatch(exeContext,
|
|
11245
|
-
var typeConditionNode =
|
|
11244
|
+
function doesFragmentConditionMatch(exeContext, fragment2, type) {
|
|
11245
|
+
var typeConditionNode = fragment2.typeCondition;
|
|
11246
11246
|
if (!typeConditionNode) {
|
|
11247
11247
|
return true;
|
|
11248
11248
|
}
|
|
@@ -68475,14 +68475,14 @@ function deepEquals(objA, objB, map = /* @__PURE__ */ new WeakMap()) {
|
|
|
68475
68475
|
}
|
|
68476
68476
|
|
|
68477
68477
|
// src/runtime/lib/selection.ts
|
|
68478
|
-
function getFieldsForType(
|
|
68479
|
-
let targetSelection =
|
|
68480
|
-
if (
|
|
68481
|
-
const mappedType =
|
|
68478
|
+
function getFieldsForType(selection, __typename) {
|
|
68479
|
+
let targetSelection = selection.fields || {};
|
|
68480
|
+
if (selection.abstractFields && __typename) {
|
|
68481
|
+
const mappedType = selection.abstractFields.typeMap[__typename];
|
|
68482
68482
|
if (mappedType) {
|
|
68483
|
-
targetSelection =
|
|
68484
|
-
} else if (
|
|
68485
|
-
targetSelection =
|
|
68483
|
+
targetSelection = selection.abstractFields.fields[mappedType];
|
|
68484
|
+
} else if (selection.abstractFields.fields[__typename]) {
|
|
68485
|
+
targetSelection = selection.abstractFields.fields[__typename];
|
|
68486
68486
|
}
|
|
68487
68487
|
}
|
|
68488
68488
|
return targetSelection;
|
|
@@ -68490,7 +68490,7 @@ function getFieldsForType(selection2, __typename) {
|
|
|
68490
68490
|
|
|
68491
68491
|
// src/runtime/lib/scalars.ts
|
|
68492
68492
|
async function marshalSelection({
|
|
68493
|
-
selection
|
|
68493
|
+
selection,
|
|
68494
68494
|
data
|
|
68495
68495
|
}) {
|
|
68496
68496
|
const config2 = getCurrentConfig();
|
|
@@ -68498,18 +68498,18 @@ async function marshalSelection({
|
|
|
68498
68498
|
return data;
|
|
68499
68499
|
}
|
|
68500
68500
|
if (Array.isArray(data)) {
|
|
68501
|
-
return await Promise.all(data.map((val) => marshalSelection({ selection
|
|
68501
|
+
return await Promise.all(data.map((val) => marshalSelection({ selection, data: val })));
|
|
68502
68502
|
}
|
|
68503
|
-
const targetSelection = getFieldsForType(
|
|
68503
|
+
const targetSelection = getFieldsForType(selection, data["__typename"]);
|
|
68504
68504
|
return Object.fromEntries(
|
|
68505
68505
|
await Promise.all(
|
|
68506
68506
|
Object.entries(data).map(async ([fieldName, value]) => {
|
|
68507
|
-
const { type, selection:
|
|
68507
|
+
const { type, selection: selection2 } = targetSelection[fieldName];
|
|
68508
68508
|
if (!type) {
|
|
68509
68509
|
return [fieldName, value];
|
|
68510
68510
|
}
|
|
68511
|
-
if (
|
|
68512
|
-
return [fieldName, await marshalSelection({ selection:
|
|
68511
|
+
if (selection2) {
|
|
68512
|
+
return [fieldName, await marshalSelection({ selection: selection2, data: value })];
|
|
68513
68513
|
}
|
|
68514
68514
|
if (config2.scalars?.[type]) {
|
|
68515
68515
|
const marshalFn = config2.scalars[type].marshal;
|
|
@@ -68560,6 +68560,7 @@ var DataSource = {
|
|
|
68560
68560
|
Network: "network",
|
|
68561
68561
|
Ssr: "ssr"
|
|
68562
68562
|
};
|
|
68563
|
+
var fragmentKey = " $fragments";
|
|
68563
68564
|
|
|
68564
68565
|
// src/runtime/lib/key.ts
|
|
68565
68566
|
var computeKey = ({ field, args }) => {
|
|
@@ -70302,7 +70303,7 @@ var List = class {
|
|
|
70302
70303
|
recordType,
|
|
70303
70304
|
key,
|
|
70304
70305
|
listType,
|
|
70305
|
-
selection
|
|
70306
|
+
selection,
|
|
70306
70307
|
when,
|
|
70307
70308
|
filters,
|
|
70308
70309
|
connection,
|
|
@@ -70314,7 +70315,7 @@ var List = class {
|
|
|
70314
70315
|
this.key = key;
|
|
70315
70316
|
this.type = listType;
|
|
70316
70317
|
this.cache = manager.cache;
|
|
70317
|
-
this.selection =
|
|
70318
|
+
this.selection = selection;
|
|
70318
70319
|
this._when = when;
|
|
70319
70320
|
this.filters = filters;
|
|
70320
70321
|
this.name = name;
|
|
@@ -70325,19 +70326,19 @@ var List = class {
|
|
|
70325
70326
|
when(when) {
|
|
70326
70327
|
return this.manager.lists.get(this.name).get(this.recordID).when(when);
|
|
70327
70328
|
}
|
|
70328
|
-
append(
|
|
70329
|
-
return this.addToList(
|
|
70329
|
+
append(selection, data, variables = {}) {
|
|
70330
|
+
return this.addToList(selection, data, variables, "last");
|
|
70330
70331
|
}
|
|
70331
|
-
prepend(
|
|
70332
|
-
return this.addToList(
|
|
70332
|
+
prepend(selection, data, variables = {}) {
|
|
70333
|
+
return this.addToList(selection, data, variables, "first");
|
|
70333
70334
|
}
|
|
70334
|
-
addToList(
|
|
70335
|
+
addToList(selection, data, variables = {}, where) {
|
|
70335
70336
|
const listType = this.listType(data);
|
|
70336
70337
|
const dataID = this.cache._internal_unstable.id(listType, data);
|
|
70337
70338
|
if (!this.validateWhen() || !dataID) {
|
|
70338
70339
|
return;
|
|
70339
70340
|
}
|
|
70340
|
-
let insertSelection =
|
|
70341
|
+
let insertSelection = selection;
|
|
70341
70342
|
let insertData = data;
|
|
70342
70343
|
if (this.connection) {
|
|
70343
70344
|
insertSelection = {
|
|
@@ -70357,9 +70358,9 @@ var List = class {
|
|
|
70357
70358
|
type: listType,
|
|
70358
70359
|
keyRaw: "node",
|
|
70359
70360
|
selection: {
|
|
70360
|
-
...
|
|
70361
|
+
...selection,
|
|
70361
70362
|
fields: {
|
|
70362
|
-
...
|
|
70363
|
+
...selection.fields,
|
|
70363
70364
|
__typename: {
|
|
70364
70365
|
keyRaw: "__typename",
|
|
70365
70366
|
type: "String"
|
|
@@ -70388,9 +70389,9 @@ var List = class {
|
|
|
70388
70389
|
type: listType,
|
|
70389
70390
|
updates: ["append", "prepend"],
|
|
70390
70391
|
selection: {
|
|
70391
|
-
...
|
|
70392
|
+
...selection,
|
|
70392
70393
|
fields: {
|
|
70393
|
-
...
|
|
70394
|
+
...selection.fields,
|
|
70394
70395
|
__typename: {
|
|
70395
70396
|
keyRaw: "__typename",
|
|
70396
70397
|
type: "String"
|
|
@@ -70465,7 +70466,8 @@ var List = class {
|
|
|
70465
70466
|
this.cache._internal_unstable.getSelection({
|
|
70466
70467
|
parent: spec.parentID || this.manager.rootID,
|
|
70467
70468
|
selection: spec.selection,
|
|
70468
|
-
variables: spec.variables?.() || {}
|
|
70469
|
+
variables: spec.variables?.() || {},
|
|
70470
|
+
ignoreMasking: false
|
|
70469
70471
|
}).data
|
|
70470
70472
|
);
|
|
70471
70473
|
}
|
|
@@ -70501,9 +70503,9 @@ var List = class {
|
|
|
70501
70503
|
}
|
|
70502
70504
|
return ok;
|
|
70503
70505
|
}
|
|
70504
|
-
toggleElement(
|
|
70506
|
+
toggleElement(selection, data, variables = {}, where) {
|
|
70505
70507
|
if (!this.remove(data, variables)) {
|
|
70506
|
-
this.addToList(
|
|
70508
|
+
this.addToList(selection, data, variables, where);
|
|
70507
70509
|
}
|
|
70508
70510
|
}
|
|
70509
70511
|
*[Symbol.iterator]() {
|
|
@@ -71078,14 +71080,24 @@ var InMemorySubscriptions = class {
|
|
|
71078
71080
|
add({
|
|
71079
71081
|
parent,
|
|
71080
71082
|
spec,
|
|
71081
|
-
selection
|
|
71083
|
+
selection,
|
|
71082
71084
|
variables,
|
|
71083
71085
|
parentType
|
|
71084
71086
|
}) {
|
|
71085
71087
|
const __typename = this.cache._internal_unstable.storage.get(parent, "__typename").value;
|
|
71086
|
-
let targetSelection = getFieldsForType(
|
|
71088
|
+
let targetSelection = getFieldsForType(selection, __typename);
|
|
71087
71089
|
for (const fieldSelection of Object.values(targetSelection || {})) {
|
|
71088
|
-
const {
|
|
71090
|
+
const {
|
|
71091
|
+
keyRaw,
|
|
71092
|
+
selection: innerSelection,
|
|
71093
|
+
type,
|
|
71094
|
+
list,
|
|
71095
|
+
filters,
|
|
71096
|
+
visible
|
|
71097
|
+
} = fieldSelection;
|
|
71098
|
+
if (!visible) {
|
|
71099
|
+
continue;
|
|
71100
|
+
}
|
|
71089
71101
|
const key = evaluateKey(keyRaw, variables);
|
|
71090
71102
|
let targetSelection2;
|
|
71091
71103
|
if (innerSelection) {
|
|
@@ -71133,10 +71145,10 @@ var InMemorySubscriptions = class {
|
|
|
71133
71145
|
addFieldSubscription({
|
|
71134
71146
|
id,
|
|
71135
71147
|
key,
|
|
71136
|
-
selection
|
|
71148
|
+
selection,
|
|
71137
71149
|
type
|
|
71138
71150
|
}) {
|
|
71139
|
-
const spec =
|
|
71151
|
+
const spec = selection[0];
|
|
71140
71152
|
if (!this.subscribers[id]) {
|
|
71141
71153
|
this.subscribers[id] = {};
|
|
71142
71154
|
}
|
|
@@ -71148,7 +71160,7 @@ var InMemorySubscriptions = class {
|
|
|
71148
71160
|
}
|
|
71149
71161
|
this.keyVersions[key].add(key);
|
|
71150
71162
|
if (!this.subscribers[id][key].map(([{ set }]) => set).includes(spec.set)) {
|
|
71151
|
-
this.subscribers[id][key].push([spec,
|
|
71163
|
+
this.subscribers[id][key].push([spec, selection[1]]);
|
|
71152
71164
|
}
|
|
71153
71165
|
if (!this.referenceCounts[id]) {
|
|
71154
71166
|
this.referenceCounts[id] = {};
|
|
@@ -71159,14 +71171,13 @@ var InMemorySubscriptions = class {
|
|
|
71159
71171
|
const counts = this.referenceCounts[id][key];
|
|
71160
71172
|
counts.set(spec.set, (counts.get(spec.set) || 0) + 1);
|
|
71161
71173
|
this.cache._internal_unstable.lifetimes.resetLifetime(id, key);
|
|
71162
|
-
const { selection: innerSelection } = selection2[1]?.[key] ?? {};
|
|
71163
71174
|
}
|
|
71164
71175
|
registerList({
|
|
71165
71176
|
list,
|
|
71166
71177
|
id,
|
|
71167
71178
|
key,
|
|
71168
71179
|
parentType,
|
|
71169
|
-
selection
|
|
71180
|
+
selection,
|
|
71170
71181
|
filters,
|
|
71171
71182
|
variables
|
|
71172
71183
|
}) {
|
|
@@ -71177,7 +71188,7 @@ var InMemorySubscriptions = class {
|
|
|
71177
71188
|
recordType: this.cache._internal_unstable.storage.get(id, "__typename")?.value || parentType,
|
|
71178
71189
|
listType: list.type,
|
|
71179
71190
|
key,
|
|
71180
|
-
selection
|
|
71191
|
+
selection,
|
|
71181
71192
|
filters: Object.entries(filters || {}).reduce((acc, [key2, { kind, value }]) => {
|
|
71182
71193
|
return {
|
|
71183
71194
|
...acc,
|
|
@@ -71193,14 +71204,14 @@ var InMemorySubscriptions = class {
|
|
|
71193
71204
|
parentType
|
|
71194
71205
|
}) {
|
|
71195
71206
|
for (const [spec, targetSelection] of subscribers) {
|
|
71196
|
-
for (const
|
|
71207
|
+
for (const selection of Object.values(targetSelection ?? {})) {
|
|
71197
71208
|
const {
|
|
71198
71209
|
type: linkedType,
|
|
71199
71210
|
keyRaw,
|
|
71200
71211
|
selection: innerSelection,
|
|
71201
71212
|
list,
|
|
71202
71213
|
filters
|
|
71203
|
-
} =
|
|
71214
|
+
} = selection;
|
|
71204
71215
|
const key = evaluateKey(keyRaw, variables);
|
|
71205
71216
|
const fieldSelection = innerSelection ? getFieldsForType(innerSelection, parentType) : void 0;
|
|
71206
71217
|
this.addFieldSubscription({
|
|
@@ -71220,7 +71231,7 @@ var InMemorySubscriptions = class {
|
|
|
71220
71231
|
parentType: parentType || spec.rootType
|
|
71221
71232
|
});
|
|
71222
71233
|
}
|
|
71223
|
-
const childSelection =
|
|
71234
|
+
const childSelection = selection.selection;
|
|
71224
71235
|
if (childSelection) {
|
|
71225
71236
|
const { value: link } = this.cache._internal_unstable.storage.get(parent, key);
|
|
71226
71237
|
const children = !Array.isArray(link) ? [link] : flatten(link);
|
|
@@ -71247,11 +71258,11 @@ var InMemorySubscriptions = class {
|
|
|
71247
71258
|
get(id, field) {
|
|
71248
71259
|
return this.subscribers[id]?.[field] || [];
|
|
71249
71260
|
}
|
|
71250
|
-
remove(id,
|
|
71261
|
+
remove(id, selection, targets, variables, visited = []) {
|
|
71251
71262
|
visited.push(id);
|
|
71252
71263
|
const linkedIDs = [];
|
|
71253
71264
|
const __typename = this.cache._internal_unstable.storage.get(id, "__typename").value;
|
|
71254
|
-
let targetSelection = getFieldsForType(
|
|
71265
|
+
let targetSelection = getFieldsForType(selection, __typename);
|
|
71255
71266
|
for (const fieldSelection of Object.values(targetSelection || {})) {
|
|
71256
71267
|
const key = evaluateKey(fieldSelection.keyRaw, variables);
|
|
71257
71268
|
this.removeSubscribers(id, key, targets);
|
|
@@ -71313,7 +71324,7 @@ var InMemorySubscriptions = class {
|
|
|
71313
71324
|
// src/runtime/cache/cache.ts
|
|
71314
71325
|
var Cache = class {
|
|
71315
71326
|
_internal_unstable;
|
|
71316
|
-
constructor(config2) {
|
|
71327
|
+
constructor({ disabled, ...config2 } = {}) {
|
|
71317
71328
|
this._internal_unstable = new CacheInternal({
|
|
71318
71329
|
cache: this,
|
|
71319
71330
|
storage: new InMemoryStorage(),
|
|
@@ -71321,9 +71332,10 @@ var Cache = class {
|
|
|
71321
71332
|
lists: new ListManager(this, rootID),
|
|
71322
71333
|
lifetimes: new GarbageCollector(this),
|
|
71323
71334
|
staleManager: new StaleManager(this),
|
|
71324
|
-
schema: new SchemaManager(this)
|
|
71335
|
+
schema: new SchemaManager(this),
|
|
71336
|
+
disabled: disabled ?? typeof globalThis.window === "undefined"
|
|
71325
71337
|
});
|
|
71326
|
-
if (config2) {
|
|
71338
|
+
if (Object.keys(config2).length > 0) {
|
|
71327
71339
|
this.setConfig(defaultConfigValues(config2));
|
|
71328
71340
|
}
|
|
71329
71341
|
}
|
|
@@ -71342,7 +71354,8 @@ var Cache = class {
|
|
|
71342
71354
|
this._internal_unstable.getSelection({
|
|
71343
71355
|
parent: spec.parentID || rootID,
|
|
71344
71356
|
selection: spec.selection,
|
|
71345
|
-
variables: spec.variables?.() || {}
|
|
71357
|
+
variables: spec.variables?.() || {},
|
|
71358
|
+
ignoreMasking: false
|
|
71346
71359
|
}).data
|
|
71347
71360
|
);
|
|
71348
71361
|
}
|
|
@@ -71417,16 +71430,13 @@ var Cache = class {
|
|
|
71417
71430
|
getFieldTime(id, field) {
|
|
71418
71431
|
return this._internal_unstable.staleManager.getFieldTime(id, field);
|
|
71419
71432
|
}
|
|
71433
|
+
config() {
|
|
71434
|
+
return this._internal_unstable.config;
|
|
71435
|
+
}
|
|
71420
71436
|
};
|
|
71421
71437
|
var CacheInternal = class {
|
|
71422
71438
|
_disabled = false;
|
|
71423
|
-
|
|
71424
|
-
plugins: {
|
|
71425
|
-
"houdini-svelte": {
|
|
71426
|
-
client: ""
|
|
71427
|
-
}
|
|
71428
|
-
}
|
|
71429
|
-
});
|
|
71439
|
+
_config;
|
|
71430
71440
|
storage;
|
|
71431
71441
|
subscriptions;
|
|
71432
71442
|
lists;
|
|
@@ -71441,7 +71451,9 @@ var CacheInternal = class {
|
|
|
71441
71451
|
cache,
|
|
71442
71452
|
lifetimes,
|
|
71443
71453
|
staleManager,
|
|
71444
|
-
schema
|
|
71454
|
+
schema,
|
|
71455
|
+
disabled,
|
|
71456
|
+
config: config2
|
|
71445
71457
|
}) {
|
|
71446
71458
|
this.storage = storage;
|
|
71447
71459
|
this.subscriptions = subscriptions;
|
|
@@ -71450,7 +71462,8 @@ var CacheInternal = class {
|
|
|
71450
71462
|
this.lifetimes = lifetimes;
|
|
71451
71463
|
this.staleManager = staleManager;
|
|
71452
71464
|
this.schema = schema;
|
|
71453
|
-
this.
|
|
71465
|
+
this._config = config2;
|
|
71466
|
+
this._disabled = disabled;
|
|
71454
71467
|
try {
|
|
71455
71468
|
if (process.env.HOUDINI_TEST === "true") {
|
|
71456
71469
|
this._disabled = false;
|
|
@@ -71458,12 +71471,15 @@ var CacheInternal = class {
|
|
|
71458
71471
|
} catch {
|
|
71459
71472
|
}
|
|
71460
71473
|
}
|
|
71474
|
+
get config() {
|
|
71475
|
+
return this._config ?? getCurrentConfig();
|
|
71476
|
+
}
|
|
71461
71477
|
setConfig(config2) {
|
|
71462
|
-
this.
|
|
71478
|
+
this._config = config2;
|
|
71463
71479
|
}
|
|
71464
71480
|
writeSelection({
|
|
71465
71481
|
data,
|
|
71466
|
-
selection
|
|
71482
|
+
selection,
|
|
71467
71483
|
variables = {},
|
|
71468
71484
|
parent = rootID,
|
|
71469
71485
|
applyUpdates,
|
|
@@ -71475,9 +71491,9 @@ var CacheInternal = class {
|
|
|
71475
71491
|
if (this._disabled) {
|
|
71476
71492
|
return [];
|
|
71477
71493
|
}
|
|
71478
|
-
let targetSelection = getFieldsForType(
|
|
71494
|
+
let targetSelection = getFieldsForType(selection, data["__typename"]);
|
|
71479
71495
|
for (const [field, value] of Object.entries(data)) {
|
|
71480
|
-
if (!
|
|
71496
|
+
if (!selection || !targetSelection[field]) {
|
|
71481
71497
|
continue;
|
|
71482
71498
|
}
|
|
71483
71499
|
let {
|
|
@@ -71733,25 +71749,40 @@ var CacheInternal = class {
|
|
|
71733
71749
|
return toNotify;
|
|
71734
71750
|
}
|
|
71735
71751
|
getSelection({
|
|
71736
|
-
selection
|
|
71752
|
+
selection,
|
|
71737
71753
|
parent = rootID,
|
|
71738
71754
|
variables,
|
|
71739
|
-
stepsFromConnection = null
|
|
71755
|
+
stepsFromConnection = null,
|
|
71756
|
+
ignoreMasking
|
|
71740
71757
|
}) {
|
|
71741
71758
|
if (parent === null) {
|
|
71742
71759
|
return { data: null, partial: false, stale: false, hasData: true };
|
|
71743
71760
|
}
|
|
71744
71761
|
const target = {};
|
|
71762
|
+
if (selection.fragments) {
|
|
71763
|
+
target[fragmentKey] = Object.fromEntries(
|
|
71764
|
+
Object.entries(selection.fragments).map(([key, value]) => [
|
|
71765
|
+
key,
|
|
71766
|
+
{
|
|
71767
|
+
parent,
|
|
71768
|
+
variables: evaluateFragmentVariables(value, variables ?? {})
|
|
71769
|
+
}
|
|
71770
|
+
])
|
|
71771
|
+
);
|
|
71772
|
+
}
|
|
71745
71773
|
let hasData = false;
|
|
71746
71774
|
let partial = false;
|
|
71747
71775
|
let cascadeNull = false;
|
|
71748
71776
|
let stale = false;
|
|
71749
71777
|
const typename = this.storage.get(parent, "__typename").value;
|
|
71750
|
-
let targetSelection = getFieldsForType(
|
|
71778
|
+
let targetSelection = getFieldsForType(selection, typename);
|
|
71751
71779
|
for (const [
|
|
71752
71780
|
attributeName,
|
|
71753
|
-
{ type, keyRaw, selection: fieldSelection, nullable, list }
|
|
71781
|
+
{ type, keyRaw, selection: fieldSelection, nullable, list, visible }
|
|
71754
71782
|
] of Object.entries(targetSelection)) {
|
|
71783
|
+
if (!visible && !ignoreMasking) {
|
|
71784
|
+
continue;
|
|
71785
|
+
}
|
|
71755
71786
|
const key = evaluateKey(keyRaw, variables);
|
|
71756
71787
|
const { value } = this.storage.get(parent, key);
|
|
71757
71788
|
const dt_field = this.staleManager.getFieldTime(parent, key);
|
|
@@ -71791,7 +71822,8 @@ var CacheInternal = class {
|
|
|
71791
71822
|
fields: fieldSelection,
|
|
71792
71823
|
variables,
|
|
71793
71824
|
linkedList: value,
|
|
71794
|
-
stepsFromConnection: nextStep
|
|
71825
|
+
stepsFromConnection: nextStep,
|
|
71826
|
+
ignoreMasking: !!ignoreMasking
|
|
71795
71827
|
});
|
|
71796
71828
|
target[attributeName] = listValue.data;
|
|
71797
71829
|
if (listValue.partial) {
|
|
@@ -71808,7 +71840,8 @@ var CacheInternal = class {
|
|
|
71808
71840
|
parent: value,
|
|
71809
71841
|
selection: fieldSelection,
|
|
71810
71842
|
variables,
|
|
71811
|
-
stepsFromConnection: nextStep
|
|
71843
|
+
stepsFromConnection: nextStep,
|
|
71844
|
+
ignoreMasking
|
|
71812
71845
|
});
|
|
71813
71846
|
target[attributeName] = objectFields.data;
|
|
71814
71847
|
if (objectFields.partial) {
|
|
@@ -71852,7 +71885,8 @@ var CacheInternal = class {
|
|
|
71852
71885
|
fields,
|
|
71853
71886
|
variables,
|
|
71854
71887
|
linkedList,
|
|
71855
|
-
stepsFromConnection
|
|
71888
|
+
stepsFromConnection,
|
|
71889
|
+
ignoreMasking
|
|
71856
71890
|
}) {
|
|
71857
71891
|
const result = [];
|
|
71858
71892
|
let partialData = false;
|
|
@@ -71864,7 +71898,8 @@ var CacheInternal = class {
|
|
|
71864
71898
|
fields,
|
|
71865
71899
|
variables,
|
|
71866
71900
|
linkedList: entry,
|
|
71867
|
-
stepsFromConnection
|
|
71901
|
+
stepsFromConnection,
|
|
71902
|
+
ignoreMasking
|
|
71868
71903
|
});
|
|
71869
71904
|
result.push(nestedValue.data);
|
|
71870
71905
|
if (nestedValue.partial) {
|
|
@@ -71885,7 +71920,8 @@ var CacheInternal = class {
|
|
|
71885
71920
|
parent: entry,
|
|
71886
71921
|
selection: fields,
|
|
71887
71922
|
variables,
|
|
71888
|
-
stepsFromConnection
|
|
71923
|
+
stepsFromConnection,
|
|
71924
|
+
ignoreMasking
|
|
71889
71925
|
});
|
|
71890
71926
|
result.push(data);
|
|
71891
71927
|
if (partial) {
|
|
@@ -71988,11 +72024,54 @@ var CacheInternal = class {
|
|
|
71988
72024
|
}
|
|
71989
72025
|
}
|
|
71990
72026
|
};
|
|
72027
|
+
function evaluateFragmentVariables(variables, args) {
|
|
72028
|
+
return Object.fromEntries(
|
|
72029
|
+
Object.entries(variables).map(([key, value]) => [key, fragmentVariableValue(value, args)])
|
|
72030
|
+
);
|
|
72031
|
+
}
|
|
72032
|
+
function fragmentVariableValue(value, args) {
|
|
72033
|
+
if (value.kind === "StringValue") {
|
|
72034
|
+
return value.value;
|
|
72035
|
+
}
|
|
72036
|
+
if (value.kind === "BooleanValue") {
|
|
72037
|
+
return value.value;
|
|
72038
|
+
}
|
|
72039
|
+
if (value.kind === "EnumValue") {
|
|
72040
|
+
return value.value;
|
|
72041
|
+
}
|
|
72042
|
+
if (value.kind === "FloatValue") {
|
|
72043
|
+
return parseFloat(value.value);
|
|
72044
|
+
}
|
|
72045
|
+
if (value.kind === "IntValue") {
|
|
72046
|
+
return parseInt(value.value, 10);
|
|
72047
|
+
}
|
|
72048
|
+
if (value.kind === "NullValue") {
|
|
72049
|
+
return null;
|
|
72050
|
+
}
|
|
72051
|
+
if (value.kind === "Variable") {
|
|
72052
|
+
return args[value.name.value];
|
|
72053
|
+
}
|
|
72054
|
+
if (value.kind === "ListValue") {
|
|
72055
|
+
return value.values.map((value2) => fragmentVariableValue(value2, args));
|
|
72056
|
+
}
|
|
72057
|
+
if (value.kind === "ObjectValue") {
|
|
72058
|
+
return value.fields.reduce(
|
|
72059
|
+
(obj, field) => ({
|
|
72060
|
+
...obj,
|
|
72061
|
+
[field.name.value]: fragmentVariableValue(field.value, args)
|
|
72062
|
+
}),
|
|
72063
|
+
{}
|
|
72064
|
+
);
|
|
72065
|
+
}
|
|
72066
|
+
}
|
|
71991
72067
|
var rootID = "_ROOT_";
|
|
71992
72068
|
|
|
71993
72069
|
// src/runtime/cache/index.ts
|
|
71994
72070
|
var cache_default = new Cache();
|
|
71995
72071
|
|
|
72072
|
+
// src/runtime/client/plugins/cache.ts
|
|
72073
|
+
var serverSide = typeof globalThis.window === "undefined";
|
|
72074
|
+
|
|
71996
72075
|
// src/runtime/client/utils/documentPlugins.ts
|
|
71997
72076
|
var documentPlugin = (kind, source) => {
|
|
71998
72077
|
return () => {
|
|
@@ -72028,7 +72107,6 @@ var documentPlugin = (kind, source) => {
|
|
|
72028
72107
|
var query = documentPlugin(ArtifactKind.Query, function() {
|
|
72029
72108
|
let subscriptionSpec = null;
|
|
72030
72109
|
let lastVariables = null;
|
|
72031
|
-
let artifactName = "";
|
|
72032
72110
|
return {
|
|
72033
72111
|
start(ctx, { next }) {
|
|
72034
72112
|
ctx.variables = {
|
|
@@ -72038,8 +72116,7 @@ var query = documentPlugin(ArtifactKind.Query, function() {
|
|
|
72038
72116
|
next(ctx);
|
|
72039
72117
|
},
|
|
72040
72118
|
end(ctx, { resolve: resolve2, marshalVariables, variablesChanged }) {
|
|
72041
|
-
if (variablesChanged(ctx)) {
|
|
72042
|
-
artifactName = ctx.artifact.name;
|
|
72119
|
+
if (variablesChanged(ctx) && !ctx.cacheParams?.disableSubscriptions) {
|
|
72043
72120
|
if (subscriptionSpec) {
|
|
72044
72121
|
cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.() || {});
|
|
72045
72122
|
}
|
|
@@ -72060,19 +72137,61 @@ var query = documentPlugin(ArtifactKind.Query, function() {
|
|
|
72060
72137
|
});
|
|
72061
72138
|
}
|
|
72062
72139
|
};
|
|
72063
|
-
cache_default.subscribe(subscriptionSpec, lastVariables
|
|
72140
|
+
cache_default.subscribe(subscriptionSpec, lastVariables);
|
|
72064
72141
|
}
|
|
72065
72142
|
resolve2(ctx);
|
|
72066
72143
|
},
|
|
72067
72144
|
cleanup() {
|
|
72068
72145
|
if (subscriptionSpec) {
|
|
72069
|
-
cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.()
|
|
72146
|
+
cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.());
|
|
72070
72147
|
lastVariables = null;
|
|
72071
72148
|
}
|
|
72072
72149
|
}
|
|
72073
72150
|
};
|
|
72074
72151
|
});
|
|
72075
72152
|
|
|
72153
|
+
// src/runtime/client/plugins/fragment.ts
|
|
72154
|
+
var fragment = documentPlugin(ArtifactKind.Fragment, function() {
|
|
72155
|
+
let subscriptionSpec = null;
|
|
72156
|
+
return {
|
|
72157
|
+
start(ctx, { next, resolve: resolve2, variablesChanged, marshalVariables }) {
|
|
72158
|
+
if (!ctx.stuff.parentID) {
|
|
72159
|
+
return next(ctx);
|
|
72160
|
+
}
|
|
72161
|
+
if (variablesChanged(ctx) && !ctx.cacheParams?.disableSubscriptions) {
|
|
72162
|
+
if (subscriptionSpec) {
|
|
72163
|
+
cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.() || {});
|
|
72164
|
+
}
|
|
72165
|
+
const variables = marshalVariables(ctx);
|
|
72166
|
+
subscriptionSpec = {
|
|
72167
|
+
rootType: ctx.artifact.rootType,
|
|
72168
|
+
selection: ctx.artifact.selection,
|
|
72169
|
+
variables: () => variables,
|
|
72170
|
+
parentID: ctx.stuff.parentID,
|
|
72171
|
+
set: (newValue) => {
|
|
72172
|
+
resolve2(ctx, {
|
|
72173
|
+
data: newValue,
|
|
72174
|
+
errors: null,
|
|
72175
|
+
fetching: false,
|
|
72176
|
+
partial: false,
|
|
72177
|
+
stale: false,
|
|
72178
|
+
source: DataSource.Cache,
|
|
72179
|
+
variables
|
|
72180
|
+
});
|
|
72181
|
+
}
|
|
72182
|
+
};
|
|
72183
|
+
cache_default.subscribe(subscriptionSpec, variables);
|
|
72184
|
+
}
|
|
72185
|
+
next(ctx);
|
|
72186
|
+
},
|
|
72187
|
+
cleanup() {
|
|
72188
|
+
if (subscriptionSpec) {
|
|
72189
|
+
cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.());
|
|
72190
|
+
}
|
|
72191
|
+
}
|
|
72192
|
+
};
|
|
72193
|
+
});
|
|
72194
|
+
|
|
72076
72195
|
// src/runtime/client/plugins/mutation.ts
|
|
72077
72196
|
var mutation = documentPlugin(ArtifactKind.Mutation, () => {
|
|
72078
72197
|
return {
|
|
@@ -72229,6 +72348,7 @@ var Config = class {
|
|
|
72229
72348
|
this.schemaPollInterval = watchSchema?.interval ?? 2e3;
|
|
72230
72349
|
this.schemaPollHeaders = watchSchema?.headers ?? {};
|
|
72231
72350
|
this.rootDir = join2(this.projectRoot, "$houdini");
|
|
72351
|
+
this.#fragmentVariableMaps = {};
|
|
72232
72352
|
if (defaultKeys) {
|
|
72233
72353
|
this.defaultKeys = defaultKeys;
|
|
72234
72354
|
}
|
|
@@ -72378,7 +72498,7 @@ var Config = class {
|
|
|
72378
72498
|
return `$houdini/${this.artifactDirectoryName}/${name}`;
|
|
72379
72499
|
}
|
|
72380
72500
|
keyFieldsForType(type) {
|
|
72381
|
-
return keyFieldsForType(this.configFile, type);
|
|
72501
|
+
return this.schema.getQueryType()?.name === type ? [] : keyFieldsForType(this.configFile, type);
|
|
72382
72502
|
}
|
|
72383
72503
|
computeID(type, data) {
|
|
72384
72504
|
return computeID(this.configFile, type, data);
|
|
@@ -72397,7 +72517,7 @@ var Config = class {
|
|
|
72397
72517
|
({ kind }) => kind === graphql2.Kind.FRAGMENT_DEFINITION
|
|
72398
72518
|
);
|
|
72399
72519
|
if (fragmentDefinitions.length) {
|
|
72400
|
-
return fragmentDefinitions.
|
|
72520
|
+
return fragmentDefinitions[0].name.value;
|
|
72401
72521
|
}
|
|
72402
72522
|
throw new Error("Could not generate artifact name for document: " + graphql2.print(document));
|
|
72403
72523
|
}
|
|
@@ -72569,6 +72689,56 @@ var Config = class {
|
|
|
72569
72689
|
}, []) ?? [];
|
|
72570
72690
|
return !defaultDirectives.includes(name) && (internalDirectives.includes(name) || this.isDeleteDirective(name));
|
|
72571
72691
|
}
|
|
72692
|
+
#fragmentVariableMaps;
|
|
72693
|
+
registerFragmentVariablesHash({
|
|
72694
|
+
hash,
|
|
72695
|
+
args,
|
|
72696
|
+
fragment: fragment2
|
|
72697
|
+
}) {
|
|
72698
|
+
this.#fragmentVariableMaps[hash] = {
|
|
72699
|
+
args: this.#serializeValueMap(args),
|
|
72700
|
+
fragment: fragment2
|
|
72701
|
+
};
|
|
72702
|
+
}
|
|
72703
|
+
getFragmentVariablesHash(hash) {
|
|
72704
|
+
return this.#fragmentVariableMaps[hash] ?? {
|
|
72705
|
+
fragment: hash,
|
|
72706
|
+
args: {},
|
|
72707
|
+
hash
|
|
72708
|
+
};
|
|
72709
|
+
}
|
|
72710
|
+
#serializeValueMap(map) {
|
|
72711
|
+
if (!map) {
|
|
72712
|
+
return null;
|
|
72713
|
+
}
|
|
72714
|
+
return Object.fromEntries(
|
|
72715
|
+
Object.entries(map).map(([key, input]) => {
|
|
72716
|
+
const result = {
|
|
72717
|
+
kind: input.kind
|
|
72718
|
+
};
|
|
72719
|
+
if (typeof input === "object") {
|
|
72720
|
+
if ("value" in input) {
|
|
72721
|
+
result.value = input.value;
|
|
72722
|
+
}
|
|
72723
|
+
if ("values" in input) {
|
|
72724
|
+
result.values = input.values.map(
|
|
72725
|
+
(value) => this.#serializeValueMap({ foo: value }).foo
|
|
72726
|
+
);
|
|
72727
|
+
}
|
|
72728
|
+
if ("name" in input) {
|
|
72729
|
+
result.name = input.name;
|
|
72730
|
+
}
|
|
72731
|
+
if ("fields" in input) {
|
|
72732
|
+
result.fields = input.fields.map((field) => ({
|
|
72733
|
+
name: field.name,
|
|
72734
|
+
value: this.#serializeValueMap({ foo: field.value }).foo
|
|
72735
|
+
}));
|
|
72736
|
+
}
|
|
72737
|
+
}
|
|
72738
|
+
return [key, result];
|
|
72739
|
+
})
|
|
72740
|
+
);
|
|
72741
|
+
}
|
|
72572
72742
|
isListFragment(name) {
|
|
72573
72743
|
return name.endsWith(this.insertFragmentSuffix) || name.endsWith(this.removeFragmentSuffix) || name.endsWith(this.toggleFragmentSuffix);
|
|
72574
72744
|
}
|
|
@@ -73074,11 +73244,17 @@ function deepMerge(filepath, ...targets) {
|
|
|
73074
73244
|
if (targets.length === 1) {
|
|
73075
73245
|
return targets[0];
|
|
73076
73246
|
} else if (targets.length === 2) {
|
|
73077
|
-
return (0, import_deepmerge.default)(targets[0], targets[1]
|
|
73247
|
+
return (0, import_deepmerge.default)(targets[0], targets[1], {
|
|
73248
|
+
arrayMerge: (source, update) => [...new Set(source.concat(update))]
|
|
73249
|
+
});
|
|
73078
73250
|
}
|
|
73079
73251
|
return deepMerge(filepath, targets[0], deepMerge(filepath, ...targets.slice(1)));
|
|
73080
73252
|
} catch (e2) {
|
|
73081
|
-
throw new HoudiniError({
|
|
73253
|
+
throw new HoudiniError({
|
|
73254
|
+
filepath,
|
|
73255
|
+
message: "could not merge: " + targets,
|
|
73256
|
+
description: e2.message
|
|
73257
|
+
});
|
|
73082
73258
|
}
|
|
73083
73259
|
}
|
|
73084
73260
|
|
|
@@ -73360,16 +73536,16 @@ function flattenSelections({
|
|
|
73360
73536
|
filepath,
|
|
73361
73537
|
selections,
|
|
73362
73538
|
fragmentDefinitions,
|
|
73363
|
-
|
|
73364
|
-
|
|
73539
|
+
ignoreMaskDisable,
|
|
73540
|
+
keepFragmentSpreadNodes
|
|
73365
73541
|
}) {
|
|
73366
73542
|
const fields = new FieldCollection({
|
|
73367
73543
|
config: config2,
|
|
73368
73544
|
filepath,
|
|
73369
73545
|
selections,
|
|
73370
73546
|
fragmentDefinitions,
|
|
73371
|
-
|
|
73372
|
-
|
|
73547
|
+
ignoreMaskDisable: !!ignoreMaskDisable,
|
|
73548
|
+
keepFragmentSpreadNodes: !!keepFragmentSpreadNodes
|
|
73373
73549
|
});
|
|
73374
73550
|
return fields.toSelectionSet();
|
|
73375
73551
|
}
|
|
@@ -73380,57 +73556,59 @@ var FieldCollection = class {
|
|
|
73380
73556
|
fields;
|
|
73381
73557
|
inlineFragments;
|
|
73382
73558
|
fragmentSpreads;
|
|
73383
|
-
applyFragments;
|
|
73384
73559
|
ignoreMaskDisable;
|
|
73560
|
+
keepFragmentSpreadNodes;
|
|
73385
73561
|
constructor(args) {
|
|
73386
73562
|
this.config = args.config;
|
|
73387
73563
|
this.fragmentDefinitions = args.fragmentDefinitions;
|
|
73388
|
-
this.applyFragments = args.applyFragments;
|
|
73389
73564
|
this.ignoreMaskDisable = args.ignoreMaskDisable;
|
|
73565
|
+
this.keepFragmentSpreadNodes = args.keepFragmentSpreadNodes;
|
|
73390
73566
|
this.fields = {};
|
|
73391
73567
|
this.inlineFragments = {};
|
|
73392
73568
|
this.fragmentSpreads = {};
|
|
73393
73569
|
this.filepath = args.filepath;
|
|
73394
|
-
for (const
|
|
73395
|
-
this.add(
|
|
73570
|
+
for (const selection of args.selections) {
|
|
73571
|
+
this.add(selection);
|
|
73396
73572
|
}
|
|
73397
73573
|
}
|
|
73398
73574
|
get size() {
|
|
73399
73575
|
return Object.keys(this.fields).length + Object.keys(this.inlineFragments).length + Object.keys(this.fragmentSpreads).length;
|
|
73400
73576
|
}
|
|
73401
|
-
add(
|
|
73402
|
-
if (
|
|
73403
|
-
const key =
|
|
73577
|
+
add(selection) {
|
|
73578
|
+
if (selection.kind === "Field") {
|
|
73579
|
+
const key = selection.alias?.value || selection.name.value;
|
|
73404
73580
|
if (!this.fields[key]) {
|
|
73405
73581
|
this.fields[key] = {
|
|
73406
|
-
astNode:
|
|
73582
|
+
astNode: selection,
|
|
73407
73583
|
selection: this.empty()
|
|
73408
73584
|
};
|
|
73409
73585
|
}
|
|
73410
|
-
for (const subselect of
|
|
73586
|
+
for (const subselect of selection.selectionSet?.selections || []) {
|
|
73411
73587
|
this.fields[key].selection.add(subselect);
|
|
73412
73588
|
}
|
|
73589
|
+
this.fields[key].selection.fragmentSpreads = this.collectFragmentSpreads(
|
|
73590
|
+
selection.selectionSet?.selections ?? []
|
|
73591
|
+
);
|
|
73413
73592
|
return;
|
|
73414
73593
|
}
|
|
73415
|
-
if (
|
|
73416
|
-
for (const subselect of
|
|
73594
|
+
if (selection.kind === "InlineFragment" && !selection.typeCondition) {
|
|
73595
|
+
for (const subselect of selection.selectionSet.selections) {
|
|
73417
73596
|
this.add(subselect);
|
|
73418
73597
|
}
|
|
73419
73598
|
}
|
|
73420
|
-
if (
|
|
73421
|
-
this.walkInlineFragment(
|
|
73599
|
+
if (selection.kind === "InlineFragment" && selection.typeCondition) {
|
|
73600
|
+
this.walkInlineFragment(selection);
|
|
73422
73601
|
return;
|
|
73423
73602
|
}
|
|
73424
|
-
if (
|
|
73425
|
-
this.fragmentSpreads[selection2.name.value] = selection2;
|
|
73603
|
+
if (selection.kind === "FragmentSpread") {
|
|
73426
73604
|
let includeFragments = this.config.defaultFragmentMasking === "disable";
|
|
73427
|
-
const maskEnableDirective =
|
|
73605
|
+
const maskEnableDirective = selection.directives?.find(
|
|
73428
73606
|
({ name }) => name.value === this.config.maskEnableDirective
|
|
73429
73607
|
);
|
|
73430
73608
|
if (maskEnableDirective) {
|
|
73431
73609
|
includeFragments = false;
|
|
73432
73610
|
}
|
|
73433
|
-
const maskDisableDirective =
|
|
73611
|
+
const maskDisableDirective = selection.directives?.find(
|
|
73434
73612
|
({ name }) => name.value === this.config.maskDisableDirective
|
|
73435
73613
|
);
|
|
73436
73614
|
if (maskDisableDirective) {
|
|
@@ -73439,14 +73617,17 @@ var FieldCollection = class {
|
|
|
73439
73617
|
if (this.ignoreMaskDisable) {
|
|
73440
73618
|
includeFragments = true;
|
|
73441
73619
|
}
|
|
73442
|
-
if (
|
|
73620
|
+
if (this.keepFragmentSpreadNodes) {
|
|
73621
|
+
this.fragmentSpreads[selection.name.value] = selection;
|
|
73622
|
+
}
|
|
73623
|
+
if (!includeFragments) {
|
|
73443
73624
|
return;
|
|
73444
73625
|
}
|
|
73445
|
-
const definition = this.fragmentDefinitions[
|
|
73626
|
+
const definition = this.fragmentDefinitions[selection.name.value];
|
|
73446
73627
|
if (!definition) {
|
|
73447
73628
|
throw new HoudiniError({
|
|
73448
73629
|
filepath: this.filepath,
|
|
73449
|
-
message: "Could not find referenced fragment definition: " +
|
|
73630
|
+
message: "Could not find referenced fragment definition: " + selection.name.value + "\n" + JSON.stringify(Object.keys(this.fragmentDefinitions), null, 4)
|
|
73450
73631
|
});
|
|
73451
73632
|
}
|
|
73452
73633
|
this.add({
|
|
@@ -73465,19 +73646,35 @@ var FieldCollection = class {
|
|
|
73465
73646
|
});
|
|
73466
73647
|
}
|
|
73467
73648
|
}
|
|
73649
|
+
collectFragmentSpreads(selections, result = {}) {
|
|
73650
|
+
for (const selection of selections) {
|
|
73651
|
+
if (selection.kind === "Field") {
|
|
73652
|
+
continue;
|
|
73653
|
+
}
|
|
73654
|
+
if (selection.kind === "InlineFragment") {
|
|
73655
|
+
this.collectFragmentSpreads(selection.selectionSet.selections, result);
|
|
73656
|
+
continue;
|
|
73657
|
+
}
|
|
73658
|
+
if (selection.kind === "FragmentSpread") {
|
|
73659
|
+
result[selection.name.value] = selection;
|
|
73660
|
+
continue;
|
|
73661
|
+
}
|
|
73662
|
+
}
|
|
73663
|
+
return result;
|
|
73664
|
+
}
|
|
73468
73665
|
toSelectionSet() {
|
|
73469
|
-
return Object.values(this.inlineFragments).flatMap((
|
|
73470
|
-
if (
|
|
73666
|
+
return Object.values(this.inlineFragments).flatMap((fragment2) => {
|
|
73667
|
+
if (fragment2.selection.size === 0) {
|
|
73471
73668
|
return [];
|
|
73472
73669
|
}
|
|
73473
|
-
|
|
73474
|
-
...
|
|
73670
|
+
fragment2.astNode = {
|
|
73671
|
+
...fragment2.astNode,
|
|
73475
73672
|
selectionSet: {
|
|
73476
|
-
...
|
|
73477
|
-
selections:
|
|
73673
|
+
...fragment2.astNode.selectionSet,
|
|
73674
|
+
selections: fragment2.selection.toSelectionSet()
|
|
73478
73675
|
}
|
|
73479
73676
|
};
|
|
73480
|
-
return [
|
|
73677
|
+
return [fragment2.astNode];
|
|
73481
73678
|
}).concat(
|
|
73482
73679
|
Object.values(this.fields).map((field) => {
|
|
73483
73680
|
if (field.astNode.selectionSet) {
|
|
@@ -73487,15 +73684,15 @@ var FieldCollection = class {
|
|
|
73487
73684
|
})
|
|
73488
73685
|
).concat(Object.values(this.fragmentSpreads));
|
|
73489
73686
|
}
|
|
73490
|
-
walkInlineFragment(
|
|
73491
|
-
const key =
|
|
73687
|
+
walkInlineFragment(selection) {
|
|
73688
|
+
const key = selection.typeCondition.name.value;
|
|
73492
73689
|
if (!this.inlineFragments[key]) {
|
|
73493
73690
|
this.inlineFragments[key] = {
|
|
73494
|
-
astNode:
|
|
73691
|
+
astNode: selection,
|
|
73495
73692
|
selection: this.empty()
|
|
73496
73693
|
};
|
|
73497
73694
|
}
|
|
73498
|
-
for (const subselect of
|
|
73695
|
+
for (const subselect of selection.selectionSet.selections || []) {
|
|
73499
73696
|
if (subselect.kind !== "InlineFragment" || !subselect.typeCondition) {
|
|
73500
73697
|
this.inlineFragments[key].selection.add(subselect);
|
|
73501
73698
|
continue;
|
|
@@ -73509,8 +73706,8 @@ var FieldCollection = class {
|
|
|
73509
73706
|
fragmentDefinitions: this.fragmentDefinitions,
|
|
73510
73707
|
selections: [],
|
|
73511
73708
|
filepath: this.filepath,
|
|
73512
|
-
|
|
73513
|
-
|
|
73709
|
+
ignoreMaskDisable: this.ignoreMaskDisable,
|
|
73710
|
+
keepFragmentSpreadNodes: this.keepFragmentSpreadNodes
|
|
73514
73711
|
});
|
|
73515
73712
|
}
|
|
73516
73713
|
};
|
|
@@ -73588,13 +73785,13 @@ function murmurHash(str) {
|
|
|
73588
73785
|
// src/codegen/transforms/fragmentVariables.ts
|
|
73589
73786
|
var graphql5 = __toESM(require_graphql2(), 1);
|
|
73590
73787
|
|
|
73591
|
-
// src/codegen/transforms/
|
|
73788
|
+
// src/codegen/transforms/collectDefinitions.ts
|
|
73592
73789
|
var import_graphql30 = __toESM(require_graphql2(), 1);
|
|
73593
73790
|
async function includeFragmentDefinitions(config2, documents) {
|
|
73594
|
-
const fragments =
|
|
73791
|
+
const fragments = collectDefinitions(config2, documents);
|
|
73595
73792
|
for (const [index, { name, document, filename }] of documents.entries()) {
|
|
73596
73793
|
const operation = document.definitions.find(
|
|
73597
|
-
(
|
|
73794
|
+
(def) => def.kind === import_graphql30.Kind.OPERATION_DEFINITION || def.kind === "FragmentDefinition"
|
|
73598
73795
|
);
|
|
73599
73796
|
if (!operation) {
|
|
73600
73797
|
continue;
|
|
@@ -73613,7 +73810,7 @@ async function includeFragmentDefinitions(config2, documents) {
|
|
|
73613
73810
|
};
|
|
73614
73811
|
}
|
|
73615
73812
|
}
|
|
73616
|
-
function
|
|
73813
|
+
function collectDefinitions(config2, docs) {
|
|
73617
73814
|
return docs.reduce((acc, doc) => {
|
|
73618
73815
|
const definitions = doc.document.definitions.reduce(
|
|
73619
73816
|
(prev, definition) => definition.kind !== "FragmentDefinition" ? prev : {
|
|
@@ -73637,11 +73834,11 @@ function findRequiredFragments(selectionSet) {
|
|
|
73637
73834
|
return [];
|
|
73638
73835
|
}
|
|
73639
73836
|
const referencedFragments = [];
|
|
73640
|
-
for (const
|
|
73641
|
-
if (
|
|
73642
|
-
referencedFragments.push(
|
|
73643
|
-
} else if (
|
|
73644
|
-
referencedFragments.push(...findRequiredFragments(
|
|
73837
|
+
for (const selection of selectionSet.selections) {
|
|
73838
|
+
if (selection.kind === import_graphql30.Kind.FRAGMENT_SPREAD) {
|
|
73839
|
+
referencedFragments.push(selection.name.value);
|
|
73840
|
+
} else if (selection.selectionSet) {
|
|
73841
|
+
referencedFragments.push(...findRequiredFragments(selection.selectionSet));
|
|
73645
73842
|
}
|
|
73646
73843
|
}
|
|
73647
73844
|
return referencedFragments;
|
|
@@ -73674,7 +73871,7 @@ function flattenFragments(filepath, operation, fragments) {
|
|
|
73674
73871
|
// src/codegen/transforms/fragmentVariables.ts
|
|
73675
73872
|
var GraphqlKinds2 = graphql5.Kind;
|
|
73676
73873
|
async function fragmentVariables(config2, documents) {
|
|
73677
|
-
const fragments =
|
|
73874
|
+
const fragments = collectDefinitions(config2, documents);
|
|
73678
73875
|
const generatedFragments = {};
|
|
73679
73876
|
const visitedFragments = /* @__PURE__ */ new Set();
|
|
73680
73877
|
for (const doc2 of documents) {
|
|
@@ -73734,9 +73931,17 @@ function inlineFragmentArgs({
|
|
|
73734
73931
|
).reduce((acc, arg) => ({ ...acc, [arg.name]: arg }), {});
|
|
73735
73932
|
const result = graphql5.visit(document, {
|
|
73736
73933
|
FragmentSpread(node) {
|
|
73934
|
+
if (!fragmentDefinitions[node.name.value]) {
|
|
73935
|
+
throw new Error("Could not find definition for fragment" + node.name.value);
|
|
73936
|
+
}
|
|
73737
73937
|
const { definition } = fragmentDefinitions[node.name.value];
|
|
73738
73938
|
let { args, hash } = collectWithArguments(config2, filepath, node, scope);
|
|
73739
73939
|
const newFragmentName = `${node.name.value}${hash}`;
|
|
73940
|
+
config2.registerFragmentVariablesHash({
|
|
73941
|
+
hash: newFragmentName,
|
|
73942
|
+
fragment: node.name.value,
|
|
73943
|
+
args
|
|
73944
|
+
});
|
|
73740
73945
|
if (!visitedFragments.has(newFragmentName)) {
|
|
73741
73946
|
visitedFragments.add(newFragmentName);
|
|
73742
73947
|
const defaultArguments = collectDefaultArgumentValues(config2, filepath, definition);
|
|
@@ -74135,7 +74340,7 @@ function operationObject({
|
|
|
74135
74340
|
listName,
|
|
74136
74341
|
operationKind,
|
|
74137
74342
|
type,
|
|
74138
|
-
selection
|
|
74343
|
+
selection,
|
|
74139
74344
|
filepath
|
|
74140
74345
|
}) {
|
|
74141
74346
|
let parentID;
|
|
@@ -74143,7 +74348,7 @@ function operationObject({
|
|
|
74143
74348
|
let position = config2.internalListPosition;
|
|
74144
74349
|
let allLists = config2.defaultListTarget ?? void 0;
|
|
74145
74350
|
let operationWhen;
|
|
74146
|
-
const internalDirectives =
|
|
74351
|
+
const internalDirectives = selection.directives?.filter(
|
|
74147
74352
|
(directive) => config2.isInternalDirective(directive.name.value)
|
|
74148
74353
|
);
|
|
74149
74354
|
if (internalDirectives && internalDirectives.length > 0) {
|
|
@@ -74379,7 +74584,7 @@ async function paginate(config2, documents) {
|
|
|
74379
74584
|
let fragmentName = "";
|
|
74380
74585
|
let refetchQueryName = "";
|
|
74381
74586
|
let nodeQuery = false;
|
|
74382
|
-
let
|
|
74587
|
+
let fragment2 = "";
|
|
74383
74588
|
let paginateMode = config2.defaultPaginateMode;
|
|
74384
74589
|
doc.document = graphql10.visit(doc.document, {
|
|
74385
74590
|
OperationDefinition(node) {
|
|
@@ -74422,7 +74627,7 @@ async function paginate(config2, documents) {
|
|
|
74422
74627
|
};
|
|
74423
74628
|
},
|
|
74424
74629
|
FragmentDefinition(node) {
|
|
74425
|
-
|
|
74630
|
+
fragment2 = node.typeCondition.name.value;
|
|
74426
74631
|
fragmentName = node.name.value;
|
|
74427
74632
|
refetchQueryName = config2.paginationQueryName(fragmentName);
|
|
74428
74633
|
nodeQuery = node.typeCondition.name.value !== config2.schema.getQueryType()?.name;
|
|
@@ -74469,17 +74674,17 @@ async function paginate(config2, documents) {
|
|
|
74469
74674
|
}
|
|
74470
74675
|
});
|
|
74471
74676
|
let targetType = config2.schema.getQueryType()?.name || "";
|
|
74472
|
-
if (
|
|
74677
|
+
if (fragment2) {
|
|
74473
74678
|
const nodeInterface = config2.schema.getType("Node");
|
|
74474
74679
|
if (nodeInterface) {
|
|
74475
74680
|
const { objects, interfaces } = config2.schema.getImplementations(nodeInterface);
|
|
74476
|
-
if (objects.find((obj) => obj.name ===
|
|
74681
|
+
if (objects.find((obj) => obj.name === fragment2) || interfaces.find((int) => int.name === fragment2)) {
|
|
74477
74682
|
targetType = "Node";
|
|
74478
74683
|
} else {
|
|
74479
|
-
targetType =
|
|
74684
|
+
targetType = fragment2;
|
|
74480
74685
|
}
|
|
74481
74686
|
} else {
|
|
74482
|
-
targetType =
|
|
74687
|
+
targetType = fragment2;
|
|
74483
74688
|
}
|
|
74484
74689
|
}
|
|
74485
74690
|
const pageSize = flags.first.defaultValue ?? flags.last.defaultValue ?? flags.limit.defaultValue;
|
|
@@ -74501,7 +74706,7 @@ async function paginate(config2, documents) {
|
|
|
74501
74706
|
start,
|
|
74502
74707
|
mode: paginateMode
|
|
74503
74708
|
};
|
|
74504
|
-
if (!
|
|
74709
|
+
if (!fragment2) {
|
|
74505
74710
|
continue;
|
|
74506
74711
|
}
|
|
74507
74712
|
const paginationArgs = Object.entries(flags).filter(([_, { enabled }]) => enabled).map(([key, value]) => ({ name: key, ...value }));
|
|
@@ -74522,15 +74727,22 @@ async function paginate(config2, documents) {
|
|
|
74522
74727
|
["arguments"]: paginationArgs.map(
|
|
74523
74728
|
({ name }) => variableAsArgument(name)
|
|
74524
74729
|
)
|
|
74730
|
+
},
|
|
74731
|
+
{
|
|
74732
|
+
kind: graphql10.Kind.DIRECTIVE,
|
|
74733
|
+
name: {
|
|
74734
|
+
kind: "Name",
|
|
74735
|
+
value: config2.maskDisableDirective
|
|
74736
|
+
}
|
|
74525
74737
|
}
|
|
74526
74738
|
]
|
|
74527
74739
|
}
|
|
74528
74740
|
];
|
|
74529
|
-
const keys = config2.keyFieldsForType(!nodeQuery ? config2.schema.getQueryType()?.name || "" :
|
|
74530
|
-
if (
|
|
74741
|
+
const keys = config2.keyFieldsForType(!nodeQuery ? config2.schema.getQueryType()?.name || "" : fragment2).flatMap((key) => {
|
|
74742
|
+
if (fragment2 === config2.schema.getQueryType()?.name) {
|
|
74531
74743
|
return [];
|
|
74532
74744
|
}
|
|
74533
|
-
const fragmentType = config2.schema.getType(
|
|
74745
|
+
const fragmentType = config2.schema.getType(fragment2);
|
|
74534
74746
|
const { type, wrappers } = unwrapType(
|
|
74535
74747
|
config2,
|
|
74536
74748
|
fragmentType.getFields()[key].type
|
|
@@ -74542,7 +74754,7 @@ async function paginate(config2, documents) {
|
|
|
74542
74754
|
}
|
|
74543
74755
|
];
|
|
74544
74756
|
});
|
|
74545
|
-
const typeConfig = config2.typeConfig?.[
|
|
74757
|
+
const typeConfig = config2.typeConfig?.[fragment2];
|
|
74546
74758
|
const queryDoc = {
|
|
74547
74759
|
kind: graphql10.Kind.DOCUMENT,
|
|
74548
74760
|
definitions: [
|
|
@@ -74884,7 +75096,7 @@ async function addListFragments(config2, documents) {
|
|
|
74884
75096
|
);
|
|
74885
75097
|
const targetField = ancestors[ancestors.length - 1];
|
|
74886
75098
|
const targetFieldDefinition = parentType.getFields()[targetField.name.value];
|
|
74887
|
-
const { selection
|
|
75099
|
+
const { selection, type, connection } = connectionSelection(
|
|
74888
75100
|
config2,
|
|
74889
75101
|
targetFieldDefinition,
|
|
74890
75102
|
parentTypeFromAncestors(
|
|
@@ -74895,7 +75107,7 @@ async function addListFragments(config2, documents) {
|
|
|
74895
75107
|
ancestors[ancestors.length - 1].selectionSet
|
|
74896
75108
|
);
|
|
74897
75109
|
lists[nameArg.value.value] = {
|
|
74898
|
-
selection
|
|
75110
|
+
selection,
|
|
74899
75111
|
type,
|
|
74900
75112
|
filename: doc.filename
|
|
74901
75113
|
};
|
|
@@ -74973,14 +75185,14 @@ async function addListFragments(config2, documents) {
|
|
|
74973
75185
|
const generatedDoc = {
|
|
74974
75186
|
kind: graphql11.Kind.DOCUMENT,
|
|
74975
75187
|
definitions: Object.entries(lists).flatMap(
|
|
74976
|
-
([name, { selection
|
|
75188
|
+
([name, { selection, type }]) => {
|
|
74977
75189
|
const schemaType = config2.schema.getType(type.name);
|
|
74978
|
-
if (!
|
|
75190
|
+
if (!selection) {
|
|
74979
75191
|
throw new HoudiniError({ message: "Lists must have a selection" });
|
|
74980
75192
|
}
|
|
74981
75193
|
const fragmentSelection = {
|
|
74982
75194
|
kind: graphql11.Kind.SELECTION_SET,
|
|
74983
|
-
selections: [...
|
|
75195
|
+
selections: [...selection.selections]
|
|
74984
75196
|
};
|
|
74985
75197
|
if (schemaType && fragmentSelection && !fragmentSelection?.selections.find(
|
|
74986
75198
|
(field) => field.kind === "Field" && config2.keyFieldsForType(type.name).includes(field.name.value)
|
|
@@ -75072,7 +75284,7 @@ async function addListFragments(config2, documents) {
|
|
|
75072
75284
|
artifact: null
|
|
75073
75285
|
});
|
|
75074
75286
|
}
|
|
75075
|
-
function connectionSelection(config2, field, type,
|
|
75287
|
+
function connectionSelection(config2, field, type, selection) {
|
|
75076
75288
|
const fieldArgs = field.args.reduce(
|
|
75077
75289
|
(args, arg) => ({
|
|
75078
75290
|
...args,
|
|
@@ -75081,34 +75293,34 @@ function connectionSelection(config2, field, type, selection2) {
|
|
|
75081
75293
|
{}
|
|
75082
75294
|
);
|
|
75083
75295
|
if (fieldArgs["limit"]) {
|
|
75084
|
-
return { selection
|
|
75296
|
+
return { selection, type, connection: false, error: null };
|
|
75085
75297
|
}
|
|
75086
75298
|
const forwardPagination = fieldArgs["first"] === "Int" && ["Cursor", "String"].includes(fieldArgs["after"]);
|
|
75087
75299
|
const backwardsPagination = fieldArgs["last"] === "Int" && ["Cursor", "String"].includes(fieldArgs["before"]);
|
|
75088
75300
|
if (!forwardPagination && !backwardsPagination) {
|
|
75089
|
-
return { selection
|
|
75301
|
+
return { selection, type, connection: false, error: missingPaginationArgMessage(config2) };
|
|
75090
75302
|
}
|
|
75091
|
-
const edgesField =
|
|
75092
|
-
(
|
|
75303
|
+
const edgesField = selection?.selections.find(
|
|
75304
|
+
(selection2) => selection2.kind === "Field" && selection2.name.value === "edges"
|
|
75093
75305
|
);
|
|
75094
75306
|
if (!edgesField) {
|
|
75095
|
-
return { selection
|
|
75307
|
+
return { selection, type, connection: false, error: missingEdgeSelectionMessage(config2) };
|
|
75096
75308
|
}
|
|
75097
75309
|
const nodeSelection = edgesField.selectionSet?.selections.find(
|
|
75098
|
-
(
|
|
75310
|
+
(selection2) => selection2.kind === "Field" && selection2.name.value === "node"
|
|
75099
75311
|
);
|
|
75100
75312
|
if (!nodeSelection.selectionSet) {
|
|
75101
|
-
return { selection
|
|
75313
|
+
return { selection, type, connection: false, error: missingNodeSelectionMessage(config2) };
|
|
75102
75314
|
}
|
|
75103
75315
|
const edgeField = unwrapType(config2, field.type).type.getFields()["edges"];
|
|
75104
75316
|
const { wrappers, type: edgeFieldType } = unwrapType(config2, edgeField.type);
|
|
75105
75317
|
const list = wrappers[wrappers.length - 2] === "List" /* List */;
|
|
75106
75318
|
if (!list) {
|
|
75107
|
-
return { selection
|
|
75319
|
+
return { selection, type, connection: false, error: edgeInvalidTypeMessage(config2) };
|
|
75108
75320
|
}
|
|
75109
75321
|
const nodeField = edgeFieldType.getFields()["node"];
|
|
75110
75322
|
if (!nodeField) {
|
|
75111
|
-
return { selection
|
|
75323
|
+
return { selection, type, connection: false, error: nodeNotDefinedMessage(config2) };
|
|
75112
75324
|
}
|
|
75113
75325
|
return {
|
|
75114
75326
|
selection: nodeSelection.selectionSet,
|
|
@@ -75187,59 +75399,45 @@ function fieldKey(config2, field) {
|
|
|
75187
75399
|
}
|
|
75188
75400
|
|
|
75189
75401
|
// src/codegen/generators/artifacts/selection.ts
|
|
75190
|
-
function
|
|
75402
|
+
function selection_default(args) {
|
|
75403
|
+
const typeMap = {};
|
|
75404
|
+
const abstractTypes = [];
|
|
75405
|
+
return mergeSelection({
|
|
75406
|
+
object: prepareSelection({ ...args, typeMap, abstractTypes }),
|
|
75407
|
+
filepath: args.filepath,
|
|
75408
|
+
typeMap,
|
|
75409
|
+
abstractTypes
|
|
75410
|
+
});
|
|
75411
|
+
}
|
|
75412
|
+
function prepareSelection({
|
|
75191
75413
|
config: config2,
|
|
75192
75414
|
filepath,
|
|
75193
75415
|
rootType,
|
|
75194
75416
|
selections,
|
|
75195
75417
|
operations,
|
|
75196
75418
|
path: path2 = [],
|
|
75197
|
-
includeFragments,
|
|
75198
75419
|
document,
|
|
75199
|
-
inConnection
|
|
75420
|
+
inConnection,
|
|
75421
|
+
typeMap,
|
|
75422
|
+
abstractTypes
|
|
75200
75423
|
}) {
|
|
75201
75424
|
let object = {};
|
|
75202
|
-
const typeMap = {};
|
|
75203
|
-
const abstractTypes = [];
|
|
75204
75425
|
for (const field of selections) {
|
|
75205
|
-
if (field.kind === "
|
|
75206
|
-
const fragmentDefinition = document.document.definitions.find(
|
|
75207
|
-
(defn) => defn.kind === "FragmentDefinition" && defn.name.value === field.name.value
|
|
75208
|
-
);
|
|
75209
|
-
if (!fragmentDefinition) {
|
|
75210
|
-
throw new HoudiniError({
|
|
75211
|
-
filepath,
|
|
75212
|
-
message: "selection: could not find definition for fragment " + field.name.value
|
|
75213
|
-
});
|
|
75214
|
-
}
|
|
75215
|
-
object = deepMerge(
|
|
75216
|
-
filepath,
|
|
75217
|
-
object,
|
|
75218
|
-
selection({
|
|
75219
|
-
config: config2,
|
|
75220
|
-
filepath,
|
|
75221
|
-
rootType: fragmentDefinition.typeCondition.name.value,
|
|
75222
|
-
operations,
|
|
75223
|
-
selections: fragmentDefinition.selectionSet.selections,
|
|
75224
|
-
path: path2,
|
|
75225
|
-
includeFragments,
|
|
75226
|
-
document
|
|
75227
|
-
})
|
|
75228
|
-
);
|
|
75229
|
-
} else if (field.kind === "InlineFragment") {
|
|
75426
|
+
if (field.kind === "InlineFragment") {
|
|
75230
75427
|
if (!field.typeCondition || field.typeCondition.name.value === rootType) {
|
|
75231
75428
|
object.fields = deepMerge(
|
|
75232
75429
|
filepath,
|
|
75233
75430
|
object.fields || {},
|
|
75234
|
-
|
|
75431
|
+
prepareSelection({
|
|
75235
75432
|
config: config2,
|
|
75236
75433
|
filepath,
|
|
75237
75434
|
rootType: field.typeCondition?.name.value || rootType,
|
|
75238
75435
|
operations,
|
|
75239
75436
|
selections: field.selectionSet.selections,
|
|
75240
75437
|
path: path2,
|
|
75241
|
-
|
|
75242
|
-
|
|
75438
|
+
document,
|
|
75439
|
+
typeMap,
|
|
75440
|
+
abstractTypes
|
|
75243
75441
|
}).fields || {}
|
|
75244
75442
|
);
|
|
75245
75443
|
} else {
|
|
@@ -75277,15 +75475,16 @@ function selection({
|
|
|
75277
75475
|
}
|
|
75278
75476
|
object.abstractFields.fields = {
|
|
75279
75477
|
...object.abstractFields.fields,
|
|
75280
|
-
[field.typeCondition.name.value]:
|
|
75478
|
+
[field.typeCondition.name.value]: prepareSelection({
|
|
75281
75479
|
config: config2,
|
|
75282
75480
|
filepath,
|
|
75283
75481
|
rootType: field.typeCondition?.name.value || rootType,
|
|
75284
75482
|
operations,
|
|
75285
75483
|
selections: field.selectionSet.selections,
|
|
75286
75484
|
path: path2,
|
|
75287
|
-
|
|
75288
|
-
|
|
75485
|
+
document,
|
|
75486
|
+
typeMap,
|
|
75487
|
+
abstractTypes
|
|
75289
75488
|
}).fields
|
|
75290
75489
|
};
|
|
75291
75490
|
}
|
|
@@ -75306,10 +75505,14 @@ function selection({
|
|
|
75306
75505
|
}
|
|
75307
75506
|
const typeName = fieldType.toString();
|
|
75308
75507
|
const pathSoFar = path2.concat(attributeName);
|
|
75309
|
-
const
|
|
75508
|
+
const keys = config2.keyFieldsForType(rootType);
|
|
75509
|
+
let fieldObj = {
|
|
75310
75510
|
type: typeName,
|
|
75311
75511
|
keyRaw: fieldKey(config2, field)
|
|
75312
75512
|
};
|
|
75513
|
+
if (keys.includes(field.name.value)) {
|
|
75514
|
+
fieldObj.visible = true;
|
|
75515
|
+
}
|
|
75313
75516
|
if (nullable) {
|
|
75314
75517
|
fieldObj.nullable = true;
|
|
75315
75518
|
}
|
|
@@ -75357,16 +75560,17 @@ function selection({
|
|
|
75357
75560
|
}
|
|
75358
75561
|
if (field.selectionSet) {
|
|
75359
75562
|
const connectionState = paginated && document.refetch?.method === "cursor" || continueConnection;
|
|
75360
|
-
fieldObj.selection =
|
|
75563
|
+
fieldObj.selection = prepareSelection({
|
|
75361
75564
|
config: config2,
|
|
75362
75565
|
filepath,
|
|
75363
75566
|
rootType: typeName,
|
|
75364
75567
|
selections: field.selectionSet.selections,
|
|
75365
75568
|
operations,
|
|
75366
75569
|
path: pathSoFar,
|
|
75367
|
-
includeFragments,
|
|
75368
75570
|
document,
|
|
75369
|
-
inConnection: connectionState
|
|
75571
|
+
inConnection: connectionState,
|
|
75572
|
+
typeMap,
|
|
75573
|
+
abstractTypes
|
|
75370
75574
|
});
|
|
75371
75575
|
}
|
|
75372
75576
|
if (field.arguments?.length && fieldObj.list) {
|
|
@@ -75381,12 +75585,29 @@ function selection({
|
|
|
75381
75585
|
if (graphql13.isInterfaceType(fieldType) || graphql13.isUnionType(fieldType)) {
|
|
75382
75586
|
fieldObj.abstract = true;
|
|
75383
75587
|
}
|
|
75588
|
+
if (object.fields?.[attributeName]) {
|
|
75589
|
+
fieldObj = deepMerge(filepath, object.fields[attributeName], fieldObj);
|
|
75590
|
+
}
|
|
75384
75591
|
object.fields = {
|
|
75385
75592
|
...object.fields,
|
|
75386
75593
|
[attributeName]: fieldObj
|
|
75387
75594
|
};
|
|
75595
|
+
} else if (field.kind === "FragmentSpread") {
|
|
75596
|
+
const { fragment: fragment2, args } = config2.getFragmentVariablesHash(field.name.value);
|
|
75597
|
+
object.fragments = {
|
|
75598
|
+
...object.fragments,
|
|
75599
|
+
[fragment2]: args ?? {}
|
|
75600
|
+
};
|
|
75388
75601
|
}
|
|
75389
75602
|
}
|
|
75603
|
+
return object;
|
|
75604
|
+
}
|
|
75605
|
+
function mergeSelection({
|
|
75606
|
+
filepath,
|
|
75607
|
+
object,
|
|
75608
|
+
typeMap,
|
|
75609
|
+
abstractTypes
|
|
75610
|
+
}) {
|
|
75390
75611
|
if (Object.keys(object.fields || {}).length > 0 && object.abstractFields && Object.keys(object.abstractFields.fields).length > 0) {
|
|
75391
75612
|
for (const [typeName, possibles] of Object.entries(typeMap)) {
|
|
75392
75613
|
let overlap = false;
|
|
@@ -75394,8 +75615,8 @@ function selection({
|
|
|
75394
75615
|
if (object.abstractFields.fields[typeName]) {
|
|
75395
75616
|
object.abstractFields.fields[typeName] = deepMerge(
|
|
75396
75617
|
filepath,
|
|
75397
|
-
object.abstractFields.fields[typeName]
|
|
75398
|
-
object.abstractFields.fields[possible]
|
|
75618
|
+
object.abstractFields.fields[typeName] ?? {},
|
|
75619
|
+
object.abstractFields.fields[possible] ?? {}
|
|
75399
75620
|
);
|
|
75400
75621
|
overlap = true;
|
|
75401
75622
|
}
|
|
@@ -75426,6 +75647,30 @@ function selection({
|
|
|
75426
75647
|
}
|
|
75427
75648
|
}
|
|
75428
75649
|
}
|
|
75650
|
+
for (const [key, value] of Object.entries(object.fields ?? {})) {
|
|
75651
|
+
const selection = value.selection;
|
|
75652
|
+
if (selection) {
|
|
75653
|
+
mergeSelection({
|
|
75654
|
+
filepath,
|
|
75655
|
+
typeMap,
|
|
75656
|
+
abstractTypes,
|
|
75657
|
+
object: selection
|
|
75658
|
+
});
|
|
75659
|
+
}
|
|
75660
|
+
}
|
|
75661
|
+
for (const [type, selection] of Object.entries(object.abstractFields?.fields ?? {})) {
|
|
75662
|
+
for (const [key, value] of Object.entries(selection ?? {})) {
|
|
75663
|
+
const selection2 = value.selection;
|
|
75664
|
+
if (selection2) {
|
|
75665
|
+
mergeSelection({
|
|
75666
|
+
filepath,
|
|
75667
|
+
typeMap,
|
|
75668
|
+
abstractTypes,
|
|
75669
|
+
object: selection2
|
|
75670
|
+
});
|
|
75671
|
+
}
|
|
75672
|
+
}
|
|
75673
|
+
}
|
|
75429
75674
|
return object;
|
|
75430
75675
|
}
|
|
75431
75676
|
|
|
@@ -75490,7 +75735,12 @@ function artifactGenerator(stats) {
|
|
|
75490
75735
|
writeIndexFile(config2, docs)
|
|
75491
75736
|
].concat(
|
|
75492
75737
|
docs.map(async (doc) => {
|
|
75493
|
-
const {
|
|
75738
|
+
const {
|
|
75739
|
+
document,
|
|
75740
|
+
name,
|
|
75741
|
+
generateArtifact,
|
|
75742
|
+
originalParsed
|
|
75743
|
+
} = doc;
|
|
75494
75744
|
if (!generateArtifact) {
|
|
75495
75745
|
return;
|
|
75496
75746
|
}
|
|
@@ -75529,6 +75779,16 @@ function artifactGenerator(stats) {
|
|
|
75529
75779
|
);
|
|
75530
75780
|
let rootType = "";
|
|
75531
75781
|
let selectionSet;
|
|
75782
|
+
let originalSelectionSet = null;
|
|
75783
|
+
const fragmentDefinitions = doc.document.definitions.filter(
|
|
75784
|
+
(definition) => definition.kind === "FragmentDefinition"
|
|
75785
|
+
).reduce(
|
|
75786
|
+
(prev, definition) => ({
|
|
75787
|
+
...prev,
|
|
75788
|
+
[definition.name.value]: definition
|
|
75789
|
+
}),
|
|
75790
|
+
{}
|
|
75791
|
+
);
|
|
75532
75792
|
if (docKind !== ArtifactKind.Fragment) {
|
|
75533
75793
|
const operation = operations[0];
|
|
75534
75794
|
if (operation.operation === "query") {
|
|
@@ -75545,9 +75805,12 @@ function artifactGenerator(stats) {
|
|
|
75545
75805
|
});
|
|
75546
75806
|
}
|
|
75547
75807
|
selectionSet = operation.selectionSet;
|
|
75808
|
+
if (originalParsed.definitions[0].kind === "OperationDefinition") {
|
|
75809
|
+
originalSelectionSet = originalParsed.definitions[0].selectionSet;
|
|
75810
|
+
}
|
|
75548
75811
|
} else {
|
|
75549
75812
|
const matchingFragment = fragments.find(
|
|
75550
|
-
(
|
|
75813
|
+
(fragment2) => fragment2.name.value === name
|
|
75551
75814
|
);
|
|
75552
75815
|
if (!matchingFragment) {
|
|
75553
75816
|
throw new HoudiniError({
|
|
@@ -75557,6 +75820,12 @@ function artifactGenerator(stats) {
|
|
|
75557
75820
|
}
|
|
75558
75821
|
rootType = matchingFragment.typeCondition.name.value;
|
|
75559
75822
|
selectionSet = matchingFragment.selectionSet;
|
|
75823
|
+
if (originalParsed.definitions[0].kind === "FragmentDefinition") {
|
|
75824
|
+
originalSelectionSet = originalParsed.definitions[0].selectionSet;
|
|
75825
|
+
}
|
|
75826
|
+
}
|
|
75827
|
+
if (!originalSelectionSet) {
|
|
75828
|
+
throw new Error("Not original selection set!");
|
|
75560
75829
|
}
|
|
75561
75830
|
let inputs = operations[0]?.variableDefinitions;
|
|
75562
75831
|
let directive = fragments[0]?.directives?.find(
|
|
@@ -75565,21 +75834,18 @@ function artifactGenerator(stats) {
|
|
|
75565
75834
|
if (docKind === ArtifactKind.Fragment && directive) {
|
|
75566
75835
|
inputs = fragmentArgumentsDefinitions(config2, doc.filename, fragments[0]);
|
|
75567
75836
|
}
|
|
75568
|
-
const
|
|
75837
|
+
const mask = selection_default({
|
|
75569
75838
|
config: config2,
|
|
75570
75839
|
filepath: doc.filename,
|
|
75571
|
-
|
|
75572
|
-
|
|
75573
|
-
|
|
75574
|
-
|
|
75575
|
-
|
|
75576
|
-
|
|
75577
|
-
|
|
75578
|
-
|
|
75579
|
-
|
|
75580
|
-
),
|
|
75581
|
-
ignoreMaskDisable: docKind === "HoudiniQuery",
|
|
75582
|
-
applyFragments: docKind !== "HoudiniFragment"
|
|
75840
|
+
rootType,
|
|
75841
|
+
operations: {},
|
|
75842
|
+
document: doc,
|
|
75843
|
+
selections: flattenSelections({
|
|
75844
|
+
config: config2,
|
|
75845
|
+
filepath: doc.filename,
|
|
75846
|
+
selections: selectionSet.selections,
|
|
75847
|
+
fragmentDefinitions
|
|
75848
|
+
})
|
|
75583
75849
|
});
|
|
75584
75850
|
let artifact = {
|
|
75585
75851
|
name,
|
|
@@ -75588,21 +75854,29 @@ function artifactGenerator(stats) {
|
|
|
75588
75854
|
refetch: doc.refetch,
|
|
75589
75855
|
raw: rawString,
|
|
75590
75856
|
rootType,
|
|
75591
|
-
selection:
|
|
75857
|
+
selection: selection_default({
|
|
75592
75858
|
config: config2,
|
|
75593
75859
|
filepath: doc.filename,
|
|
75594
75860
|
rootType,
|
|
75595
|
-
selections:
|
|
75861
|
+
selections: flattenSelections({
|
|
75862
|
+
config: config2,
|
|
75863
|
+
filepath: doc.filename,
|
|
75864
|
+
selections: selectionSet.selections,
|
|
75865
|
+
fragmentDefinitions,
|
|
75866
|
+
ignoreMaskDisable: docKind !== "HoudiniFragment",
|
|
75867
|
+
keepFragmentSpreadNodes: true
|
|
75868
|
+
}),
|
|
75596
75869
|
operations: operationsByPath(
|
|
75597
75870
|
config2,
|
|
75598
75871
|
doc.filename,
|
|
75599
75872
|
operations[0],
|
|
75600
75873
|
filterTypes
|
|
75601
75874
|
),
|
|
75602
|
-
includeFragments: docKind !== "HoudiniFragment",
|
|
75603
75875
|
document: doc
|
|
75604
|
-
})
|
|
75876
|
+
}),
|
|
75877
|
+
pluginData: {}
|
|
75605
75878
|
};
|
|
75879
|
+
applyMask(config2, artifact.selection, mask);
|
|
75606
75880
|
artifact.pluginData = {};
|
|
75607
75881
|
for (const plugin2 of config2.plugins) {
|
|
75608
75882
|
if (!plugin2.artifactData) {
|
|
@@ -75679,6 +75953,49 @@ function artifactGenerator(stats) {
|
|
|
75679
75953
|
stats.deleted = await cleanupFiles(config2.artifactDirectory, listOfArtifacts);
|
|
75680
75954
|
};
|
|
75681
75955
|
}
|
|
75956
|
+
function applyMask(config2, target, mask) {
|
|
75957
|
+
for (const [fieldName, value] of Object.entries(mask.fields ?? {})) {
|
|
75958
|
+
const targetSelection = target.fields?.[fieldName];
|
|
75959
|
+
if (!targetSelection || !mask.fields) {
|
|
75960
|
+
continue;
|
|
75961
|
+
}
|
|
75962
|
+
targetSelection.visible = true;
|
|
75963
|
+
if (targetSelection.selection && value.selection) {
|
|
75964
|
+
applyMask(config2, targetSelection.selection, value.selection);
|
|
75965
|
+
}
|
|
75966
|
+
}
|
|
75967
|
+
for (const [type, selection] of Object.entries(mask.abstractFields?.fields ?? {})) {
|
|
75968
|
+
if (!selection) {
|
|
75969
|
+
continue;
|
|
75970
|
+
}
|
|
75971
|
+
if (target.abstractFields?.fields[type]) {
|
|
75972
|
+
applyMask(config2, { fields: target.abstractFields.fields[type] }, { fields: selection });
|
|
75973
|
+
}
|
|
75974
|
+
const targetType = config2.schema.getType(type);
|
|
75975
|
+
if (!targetType) {
|
|
75976
|
+
continue;
|
|
75977
|
+
}
|
|
75978
|
+
if (graphql14.isAbstractType(targetType)) {
|
|
75979
|
+
for (const possible of config2.schema.getPossibleTypes(targetType)) {
|
|
75980
|
+
if (target.abstractFields?.fields[possible.name]) {
|
|
75981
|
+
applyMask(
|
|
75982
|
+
config2,
|
|
75983
|
+
{ fields: target.abstractFields.fields[possible.name] },
|
|
75984
|
+
{ fields: selection }
|
|
75985
|
+
);
|
|
75986
|
+
}
|
|
75987
|
+
}
|
|
75988
|
+
}
|
|
75989
|
+
const mappedType = target.abstractFields?.typeMap[type];
|
|
75990
|
+
if (target.abstractFields && mappedType && target.abstractFields.fields[mappedType]) {
|
|
75991
|
+
applyMask(
|
|
75992
|
+
config2,
|
|
75993
|
+
{ fields: target.abstractFields.fields[mappedType] },
|
|
75994
|
+
{ fields: selection }
|
|
75995
|
+
);
|
|
75996
|
+
}
|
|
75997
|
+
}
|
|
75998
|
+
}
|
|
75682
75999
|
|
|
75683
76000
|
// src/codegen/generators/runtime/graphqlFunction.ts
|
|
75684
76001
|
var recast6 = __toESM(require_main2(), 1);
|
|
@@ -76004,7 +76321,7 @@ function addReferencedInputTypes(config2, filepath, body, visitedTypes, missingS
|
|
|
76004
76321
|
var graphql18 = __toESM(require_graphql2(), 1);
|
|
76005
76322
|
var recast10 = __toESM(require_main2(), 1);
|
|
76006
76323
|
var AST10 = recast10.types.builders;
|
|
76007
|
-
var
|
|
76324
|
+
var fragmentKey2 = " $fragments";
|
|
76008
76325
|
function inlineType({
|
|
76009
76326
|
config: config2,
|
|
76010
76327
|
filepath,
|
|
@@ -76044,24 +76361,24 @@ function inlineType({
|
|
|
76044
76361
|
const rootObj = type;
|
|
76045
76362
|
const inlineFragments = {};
|
|
76046
76363
|
const selectedFields = [];
|
|
76047
|
-
for (const
|
|
76048
|
-
if (
|
|
76049
|
-
const fragmentType = config2.schema.getType(
|
|
76364
|
+
for (const selection of selections) {
|
|
76365
|
+
if (selection.kind === "InlineFragment" && selection.typeCondition) {
|
|
76366
|
+
const fragmentType = config2.schema.getType(selection.typeCondition.name.value);
|
|
76050
76367
|
if (!graphql18.isInterfaceType(type) && !graphql18.isUnionType(type)) {
|
|
76051
|
-
selectedFields.push(...
|
|
76368
|
+
selectedFields.push(...selection.selectionSet.selections);
|
|
76052
76369
|
continue;
|
|
76053
76370
|
}
|
|
76054
76371
|
if (!graphql18.isInterfaceType(fragmentType) && !graphql18.isUnionType(fragmentType)) {
|
|
76055
76372
|
if (!inlineFragments[fragmentType.name]) {
|
|
76056
76373
|
inlineFragments[fragmentType.name] = [];
|
|
76057
76374
|
}
|
|
76058
|
-
inlineFragments[fragmentType.name].push(...
|
|
76375
|
+
inlineFragments[fragmentType.name].push(...selection.selectionSet.selections);
|
|
76059
76376
|
continue;
|
|
76060
76377
|
}
|
|
76061
76378
|
const possibleParents = config2.schema.getPossibleTypes(type).map((t2) => t2.name);
|
|
76062
76379
|
const freeSelections = [];
|
|
76063
76380
|
const typeSpecificSelections = {};
|
|
76064
|
-
for (const node of
|
|
76381
|
+
for (const node of selection.selectionSet.selections) {
|
|
76065
76382
|
if (node.kind !== "InlineFragment") {
|
|
76066
76383
|
freeSelections.push(node);
|
|
76067
76384
|
} else if (node.typeCondition) {
|
|
@@ -76084,23 +76401,30 @@ function inlineType({
|
|
|
76084
76401
|
);
|
|
76085
76402
|
}
|
|
76086
76403
|
}
|
|
76087
|
-
} else if (
|
|
76088
|
-
selectedFields.push(...
|
|
76404
|
+
} else if (selection.kind === "InlineFragment" && !selection.typeCondition) {
|
|
76405
|
+
selectedFields.push(...selection.selectionSet.selections);
|
|
76089
76406
|
} else {
|
|
76090
|
-
selectedFields.push(
|
|
76407
|
+
selectedFields.push(selection);
|
|
76091
76408
|
}
|
|
76092
76409
|
}
|
|
76410
|
+
const fields = Object.values(
|
|
76411
|
+
selectedFields.filter((field) => field.kind === "Field").reduce(
|
|
76412
|
+
(sel, field) => ({
|
|
76413
|
+
...sel,
|
|
76414
|
+
[field.alias?.value ?? field.name.value]: field
|
|
76415
|
+
}),
|
|
76416
|
+
{}
|
|
76417
|
+
)
|
|
76418
|
+
);
|
|
76093
76419
|
result = AST10.tsTypeLiteral([
|
|
76094
|
-
...(
|
|
76095
|
-
|
|
76096
|
-
|
|
76097
|
-
const { field } = selectionTypeInfo(config2.schema, filepath, rootObj, selection2);
|
|
76098
|
-
const attributeName = selection2.alias?.value || selection2.name.value;
|
|
76420
|
+
...fields.map((selection) => {
|
|
76421
|
+
const { field } = selectionTypeInfo(config2.schema, filepath, rootObj, selection);
|
|
76422
|
+
const attributeName = selection.alias?.value || selection.name.value;
|
|
76099
76423
|
let attributeType = inlineType({
|
|
76100
76424
|
config: config2,
|
|
76101
76425
|
filepath,
|
|
76102
76426
|
rootType: field.type,
|
|
76103
|
-
selections:
|
|
76427
|
+
selections: selection.selectionSet?.selections,
|
|
76104
76428
|
root: false,
|
|
76105
76429
|
allowReadonly,
|
|
76106
76430
|
visitedTypes,
|
|
@@ -76109,7 +76433,7 @@ function inlineType({
|
|
|
76109
76433
|
includeFragments,
|
|
76110
76434
|
allOptional
|
|
76111
76435
|
});
|
|
76112
|
-
const hasIncludeOrSkipDirective =
|
|
76436
|
+
const hasIncludeOrSkipDirective = selection.directives && selection.directives.filter(
|
|
76113
76437
|
(directive) => directive.name.value === "include" || directive.name.value === "skip"
|
|
76114
76438
|
).length > 0;
|
|
76115
76439
|
if (hasIncludeOrSkipDirective) {
|
|
@@ -76133,15 +76457,13 @@ function inlineType({
|
|
|
76133
76457
|
result.members.push(
|
|
76134
76458
|
readonlyProperty(
|
|
76135
76459
|
AST10.tsPropertySignature(
|
|
76136
|
-
AST10.
|
|
76460
|
+
AST10.stringLiteral(fragmentKey2),
|
|
76137
76461
|
AST10.tsTypeAnnotation(
|
|
76138
76462
|
AST10.tsTypeLiteral(
|
|
76139
76463
|
(fragmentSpreads || []).map(
|
|
76140
76464
|
(fragmentSpread) => AST10.tsPropertySignature(
|
|
76141
76465
|
AST10.identifier(fragmentSpread.name.value),
|
|
76142
|
-
AST10.tsTypeAnnotation(
|
|
76143
|
-
AST10.tsLiteralType(AST10.booleanLiteral(true))
|
|
76144
|
-
)
|
|
76466
|
+
AST10.tsTypeAnnotation(AST10.tsTypeLiteral([]))
|
|
76145
76467
|
)
|
|
76146
76468
|
)
|
|
76147
76469
|
)
|
|
@@ -76151,7 +76473,7 @@ function inlineType({
|
|
|
76151
76473
|
)
|
|
76152
76474
|
);
|
|
76153
76475
|
}
|
|
76154
|
-
const inlineFragmentSelections = Object.entries(inlineFragments).flatMap(([typeName,
|
|
76476
|
+
const inlineFragmentSelections = Object.entries(inlineFragments).flatMap(([typeName, fragment2]) => {
|
|
76155
76477
|
const fragmentRootType = config2.schema.getType(typeName);
|
|
76156
76478
|
if (!fragmentRootType) {
|
|
76157
76479
|
return [];
|
|
@@ -76160,7 +76482,7 @@ function inlineType({
|
|
|
76160
76482
|
config: config2,
|
|
76161
76483
|
filepath,
|
|
76162
76484
|
rootType: fragmentRootType,
|
|
76163
|
-
selections:
|
|
76485
|
+
selections: fragment2,
|
|
76164
76486
|
allowReadonly,
|
|
76165
76487
|
visitedTypes,
|
|
76166
76488
|
root,
|
|
@@ -76232,10 +76554,10 @@ function inlineType({
|
|
|
76232
76554
|
}
|
|
76233
76555
|
return result;
|
|
76234
76556
|
}
|
|
76235
|
-
function selectionTypeInfo(schema, filepath, rootType,
|
|
76236
|
-
const selectionName =
|
|
76557
|
+
function selectionTypeInfo(schema, filepath, rootType, selection) {
|
|
76558
|
+
const selectionName = selection.name.value;
|
|
76237
76559
|
let fields = {};
|
|
76238
|
-
if (
|
|
76560
|
+
if (selection.kind === "Field" && selection.name.value === "__typename") {
|
|
76239
76561
|
return {
|
|
76240
76562
|
field: {
|
|
76241
76563
|
name: "__typename",
|
|
@@ -76306,7 +76628,7 @@ async function generateDocumentTypes(config2, docs) {
|
|
|
76306
76628
|
filepath: filename,
|
|
76307
76629
|
selections: definition.selectionSet.selections,
|
|
76308
76630
|
fragmentDefinitions,
|
|
76309
|
-
|
|
76631
|
+
keepFragmentSpreadNodes: true
|
|
76310
76632
|
});
|
|
76311
76633
|
if (definition?.kind === "OperationDefinition") {
|
|
76312
76634
|
await generateOperationTypeDefs(
|
|
@@ -76530,39 +76852,26 @@ async function generateFragmentTypeDefs(config2, filepath, body, selections, def
|
|
|
76530
76852
|
if (!type) {
|
|
76531
76853
|
throw new Error("Should not get here");
|
|
76532
76854
|
}
|
|
76533
|
-
let extraExports = [];
|
|
76534
76855
|
let directive = definition.directives?.find(
|
|
76535
76856
|
(directive2) => directive2.name.value === config2.argumentsDirective
|
|
76536
76857
|
);
|
|
76537
|
-
|
|
76538
|
-
|
|
76539
|
-
|
|
76540
|
-
AST11.
|
|
76541
|
-
AST11.identifier(
|
|
76542
|
-
AST11.
|
|
76543
|
-
(
|
|
76544
|
-
|
|
76545
|
-
|
|
76546
|
-
|
|
76547
|
-
|
|
76548
|
-
|
|
76549
|
-
|
|
76550
|
-
missingScalars,
|
|
76551
|
-
definition2,
|
|
76552
|
-
body
|
|
76553
|
-
)
|
|
76554
|
-
),
|
|
76555
|
-
definition2.type.kind !== "NonNullType"
|
|
76556
|
-
);
|
|
76557
|
-
}
|
|
76558
|
-
)
|
|
76559
|
-
)
|
|
76560
|
-
)
|
|
76561
|
-
)
|
|
76562
|
-
);
|
|
76563
|
-
}
|
|
76858
|
+
let inputValue = !directive ? AST11.tsTypeLiteral([]) : AST11.tsTypeLiteral(
|
|
76859
|
+
(fragmentArgumentsDefinitions(config2, filepath, definition) || []).map(
|
|
76860
|
+
(definition2) => {
|
|
76861
|
+
return AST11.tsPropertySignature(
|
|
76862
|
+
AST11.identifier(definition2.variable.name.value),
|
|
76863
|
+
AST11.tsTypeAnnotation(
|
|
76864
|
+
tsTypeReference(config2, missingScalars, definition2, body)
|
|
76865
|
+
),
|
|
76866
|
+
definition2.type.kind !== "NonNullType"
|
|
76867
|
+
);
|
|
76868
|
+
}
|
|
76869
|
+
)
|
|
76870
|
+
);
|
|
76564
76871
|
body.push(
|
|
76565
|
-
|
|
76872
|
+
AST11.exportNamedDeclaration(
|
|
76873
|
+
AST11.tsTypeAliasDeclaration(AST11.identifier(inputTypeName), inputValue)
|
|
76874
|
+
),
|
|
76566
76875
|
AST11.exportNamedDeclaration(
|
|
76567
76876
|
AST11.tsTypeAliasDeclaration(
|
|
76568
76877
|
AST11.identifier(propTypeName),
|
|
@@ -76578,14 +76887,12 @@ async function generateFragmentTypeDefs(config2, filepath, body, selections, def
|
|
|
76578
76887
|
),
|
|
76579
76888
|
readonlyProperty(
|
|
76580
76889
|
AST11.tsPropertySignature(
|
|
76581
|
-
AST11.stringLiteral(
|
|
76890
|
+
AST11.stringLiteral(fragmentKey2),
|
|
76582
76891
|
AST11.tsTypeAnnotation(
|
|
76583
76892
|
AST11.tsTypeLiteral([
|
|
76584
76893
|
AST11.tsPropertySignature(
|
|
76585
76894
|
AST11.stringLiteral(propTypeName),
|
|
76586
|
-
AST11.tsTypeAnnotation(
|
|
76587
|
-
AST11.tsLiteralType(AST11.booleanLiteral(true))
|
|
76588
|
-
)
|
|
76895
|
+
AST11.tsTypeAnnotation(AST11.tsAnyKeyword())
|
|
76589
76896
|
)
|
|
76590
76897
|
])
|
|
76591
76898
|
)
|
|
@@ -77297,6 +77604,13 @@ async function addID(config2, documents) {
|
|
|
77297
77604
|
return;
|
|
77298
77605
|
}
|
|
77299
77606
|
return addKeysToSelection(config2, node, fragmentType);
|
|
77607
|
+
},
|
|
77608
|
+
FragmentDefinition(node) {
|
|
77609
|
+
const fragmentType = config2.schema.getType(node.typeCondition.name.value);
|
|
77610
|
+
if (!fragmentType) {
|
|
77611
|
+
return;
|
|
77612
|
+
}
|
|
77613
|
+
return addKeysToSelection(config2, node, fragmentType);
|
|
77300
77614
|
}
|
|
77301
77615
|
});
|
|
77302
77616
|
}
|
|
@@ -77315,7 +77629,7 @@ function addKeysToSelection(config2, node, fieldType) {
|
|
|
77315
77629
|
const selections = [...node.selectionSet.selections];
|
|
77316
77630
|
for (const keyField of keyFields) {
|
|
77317
77631
|
if (node.selectionSet.selections.find(
|
|
77318
|
-
(
|
|
77632
|
+
(selection) => selection.kind === "Field" && !selection.alias && selection.name.value === keyField
|
|
77319
77633
|
)) {
|
|
77320
77634
|
continue;
|
|
77321
77635
|
}
|
|
@@ -78905,8 +79219,8 @@ async function updatePackageJSON(targetPath) {
|
|
|
78905
79219
|
}
|
|
78906
79220
|
packageJSON.devDependencies = {
|
|
78907
79221
|
...packageJSON.devDependencies,
|
|
78908
|
-
houdini: "^1.0
|
|
78909
|
-
"houdini-svelte": "^1.0
|
|
79222
|
+
houdini: "^1.1.0",
|
|
79223
|
+
"houdini-svelte": "^1.1.0"
|
|
78910
79224
|
};
|
|
78911
79225
|
await fs_exports.writeFile(packagePath, JSON.stringify(packageJSON, null, 4));
|
|
78912
79226
|
}
|