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/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,60 @@ 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 = {
|
|
73590
|
+
...this.collectFragmentSpreads(selection.selectionSet?.selections ?? []),
|
|
73591
|
+
...this.fields[key].selection.fragmentSpreads
|
|
73592
|
+
};
|
|
73413
73593
|
return;
|
|
73414
73594
|
}
|
|
73415
|
-
if (
|
|
73416
|
-
for (const subselect of
|
|
73595
|
+
if (selection.kind === "InlineFragment" && !selection.typeCondition) {
|
|
73596
|
+
for (const subselect of selection.selectionSet.selections) {
|
|
73417
73597
|
this.add(subselect);
|
|
73418
73598
|
}
|
|
73419
73599
|
}
|
|
73420
|
-
if (
|
|
73421
|
-
this.walkInlineFragment(
|
|
73600
|
+
if (selection.kind === "InlineFragment" && selection.typeCondition) {
|
|
73601
|
+
this.walkInlineFragment(selection);
|
|
73422
73602
|
return;
|
|
73423
73603
|
}
|
|
73424
|
-
if (
|
|
73425
|
-
this.fragmentSpreads[selection2.name.value] = selection2;
|
|
73604
|
+
if (selection.kind === "FragmentSpread") {
|
|
73426
73605
|
let includeFragments = this.config.defaultFragmentMasking === "disable";
|
|
73427
|
-
const maskEnableDirective =
|
|
73606
|
+
const maskEnableDirective = selection.directives?.find(
|
|
73428
73607
|
({ name }) => name.value === this.config.maskEnableDirective
|
|
73429
73608
|
);
|
|
73430
73609
|
if (maskEnableDirective) {
|
|
73431
73610
|
includeFragments = false;
|
|
73432
73611
|
}
|
|
73433
|
-
const maskDisableDirective =
|
|
73612
|
+
const maskDisableDirective = selection.directives?.find(
|
|
73434
73613
|
({ name }) => name.value === this.config.maskDisableDirective
|
|
73435
73614
|
);
|
|
73436
73615
|
if (maskDisableDirective) {
|
|
@@ -73439,14 +73618,17 @@ var FieldCollection = class {
|
|
|
73439
73618
|
if (this.ignoreMaskDisable) {
|
|
73440
73619
|
includeFragments = true;
|
|
73441
73620
|
}
|
|
73442
|
-
if (
|
|
73621
|
+
if (this.keepFragmentSpreadNodes) {
|
|
73622
|
+
this.fragmentSpreads[selection.name.value] = selection;
|
|
73623
|
+
}
|
|
73624
|
+
if (!includeFragments) {
|
|
73443
73625
|
return;
|
|
73444
73626
|
}
|
|
73445
|
-
const definition = this.fragmentDefinitions[
|
|
73627
|
+
const definition = this.fragmentDefinitions[selection.name.value];
|
|
73446
73628
|
if (!definition) {
|
|
73447
73629
|
throw new HoudiniError({
|
|
73448
73630
|
filepath: this.filepath,
|
|
73449
|
-
message: "Could not find referenced fragment definition: " +
|
|
73631
|
+
message: "Could not find referenced fragment definition: " + selection.name.value + "\n" + JSON.stringify(Object.keys(this.fragmentDefinitions), null, 4)
|
|
73450
73632
|
});
|
|
73451
73633
|
}
|
|
73452
73634
|
this.add({
|
|
@@ -73465,37 +73647,67 @@ var FieldCollection = class {
|
|
|
73465
73647
|
});
|
|
73466
73648
|
}
|
|
73467
73649
|
}
|
|
73650
|
+
collectFragmentSpreads(selections, result = {}) {
|
|
73651
|
+
for (const selection of selections) {
|
|
73652
|
+
if (selection.kind === "Field") {
|
|
73653
|
+
continue;
|
|
73654
|
+
}
|
|
73655
|
+
if (selection.kind === "InlineFragment") {
|
|
73656
|
+
this.collectFragmentSpreads(selection.selectionSet.selections, result);
|
|
73657
|
+
continue;
|
|
73658
|
+
}
|
|
73659
|
+
if (selection.kind === "FragmentSpread") {
|
|
73660
|
+
result[selection.name.value] = selection;
|
|
73661
|
+
continue;
|
|
73662
|
+
}
|
|
73663
|
+
}
|
|
73664
|
+
return result;
|
|
73665
|
+
}
|
|
73468
73666
|
toSelectionSet() {
|
|
73469
|
-
return Object.values(this.inlineFragments).flatMap((
|
|
73470
|
-
if (
|
|
73667
|
+
return Object.values(this.inlineFragments).flatMap((fragment2) => {
|
|
73668
|
+
if (fragment2.selection.size === 0) {
|
|
73471
73669
|
return [];
|
|
73472
73670
|
}
|
|
73473
|
-
|
|
73474
|
-
...
|
|
73671
|
+
fragment2.astNode = {
|
|
73672
|
+
...fragment2.astNode,
|
|
73475
73673
|
selectionSet: {
|
|
73476
|
-
...
|
|
73477
|
-
selections:
|
|
73674
|
+
...fragment2.astNode.selectionSet,
|
|
73675
|
+
selections: fragment2.selection.toSelectionSet()
|
|
73478
73676
|
}
|
|
73479
73677
|
};
|
|
73480
|
-
return [
|
|
73678
|
+
return [fragment2.astNode];
|
|
73481
73679
|
}).concat(
|
|
73482
73680
|
Object.values(this.fields).map((field) => {
|
|
73483
|
-
|
|
73484
|
-
field.astNode
|
|
73485
|
-
|
|
73486
|
-
|
|
73681
|
+
return {
|
|
73682
|
+
...field.astNode,
|
|
73683
|
+
selectionSet: field.astNode.selectionSet ? {
|
|
73684
|
+
kind: "SelectionSet",
|
|
73685
|
+
selections: field.selection.toSelectionSet()
|
|
73686
|
+
} : void 0
|
|
73687
|
+
};
|
|
73487
73688
|
})
|
|
73488
|
-
).concat(
|
|
73689
|
+
).concat(
|
|
73690
|
+
Object.values(this.fragmentSpreads).map((spread) => {
|
|
73691
|
+
return {
|
|
73692
|
+
kind: "FragmentSpread",
|
|
73693
|
+
name: {
|
|
73694
|
+
kind: "Name",
|
|
73695
|
+
value: spread.name.value
|
|
73696
|
+
},
|
|
73697
|
+
directives: spread.directives
|
|
73698
|
+
};
|
|
73699
|
+
})
|
|
73700
|
+
);
|
|
73489
73701
|
}
|
|
73490
|
-
walkInlineFragment(
|
|
73491
|
-
const key =
|
|
73702
|
+
walkInlineFragment(selection) {
|
|
73703
|
+
const key = selection.typeCondition.name.value;
|
|
73492
73704
|
if (!this.inlineFragments[key]) {
|
|
73493
73705
|
this.inlineFragments[key] = {
|
|
73494
|
-
astNode:
|
|
73706
|
+
astNode: selection,
|
|
73495
73707
|
selection: this.empty()
|
|
73496
73708
|
};
|
|
73497
73709
|
}
|
|
73498
|
-
for (const subselect of
|
|
73710
|
+
for (const subselect of selection.selectionSet.selections || []) {
|
|
73499
73711
|
if (subselect.kind !== "InlineFragment" || !subselect.typeCondition) {
|
|
73500
73712
|
this.inlineFragments[key].selection.add(subselect);
|
|
73501
73713
|
continue;
|
|
@@ -73509,8 +73721,8 @@ var FieldCollection = class {
|
|
|
73509
73721
|
fragmentDefinitions: this.fragmentDefinitions,
|
|
73510
73722
|
selections: [],
|
|
73511
73723
|
filepath: this.filepath,
|
|
73512
|
-
|
|
73513
|
-
|
|
73724
|
+
ignoreMaskDisable: this.ignoreMaskDisable,
|
|
73725
|
+
keepFragmentSpreadNodes: this.keepFragmentSpreadNodes
|
|
73514
73726
|
});
|
|
73515
73727
|
}
|
|
73516
73728
|
};
|
|
@@ -73588,13 +73800,13 @@ function murmurHash(str) {
|
|
|
73588
73800
|
// src/codegen/transforms/fragmentVariables.ts
|
|
73589
73801
|
var graphql5 = __toESM(require_graphql2(), 1);
|
|
73590
73802
|
|
|
73591
|
-
// src/codegen/transforms/
|
|
73803
|
+
// src/codegen/transforms/collectDefinitions.ts
|
|
73592
73804
|
var import_graphql30 = __toESM(require_graphql2(), 1);
|
|
73593
73805
|
async function includeFragmentDefinitions(config2, documents) {
|
|
73594
|
-
const fragments =
|
|
73806
|
+
const fragments = collectDefinitions(config2, documents);
|
|
73595
73807
|
for (const [index, { name, document, filename }] of documents.entries()) {
|
|
73596
73808
|
const operation = document.definitions.find(
|
|
73597
|
-
(
|
|
73809
|
+
(def) => def.kind === import_graphql30.Kind.OPERATION_DEFINITION || def.kind === "FragmentDefinition"
|
|
73598
73810
|
);
|
|
73599
73811
|
if (!operation) {
|
|
73600
73812
|
continue;
|
|
@@ -73613,7 +73825,7 @@ async function includeFragmentDefinitions(config2, documents) {
|
|
|
73613
73825
|
};
|
|
73614
73826
|
}
|
|
73615
73827
|
}
|
|
73616
|
-
function
|
|
73828
|
+
function collectDefinitions(config2, docs) {
|
|
73617
73829
|
return docs.reduce((acc, doc) => {
|
|
73618
73830
|
const definitions = doc.document.definitions.reduce(
|
|
73619
73831
|
(prev, definition) => definition.kind !== "FragmentDefinition" ? prev : {
|
|
@@ -73637,11 +73849,11 @@ function findRequiredFragments(selectionSet) {
|
|
|
73637
73849
|
return [];
|
|
73638
73850
|
}
|
|
73639
73851
|
const referencedFragments = [];
|
|
73640
|
-
for (const
|
|
73641
|
-
if (
|
|
73642
|
-
referencedFragments.push(
|
|
73643
|
-
} else if (
|
|
73644
|
-
referencedFragments.push(...findRequiredFragments(
|
|
73852
|
+
for (const selection of selectionSet.selections) {
|
|
73853
|
+
if (selection.kind === import_graphql30.Kind.FRAGMENT_SPREAD) {
|
|
73854
|
+
referencedFragments.push(selection.name.value);
|
|
73855
|
+
} else if (selection.selectionSet) {
|
|
73856
|
+
referencedFragments.push(...findRequiredFragments(selection.selectionSet));
|
|
73645
73857
|
}
|
|
73646
73858
|
}
|
|
73647
73859
|
return referencedFragments;
|
|
@@ -73674,7 +73886,7 @@ function flattenFragments(filepath, operation, fragments) {
|
|
|
73674
73886
|
// src/codegen/transforms/fragmentVariables.ts
|
|
73675
73887
|
var GraphqlKinds2 = graphql5.Kind;
|
|
73676
73888
|
async function fragmentVariables(config2, documents) {
|
|
73677
|
-
const fragments =
|
|
73889
|
+
const fragments = collectDefinitions(config2, documents);
|
|
73678
73890
|
const generatedFragments = {};
|
|
73679
73891
|
const visitedFragments = /* @__PURE__ */ new Set();
|
|
73680
73892
|
for (const doc2 of documents) {
|
|
@@ -73734,9 +73946,17 @@ function inlineFragmentArgs({
|
|
|
73734
73946
|
).reduce((acc, arg) => ({ ...acc, [arg.name]: arg }), {});
|
|
73735
73947
|
const result = graphql5.visit(document, {
|
|
73736
73948
|
FragmentSpread(node) {
|
|
73949
|
+
if (!fragmentDefinitions[node.name.value]) {
|
|
73950
|
+
throw new Error("Could not find definition for fragment" + node.name.value);
|
|
73951
|
+
}
|
|
73737
73952
|
const { definition } = fragmentDefinitions[node.name.value];
|
|
73738
73953
|
let { args, hash } = collectWithArguments(config2, filepath, node, scope);
|
|
73739
73954
|
const newFragmentName = `${node.name.value}${hash}`;
|
|
73955
|
+
config2.registerFragmentVariablesHash({
|
|
73956
|
+
hash: newFragmentName,
|
|
73957
|
+
fragment: node.name.value,
|
|
73958
|
+
args
|
|
73959
|
+
});
|
|
73740
73960
|
if (!visitedFragments.has(newFragmentName)) {
|
|
73741
73961
|
visitedFragments.add(newFragmentName);
|
|
73742
73962
|
const defaultArguments = collectDefaultArgumentValues(config2, filepath, definition);
|
|
@@ -74135,7 +74355,7 @@ function operationObject({
|
|
|
74135
74355
|
listName,
|
|
74136
74356
|
operationKind,
|
|
74137
74357
|
type,
|
|
74138
|
-
selection
|
|
74358
|
+
selection,
|
|
74139
74359
|
filepath
|
|
74140
74360
|
}) {
|
|
74141
74361
|
let parentID;
|
|
@@ -74143,7 +74363,7 @@ function operationObject({
|
|
|
74143
74363
|
let position = config2.internalListPosition;
|
|
74144
74364
|
let allLists = config2.defaultListTarget ?? void 0;
|
|
74145
74365
|
let operationWhen;
|
|
74146
|
-
const internalDirectives =
|
|
74366
|
+
const internalDirectives = selection.directives?.filter(
|
|
74147
74367
|
(directive) => config2.isInternalDirective(directive.name.value)
|
|
74148
74368
|
);
|
|
74149
74369
|
if (internalDirectives && internalDirectives.length > 0) {
|
|
@@ -74379,7 +74599,7 @@ async function paginate(config2, documents) {
|
|
|
74379
74599
|
let fragmentName = "";
|
|
74380
74600
|
let refetchQueryName = "";
|
|
74381
74601
|
let nodeQuery = false;
|
|
74382
|
-
let
|
|
74602
|
+
let fragment2 = "";
|
|
74383
74603
|
let paginateMode = config2.defaultPaginateMode;
|
|
74384
74604
|
doc.document = graphql10.visit(doc.document, {
|
|
74385
74605
|
OperationDefinition(node) {
|
|
@@ -74422,7 +74642,7 @@ async function paginate(config2, documents) {
|
|
|
74422
74642
|
};
|
|
74423
74643
|
},
|
|
74424
74644
|
FragmentDefinition(node) {
|
|
74425
|
-
|
|
74645
|
+
fragment2 = node.typeCondition.name.value;
|
|
74426
74646
|
fragmentName = node.name.value;
|
|
74427
74647
|
refetchQueryName = config2.paginationQueryName(fragmentName);
|
|
74428
74648
|
nodeQuery = node.typeCondition.name.value !== config2.schema.getQueryType()?.name;
|
|
@@ -74469,17 +74689,17 @@ async function paginate(config2, documents) {
|
|
|
74469
74689
|
}
|
|
74470
74690
|
});
|
|
74471
74691
|
let targetType = config2.schema.getQueryType()?.name || "";
|
|
74472
|
-
if (
|
|
74692
|
+
if (fragment2) {
|
|
74473
74693
|
const nodeInterface = config2.schema.getType("Node");
|
|
74474
74694
|
if (nodeInterface) {
|
|
74475
74695
|
const { objects, interfaces } = config2.schema.getImplementations(nodeInterface);
|
|
74476
|
-
if (objects.find((obj) => obj.name ===
|
|
74696
|
+
if (objects.find((obj) => obj.name === fragment2) || interfaces.find((int) => int.name === fragment2)) {
|
|
74477
74697
|
targetType = "Node";
|
|
74478
74698
|
} else {
|
|
74479
|
-
targetType =
|
|
74699
|
+
targetType = fragment2;
|
|
74480
74700
|
}
|
|
74481
74701
|
} else {
|
|
74482
|
-
targetType =
|
|
74702
|
+
targetType = fragment2;
|
|
74483
74703
|
}
|
|
74484
74704
|
}
|
|
74485
74705
|
const pageSize = flags.first.defaultValue ?? flags.last.defaultValue ?? flags.limit.defaultValue;
|
|
@@ -74501,7 +74721,7 @@ async function paginate(config2, documents) {
|
|
|
74501
74721
|
start,
|
|
74502
74722
|
mode: paginateMode
|
|
74503
74723
|
};
|
|
74504
|
-
if (!
|
|
74724
|
+
if (!fragment2) {
|
|
74505
74725
|
continue;
|
|
74506
74726
|
}
|
|
74507
74727
|
const paginationArgs = Object.entries(flags).filter(([_, { enabled }]) => enabled).map(([key, value]) => ({ name: key, ...value }));
|
|
@@ -74522,15 +74742,22 @@ async function paginate(config2, documents) {
|
|
|
74522
74742
|
["arguments"]: paginationArgs.map(
|
|
74523
74743
|
({ name }) => variableAsArgument(name)
|
|
74524
74744
|
)
|
|
74745
|
+
},
|
|
74746
|
+
{
|
|
74747
|
+
kind: graphql10.Kind.DIRECTIVE,
|
|
74748
|
+
name: {
|
|
74749
|
+
kind: "Name",
|
|
74750
|
+
value: config2.maskDisableDirective
|
|
74751
|
+
}
|
|
74525
74752
|
}
|
|
74526
74753
|
]
|
|
74527
74754
|
}
|
|
74528
74755
|
];
|
|
74529
|
-
const keys = config2.keyFieldsForType(!nodeQuery ? config2.schema.getQueryType()?.name || "" :
|
|
74530
|
-
if (
|
|
74756
|
+
const keys = config2.keyFieldsForType(!nodeQuery ? config2.schema.getQueryType()?.name || "" : fragment2).flatMap((key) => {
|
|
74757
|
+
if (fragment2 === config2.schema.getQueryType()?.name) {
|
|
74531
74758
|
return [];
|
|
74532
74759
|
}
|
|
74533
|
-
const fragmentType = config2.schema.getType(
|
|
74760
|
+
const fragmentType = config2.schema.getType(fragment2);
|
|
74534
74761
|
const { type, wrappers } = unwrapType(
|
|
74535
74762
|
config2,
|
|
74536
74763
|
fragmentType.getFields()[key].type
|
|
@@ -74542,7 +74769,7 @@ async function paginate(config2, documents) {
|
|
|
74542
74769
|
}
|
|
74543
74770
|
];
|
|
74544
74771
|
});
|
|
74545
|
-
const typeConfig = config2.typeConfig?.[
|
|
74772
|
+
const typeConfig = config2.typeConfig?.[fragment2];
|
|
74546
74773
|
const queryDoc = {
|
|
74547
74774
|
kind: graphql10.Kind.DOCUMENT,
|
|
74548
74775
|
definitions: [
|
|
@@ -74884,7 +75111,7 @@ async function addListFragments(config2, documents) {
|
|
|
74884
75111
|
);
|
|
74885
75112
|
const targetField = ancestors[ancestors.length - 1];
|
|
74886
75113
|
const targetFieldDefinition = parentType.getFields()[targetField.name.value];
|
|
74887
|
-
const { selection
|
|
75114
|
+
const { selection, type, connection } = connectionSelection(
|
|
74888
75115
|
config2,
|
|
74889
75116
|
targetFieldDefinition,
|
|
74890
75117
|
parentTypeFromAncestors(
|
|
@@ -74895,7 +75122,7 @@ async function addListFragments(config2, documents) {
|
|
|
74895
75122
|
ancestors[ancestors.length - 1].selectionSet
|
|
74896
75123
|
);
|
|
74897
75124
|
lists[nameArg.value.value] = {
|
|
74898
|
-
selection
|
|
75125
|
+
selection,
|
|
74899
75126
|
type,
|
|
74900
75127
|
filename: doc.filename
|
|
74901
75128
|
};
|
|
@@ -74973,14 +75200,14 @@ async function addListFragments(config2, documents) {
|
|
|
74973
75200
|
const generatedDoc = {
|
|
74974
75201
|
kind: graphql11.Kind.DOCUMENT,
|
|
74975
75202
|
definitions: Object.entries(lists).flatMap(
|
|
74976
|
-
([name, { selection
|
|
75203
|
+
([name, { selection, type }]) => {
|
|
74977
75204
|
const schemaType = config2.schema.getType(type.name);
|
|
74978
|
-
if (!
|
|
75205
|
+
if (!selection) {
|
|
74979
75206
|
throw new HoudiniError({ message: "Lists must have a selection" });
|
|
74980
75207
|
}
|
|
74981
75208
|
const fragmentSelection = {
|
|
74982
75209
|
kind: graphql11.Kind.SELECTION_SET,
|
|
74983
|
-
selections: [...
|
|
75210
|
+
selections: [...selection.selections]
|
|
74984
75211
|
};
|
|
74985
75212
|
if (schemaType && fragmentSelection && !fragmentSelection?.selections.find(
|
|
74986
75213
|
(field) => field.kind === "Field" && config2.keyFieldsForType(type.name).includes(field.name.value)
|
|
@@ -75072,7 +75299,7 @@ async function addListFragments(config2, documents) {
|
|
|
75072
75299
|
artifact: null
|
|
75073
75300
|
});
|
|
75074
75301
|
}
|
|
75075
|
-
function connectionSelection(config2, field, type,
|
|
75302
|
+
function connectionSelection(config2, field, type, selection) {
|
|
75076
75303
|
const fieldArgs = field.args.reduce(
|
|
75077
75304
|
(args, arg) => ({
|
|
75078
75305
|
...args,
|
|
@@ -75081,34 +75308,34 @@ function connectionSelection(config2, field, type, selection2) {
|
|
|
75081
75308
|
{}
|
|
75082
75309
|
);
|
|
75083
75310
|
if (fieldArgs["limit"]) {
|
|
75084
|
-
return { selection
|
|
75311
|
+
return { selection, type, connection: false, error: null };
|
|
75085
75312
|
}
|
|
75086
75313
|
const forwardPagination = fieldArgs["first"] === "Int" && ["Cursor", "String"].includes(fieldArgs["after"]);
|
|
75087
75314
|
const backwardsPagination = fieldArgs["last"] === "Int" && ["Cursor", "String"].includes(fieldArgs["before"]);
|
|
75088
75315
|
if (!forwardPagination && !backwardsPagination) {
|
|
75089
|
-
return { selection
|
|
75316
|
+
return { selection, type, connection: false, error: missingPaginationArgMessage(config2) };
|
|
75090
75317
|
}
|
|
75091
|
-
const edgesField =
|
|
75092
|
-
(
|
|
75318
|
+
const edgesField = selection?.selections.find(
|
|
75319
|
+
(selection2) => selection2.kind === "Field" && selection2.name.value === "edges"
|
|
75093
75320
|
);
|
|
75094
75321
|
if (!edgesField) {
|
|
75095
|
-
return { selection
|
|
75322
|
+
return { selection, type, connection: false, error: missingEdgeSelectionMessage(config2) };
|
|
75096
75323
|
}
|
|
75097
75324
|
const nodeSelection = edgesField.selectionSet?.selections.find(
|
|
75098
|
-
(
|
|
75325
|
+
(selection2) => selection2.kind === "Field" && selection2.name.value === "node"
|
|
75099
75326
|
);
|
|
75100
75327
|
if (!nodeSelection.selectionSet) {
|
|
75101
|
-
return { selection
|
|
75328
|
+
return { selection, type, connection: false, error: missingNodeSelectionMessage(config2) };
|
|
75102
75329
|
}
|
|
75103
75330
|
const edgeField = unwrapType(config2, field.type).type.getFields()["edges"];
|
|
75104
75331
|
const { wrappers, type: edgeFieldType } = unwrapType(config2, edgeField.type);
|
|
75105
75332
|
const list = wrappers[wrappers.length - 2] === "List" /* List */;
|
|
75106
75333
|
if (!list) {
|
|
75107
|
-
return { selection
|
|
75334
|
+
return { selection, type, connection: false, error: edgeInvalidTypeMessage(config2) };
|
|
75108
75335
|
}
|
|
75109
75336
|
const nodeField = edgeFieldType.getFields()["node"];
|
|
75110
75337
|
if (!nodeField) {
|
|
75111
|
-
return { selection
|
|
75338
|
+
return { selection, type, connection: false, error: nodeNotDefinedMessage(config2) };
|
|
75112
75339
|
}
|
|
75113
75340
|
return {
|
|
75114
75341
|
selection: nodeSelection.selectionSet,
|
|
@@ -75187,59 +75414,45 @@ function fieldKey(config2, field) {
|
|
|
75187
75414
|
}
|
|
75188
75415
|
|
|
75189
75416
|
// src/codegen/generators/artifacts/selection.ts
|
|
75190
|
-
function
|
|
75417
|
+
function selection_default(args) {
|
|
75418
|
+
const typeMap = {};
|
|
75419
|
+
const abstractTypes = [];
|
|
75420
|
+
return mergeSelection({
|
|
75421
|
+
object: prepareSelection({ ...args, typeMap, abstractTypes }),
|
|
75422
|
+
filepath: args.filepath,
|
|
75423
|
+
typeMap,
|
|
75424
|
+
abstractTypes
|
|
75425
|
+
});
|
|
75426
|
+
}
|
|
75427
|
+
function prepareSelection({
|
|
75191
75428
|
config: config2,
|
|
75192
75429
|
filepath,
|
|
75193
75430
|
rootType,
|
|
75194
75431
|
selections,
|
|
75195
75432
|
operations,
|
|
75196
75433
|
path: path2 = [],
|
|
75197
|
-
includeFragments,
|
|
75198
75434
|
document,
|
|
75199
|
-
inConnection
|
|
75435
|
+
inConnection,
|
|
75436
|
+
typeMap,
|
|
75437
|
+
abstractTypes
|
|
75200
75438
|
}) {
|
|
75201
75439
|
let object = {};
|
|
75202
|
-
const typeMap = {};
|
|
75203
|
-
const abstractTypes = [];
|
|
75204
75440
|
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") {
|
|
75441
|
+
if (field.kind === "InlineFragment") {
|
|
75230
75442
|
if (!field.typeCondition || field.typeCondition.name.value === rootType) {
|
|
75231
75443
|
object.fields = deepMerge(
|
|
75232
75444
|
filepath,
|
|
75233
75445
|
object.fields || {},
|
|
75234
|
-
|
|
75446
|
+
prepareSelection({
|
|
75235
75447
|
config: config2,
|
|
75236
75448
|
filepath,
|
|
75237
75449
|
rootType: field.typeCondition?.name.value || rootType,
|
|
75238
75450
|
operations,
|
|
75239
75451
|
selections: field.selectionSet.selections,
|
|
75240
75452
|
path: path2,
|
|
75241
|
-
|
|
75242
|
-
|
|
75453
|
+
document,
|
|
75454
|
+
typeMap,
|
|
75455
|
+
abstractTypes
|
|
75243
75456
|
}).fields || {}
|
|
75244
75457
|
);
|
|
75245
75458
|
} else {
|
|
@@ -75277,15 +75490,16 @@ function selection({
|
|
|
75277
75490
|
}
|
|
75278
75491
|
object.abstractFields.fields = {
|
|
75279
75492
|
...object.abstractFields.fields,
|
|
75280
|
-
[field.typeCondition.name.value]:
|
|
75493
|
+
[field.typeCondition.name.value]: prepareSelection({
|
|
75281
75494
|
config: config2,
|
|
75282
75495
|
filepath,
|
|
75283
75496
|
rootType: field.typeCondition?.name.value || rootType,
|
|
75284
75497
|
operations,
|
|
75285
75498
|
selections: field.selectionSet.selections,
|
|
75286
75499
|
path: path2,
|
|
75287
|
-
|
|
75288
|
-
|
|
75500
|
+
document,
|
|
75501
|
+
typeMap,
|
|
75502
|
+
abstractTypes
|
|
75289
75503
|
}).fields
|
|
75290
75504
|
};
|
|
75291
75505
|
}
|
|
@@ -75306,10 +75520,14 @@ function selection({
|
|
|
75306
75520
|
}
|
|
75307
75521
|
const typeName = fieldType.toString();
|
|
75308
75522
|
const pathSoFar = path2.concat(attributeName);
|
|
75309
|
-
const
|
|
75523
|
+
const keys = config2.keyFieldsForType(rootType);
|
|
75524
|
+
let fieldObj = {
|
|
75310
75525
|
type: typeName,
|
|
75311
75526
|
keyRaw: fieldKey(config2, field)
|
|
75312
75527
|
};
|
|
75528
|
+
if (keys.includes(field.name.value)) {
|
|
75529
|
+
fieldObj.visible = true;
|
|
75530
|
+
}
|
|
75313
75531
|
if (nullable) {
|
|
75314
75532
|
fieldObj.nullable = true;
|
|
75315
75533
|
}
|
|
@@ -75357,16 +75575,17 @@ function selection({
|
|
|
75357
75575
|
}
|
|
75358
75576
|
if (field.selectionSet) {
|
|
75359
75577
|
const connectionState = paginated && document.refetch?.method === "cursor" || continueConnection;
|
|
75360
|
-
fieldObj.selection =
|
|
75578
|
+
fieldObj.selection = prepareSelection({
|
|
75361
75579
|
config: config2,
|
|
75362
75580
|
filepath,
|
|
75363
75581
|
rootType: typeName,
|
|
75364
75582
|
selections: field.selectionSet.selections,
|
|
75365
75583
|
operations,
|
|
75366
75584
|
path: pathSoFar,
|
|
75367
|
-
includeFragments,
|
|
75368
75585
|
document,
|
|
75369
|
-
inConnection: connectionState
|
|
75586
|
+
inConnection: connectionState,
|
|
75587
|
+
typeMap,
|
|
75588
|
+
abstractTypes
|
|
75370
75589
|
});
|
|
75371
75590
|
}
|
|
75372
75591
|
if (field.arguments?.length && fieldObj.list) {
|
|
@@ -75381,12 +75600,29 @@ function selection({
|
|
|
75381
75600
|
if (graphql13.isInterfaceType(fieldType) || graphql13.isUnionType(fieldType)) {
|
|
75382
75601
|
fieldObj.abstract = true;
|
|
75383
75602
|
}
|
|
75603
|
+
if (object.fields?.[attributeName]) {
|
|
75604
|
+
fieldObj = deepMerge(filepath, object.fields[attributeName], fieldObj);
|
|
75605
|
+
}
|
|
75384
75606
|
object.fields = {
|
|
75385
75607
|
...object.fields,
|
|
75386
75608
|
[attributeName]: fieldObj
|
|
75387
75609
|
};
|
|
75610
|
+
} else if (field.kind === "FragmentSpread") {
|
|
75611
|
+
const { fragment: fragment2, args } = config2.getFragmentVariablesHash(field.name.value);
|
|
75612
|
+
object.fragments = {
|
|
75613
|
+
...object.fragments,
|
|
75614
|
+
[fragment2]: args ?? {}
|
|
75615
|
+
};
|
|
75388
75616
|
}
|
|
75389
75617
|
}
|
|
75618
|
+
return object;
|
|
75619
|
+
}
|
|
75620
|
+
function mergeSelection({
|
|
75621
|
+
filepath,
|
|
75622
|
+
object,
|
|
75623
|
+
typeMap,
|
|
75624
|
+
abstractTypes
|
|
75625
|
+
}) {
|
|
75390
75626
|
if (Object.keys(object.fields || {}).length > 0 && object.abstractFields && Object.keys(object.abstractFields.fields).length > 0) {
|
|
75391
75627
|
for (const [typeName, possibles] of Object.entries(typeMap)) {
|
|
75392
75628
|
let overlap = false;
|
|
@@ -75394,8 +75630,8 @@ function selection({
|
|
|
75394
75630
|
if (object.abstractFields.fields[typeName]) {
|
|
75395
75631
|
object.abstractFields.fields[typeName] = deepMerge(
|
|
75396
75632
|
filepath,
|
|
75397
|
-
object.abstractFields.fields[typeName]
|
|
75398
|
-
object.abstractFields.fields[possible]
|
|
75633
|
+
object.abstractFields.fields[typeName] ?? {},
|
|
75634
|
+
object.abstractFields.fields[possible] ?? {}
|
|
75399
75635
|
);
|
|
75400
75636
|
overlap = true;
|
|
75401
75637
|
}
|
|
@@ -75426,6 +75662,30 @@ function selection({
|
|
|
75426
75662
|
}
|
|
75427
75663
|
}
|
|
75428
75664
|
}
|
|
75665
|
+
for (const [key, value] of Object.entries(object.fields ?? {})) {
|
|
75666
|
+
const selection = value.selection;
|
|
75667
|
+
if (selection) {
|
|
75668
|
+
mergeSelection({
|
|
75669
|
+
filepath,
|
|
75670
|
+
typeMap,
|
|
75671
|
+
abstractTypes,
|
|
75672
|
+
object: selection
|
|
75673
|
+
});
|
|
75674
|
+
}
|
|
75675
|
+
}
|
|
75676
|
+
for (const [type, selection] of Object.entries(object.abstractFields?.fields ?? {})) {
|
|
75677
|
+
for (const [key, value] of Object.entries(selection ?? {})) {
|
|
75678
|
+
const selection2 = value.selection;
|
|
75679
|
+
if (selection2) {
|
|
75680
|
+
mergeSelection({
|
|
75681
|
+
filepath,
|
|
75682
|
+
typeMap,
|
|
75683
|
+
abstractTypes,
|
|
75684
|
+
object: selection2
|
|
75685
|
+
});
|
|
75686
|
+
}
|
|
75687
|
+
}
|
|
75688
|
+
}
|
|
75429
75689
|
return object;
|
|
75430
75690
|
}
|
|
75431
75691
|
|
|
@@ -75490,7 +75750,12 @@ function artifactGenerator(stats) {
|
|
|
75490
75750
|
writeIndexFile(config2, docs)
|
|
75491
75751
|
].concat(
|
|
75492
75752
|
docs.map(async (doc) => {
|
|
75493
|
-
const {
|
|
75753
|
+
const {
|
|
75754
|
+
document,
|
|
75755
|
+
name,
|
|
75756
|
+
generateArtifact,
|
|
75757
|
+
originalParsed
|
|
75758
|
+
} = doc;
|
|
75494
75759
|
if (!generateArtifact) {
|
|
75495
75760
|
return;
|
|
75496
75761
|
}
|
|
@@ -75529,6 +75794,16 @@ function artifactGenerator(stats) {
|
|
|
75529
75794
|
);
|
|
75530
75795
|
let rootType = "";
|
|
75531
75796
|
let selectionSet;
|
|
75797
|
+
let originalSelectionSet = null;
|
|
75798
|
+
const fragmentDefinitions = doc.document.definitions.filter(
|
|
75799
|
+
(definition) => definition.kind === "FragmentDefinition"
|
|
75800
|
+
).reduce(
|
|
75801
|
+
(prev, definition) => ({
|
|
75802
|
+
...prev,
|
|
75803
|
+
[definition.name.value]: definition
|
|
75804
|
+
}),
|
|
75805
|
+
{}
|
|
75806
|
+
);
|
|
75532
75807
|
if (docKind !== ArtifactKind.Fragment) {
|
|
75533
75808
|
const operation = operations[0];
|
|
75534
75809
|
if (operation.operation === "query") {
|
|
@@ -75545,9 +75820,12 @@ function artifactGenerator(stats) {
|
|
|
75545
75820
|
});
|
|
75546
75821
|
}
|
|
75547
75822
|
selectionSet = operation.selectionSet;
|
|
75823
|
+
if (originalParsed.definitions[0].kind === "OperationDefinition") {
|
|
75824
|
+
originalSelectionSet = originalParsed.definitions[0].selectionSet;
|
|
75825
|
+
}
|
|
75548
75826
|
} else {
|
|
75549
75827
|
const matchingFragment = fragments.find(
|
|
75550
|
-
(
|
|
75828
|
+
(fragment2) => fragment2.name.value === name
|
|
75551
75829
|
);
|
|
75552
75830
|
if (!matchingFragment) {
|
|
75553
75831
|
throw new HoudiniError({
|
|
@@ -75557,6 +75835,12 @@ function artifactGenerator(stats) {
|
|
|
75557
75835
|
}
|
|
75558
75836
|
rootType = matchingFragment.typeCondition.name.value;
|
|
75559
75837
|
selectionSet = matchingFragment.selectionSet;
|
|
75838
|
+
if (originalParsed.definitions[0].kind === "FragmentDefinition") {
|
|
75839
|
+
originalSelectionSet = originalParsed.definitions[0].selectionSet;
|
|
75840
|
+
}
|
|
75841
|
+
}
|
|
75842
|
+
if (!originalSelectionSet) {
|
|
75843
|
+
throw new Error("Not original selection set!");
|
|
75560
75844
|
}
|
|
75561
75845
|
let inputs = operations[0]?.variableDefinitions;
|
|
75562
75846
|
let directive = fragments[0]?.directives?.find(
|
|
@@ -75565,21 +75849,18 @@ function artifactGenerator(stats) {
|
|
|
75565
75849
|
if (docKind === ArtifactKind.Fragment && directive) {
|
|
75566
75850
|
inputs = fragmentArgumentsDefinitions(config2, doc.filename, fragments[0]);
|
|
75567
75851
|
}
|
|
75568
|
-
const
|
|
75852
|
+
const mask = selection_default({
|
|
75569
75853
|
config: config2,
|
|
75570
75854
|
filepath: doc.filename,
|
|
75571
|
-
|
|
75572
|
-
|
|
75573
|
-
|
|
75574
|
-
|
|
75575
|
-
|
|
75576
|
-
|
|
75577
|
-
|
|
75578
|
-
|
|
75579
|
-
|
|
75580
|
-
),
|
|
75581
|
-
ignoreMaskDisable: docKind === "HoudiniQuery",
|
|
75582
|
-
applyFragments: docKind !== "HoudiniFragment"
|
|
75855
|
+
rootType,
|
|
75856
|
+
operations: {},
|
|
75857
|
+
document: doc,
|
|
75858
|
+
selections: flattenSelections({
|
|
75859
|
+
config: config2,
|
|
75860
|
+
filepath: doc.filename,
|
|
75861
|
+
selections: selectionSet.selections,
|
|
75862
|
+
fragmentDefinitions
|
|
75863
|
+
})
|
|
75583
75864
|
});
|
|
75584
75865
|
let artifact = {
|
|
75585
75866
|
name,
|
|
@@ -75588,21 +75869,29 @@ function artifactGenerator(stats) {
|
|
|
75588
75869
|
refetch: doc.refetch,
|
|
75589
75870
|
raw: rawString,
|
|
75590
75871
|
rootType,
|
|
75591
|
-
selection:
|
|
75872
|
+
selection: selection_default({
|
|
75592
75873
|
config: config2,
|
|
75593
75874
|
filepath: doc.filename,
|
|
75594
75875
|
rootType,
|
|
75595
|
-
selections:
|
|
75876
|
+
selections: flattenSelections({
|
|
75877
|
+
config: config2,
|
|
75878
|
+
filepath: doc.filename,
|
|
75879
|
+
selections: selectionSet.selections,
|
|
75880
|
+
fragmentDefinitions,
|
|
75881
|
+
ignoreMaskDisable: docKind !== "HoudiniFragment",
|
|
75882
|
+
keepFragmentSpreadNodes: true
|
|
75883
|
+
}),
|
|
75596
75884
|
operations: operationsByPath(
|
|
75597
75885
|
config2,
|
|
75598
75886
|
doc.filename,
|
|
75599
75887
|
operations[0],
|
|
75600
75888
|
filterTypes
|
|
75601
75889
|
),
|
|
75602
|
-
includeFragments: docKind !== "HoudiniFragment",
|
|
75603
75890
|
document: doc
|
|
75604
|
-
})
|
|
75891
|
+
}),
|
|
75892
|
+
pluginData: {}
|
|
75605
75893
|
};
|
|
75894
|
+
applyMask(config2, artifact.selection, mask);
|
|
75606
75895
|
artifact.pluginData = {};
|
|
75607
75896
|
for (const plugin2 of config2.plugins) {
|
|
75608
75897
|
if (!plugin2.artifactData) {
|
|
@@ -75679,6 +75968,49 @@ function artifactGenerator(stats) {
|
|
|
75679
75968
|
stats.deleted = await cleanupFiles(config2.artifactDirectory, listOfArtifacts);
|
|
75680
75969
|
};
|
|
75681
75970
|
}
|
|
75971
|
+
function applyMask(config2, target, mask) {
|
|
75972
|
+
for (const [fieldName, value] of Object.entries(mask.fields ?? {})) {
|
|
75973
|
+
const targetSelection = target.fields?.[fieldName];
|
|
75974
|
+
if (!targetSelection || !mask.fields) {
|
|
75975
|
+
continue;
|
|
75976
|
+
}
|
|
75977
|
+
targetSelection.visible = true;
|
|
75978
|
+
if (targetSelection.selection && value.selection) {
|
|
75979
|
+
applyMask(config2, targetSelection.selection, value.selection);
|
|
75980
|
+
}
|
|
75981
|
+
}
|
|
75982
|
+
for (const [type, selection] of Object.entries(mask.abstractFields?.fields ?? {})) {
|
|
75983
|
+
if (!selection) {
|
|
75984
|
+
continue;
|
|
75985
|
+
}
|
|
75986
|
+
if (target.abstractFields?.fields[type]) {
|
|
75987
|
+
applyMask(config2, { fields: target.abstractFields.fields[type] }, { fields: selection });
|
|
75988
|
+
}
|
|
75989
|
+
const targetType = config2.schema.getType(type);
|
|
75990
|
+
if (!targetType) {
|
|
75991
|
+
continue;
|
|
75992
|
+
}
|
|
75993
|
+
if (graphql14.isAbstractType(targetType)) {
|
|
75994
|
+
for (const possible of config2.schema.getPossibleTypes(targetType)) {
|
|
75995
|
+
if (target.abstractFields?.fields[possible.name]) {
|
|
75996
|
+
applyMask(
|
|
75997
|
+
config2,
|
|
75998
|
+
{ fields: target.abstractFields.fields[possible.name] },
|
|
75999
|
+
{ fields: selection }
|
|
76000
|
+
);
|
|
76001
|
+
}
|
|
76002
|
+
}
|
|
76003
|
+
}
|
|
76004
|
+
const mappedType = target.abstractFields?.typeMap[type];
|
|
76005
|
+
if (target.abstractFields && mappedType && target.abstractFields.fields[mappedType]) {
|
|
76006
|
+
applyMask(
|
|
76007
|
+
config2,
|
|
76008
|
+
{ fields: target.abstractFields.fields[mappedType] },
|
|
76009
|
+
{ fields: selection }
|
|
76010
|
+
);
|
|
76011
|
+
}
|
|
76012
|
+
}
|
|
76013
|
+
}
|
|
75682
76014
|
|
|
75683
76015
|
// src/codegen/generators/runtime/graphqlFunction.ts
|
|
75684
76016
|
var recast6 = __toESM(require_main2(), 1);
|
|
@@ -76004,7 +76336,7 @@ function addReferencedInputTypes(config2, filepath, body, visitedTypes, missingS
|
|
|
76004
76336
|
var graphql18 = __toESM(require_graphql2(), 1);
|
|
76005
76337
|
var recast10 = __toESM(require_main2(), 1);
|
|
76006
76338
|
var AST10 = recast10.types.builders;
|
|
76007
|
-
var
|
|
76339
|
+
var fragmentKey2 = " $fragments";
|
|
76008
76340
|
function inlineType({
|
|
76009
76341
|
config: config2,
|
|
76010
76342
|
filepath,
|
|
@@ -76044,24 +76376,24 @@ function inlineType({
|
|
|
76044
76376
|
const rootObj = type;
|
|
76045
76377
|
const inlineFragments = {};
|
|
76046
76378
|
const selectedFields = [];
|
|
76047
|
-
for (const
|
|
76048
|
-
if (
|
|
76049
|
-
const fragmentType = config2.schema.getType(
|
|
76379
|
+
for (const selection of selections) {
|
|
76380
|
+
if (selection.kind === "InlineFragment" && selection.typeCondition) {
|
|
76381
|
+
const fragmentType = config2.schema.getType(selection.typeCondition.name.value);
|
|
76050
76382
|
if (!graphql18.isInterfaceType(type) && !graphql18.isUnionType(type)) {
|
|
76051
|
-
selectedFields.push(...
|
|
76383
|
+
selectedFields.push(...selection.selectionSet.selections);
|
|
76052
76384
|
continue;
|
|
76053
76385
|
}
|
|
76054
76386
|
if (!graphql18.isInterfaceType(fragmentType) && !graphql18.isUnionType(fragmentType)) {
|
|
76055
76387
|
if (!inlineFragments[fragmentType.name]) {
|
|
76056
76388
|
inlineFragments[fragmentType.name] = [];
|
|
76057
76389
|
}
|
|
76058
|
-
inlineFragments[fragmentType.name].push(...
|
|
76390
|
+
inlineFragments[fragmentType.name].push(...selection.selectionSet.selections);
|
|
76059
76391
|
continue;
|
|
76060
76392
|
}
|
|
76061
76393
|
const possibleParents = config2.schema.getPossibleTypes(type).map((t2) => t2.name);
|
|
76062
76394
|
const freeSelections = [];
|
|
76063
76395
|
const typeSpecificSelections = {};
|
|
76064
|
-
for (const node of
|
|
76396
|
+
for (const node of selection.selectionSet.selections) {
|
|
76065
76397
|
if (node.kind !== "InlineFragment") {
|
|
76066
76398
|
freeSelections.push(node);
|
|
76067
76399
|
} else if (node.typeCondition) {
|
|
@@ -76084,23 +76416,30 @@ function inlineType({
|
|
|
76084
76416
|
);
|
|
76085
76417
|
}
|
|
76086
76418
|
}
|
|
76087
|
-
} else if (
|
|
76088
|
-
selectedFields.push(...
|
|
76419
|
+
} else if (selection.kind === "InlineFragment" && !selection.typeCondition) {
|
|
76420
|
+
selectedFields.push(...selection.selectionSet.selections);
|
|
76089
76421
|
} else {
|
|
76090
|
-
selectedFields.push(
|
|
76422
|
+
selectedFields.push(selection);
|
|
76091
76423
|
}
|
|
76092
76424
|
}
|
|
76425
|
+
const fields = Object.values(
|
|
76426
|
+
selectedFields.filter((field) => field.kind === "Field").reduce(
|
|
76427
|
+
(sel, field) => ({
|
|
76428
|
+
...sel,
|
|
76429
|
+
[field.alias?.value ?? field.name.value]: field
|
|
76430
|
+
}),
|
|
76431
|
+
{}
|
|
76432
|
+
)
|
|
76433
|
+
);
|
|
76093
76434
|
result = AST10.tsTypeLiteral([
|
|
76094
|
-
...(
|
|
76095
|
-
|
|
76096
|
-
|
|
76097
|
-
const { field } = selectionTypeInfo(config2.schema, filepath, rootObj, selection2);
|
|
76098
|
-
const attributeName = selection2.alias?.value || selection2.name.value;
|
|
76435
|
+
...fields.map((selection) => {
|
|
76436
|
+
const { field } = selectionTypeInfo(config2.schema, filepath, rootObj, selection);
|
|
76437
|
+
const attributeName = selection.alias?.value || selection.name.value;
|
|
76099
76438
|
let attributeType = inlineType({
|
|
76100
76439
|
config: config2,
|
|
76101
76440
|
filepath,
|
|
76102
76441
|
rootType: field.type,
|
|
76103
|
-
selections:
|
|
76442
|
+
selections: selection.selectionSet?.selections,
|
|
76104
76443
|
root: false,
|
|
76105
76444
|
allowReadonly,
|
|
76106
76445
|
visitedTypes,
|
|
@@ -76109,7 +76448,7 @@ function inlineType({
|
|
|
76109
76448
|
includeFragments,
|
|
76110
76449
|
allOptional
|
|
76111
76450
|
});
|
|
76112
|
-
const hasIncludeOrSkipDirective =
|
|
76451
|
+
const hasIncludeOrSkipDirective = selection.directives && selection.directives.filter(
|
|
76113
76452
|
(directive) => directive.name.value === "include" || directive.name.value === "skip"
|
|
76114
76453
|
).length > 0;
|
|
76115
76454
|
if (hasIncludeOrSkipDirective) {
|
|
@@ -76133,15 +76472,13 @@ function inlineType({
|
|
|
76133
76472
|
result.members.push(
|
|
76134
76473
|
readonlyProperty(
|
|
76135
76474
|
AST10.tsPropertySignature(
|
|
76136
|
-
AST10.
|
|
76475
|
+
AST10.stringLiteral(fragmentKey2),
|
|
76137
76476
|
AST10.tsTypeAnnotation(
|
|
76138
76477
|
AST10.tsTypeLiteral(
|
|
76139
76478
|
(fragmentSpreads || []).map(
|
|
76140
76479
|
(fragmentSpread) => AST10.tsPropertySignature(
|
|
76141
76480
|
AST10.identifier(fragmentSpread.name.value),
|
|
76142
|
-
AST10.tsTypeAnnotation(
|
|
76143
|
-
AST10.tsLiteralType(AST10.booleanLiteral(true))
|
|
76144
|
-
)
|
|
76481
|
+
AST10.tsTypeAnnotation(AST10.tsTypeLiteral([]))
|
|
76145
76482
|
)
|
|
76146
76483
|
)
|
|
76147
76484
|
)
|
|
@@ -76151,7 +76488,7 @@ function inlineType({
|
|
|
76151
76488
|
)
|
|
76152
76489
|
);
|
|
76153
76490
|
}
|
|
76154
|
-
const inlineFragmentSelections = Object.entries(inlineFragments).flatMap(([typeName,
|
|
76491
|
+
const inlineFragmentSelections = Object.entries(inlineFragments).flatMap(([typeName, fragment2]) => {
|
|
76155
76492
|
const fragmentRootType = config2.schema.getType(typeName);
|
|
76156
76493
|
if (!fragmentRootType) {
|
|
76157
76494
|
return [];
|
|
@@ -76160,7 +76497,7 @@ function inlineType({
|
|
|
76160
76497
|
config: config2,
|
|
76161
76498
|
filepath,
|
|
76162
76499
|
rootType: fragmentRootType,
|
|
76163
|
-
selections:
|
|
76500
|
+
selections: fragment2,
|
|
76164
76501
|
allowReadonly,
|
|
76165
76502
|
visitedTypes,
|
|
76166
76503
|
root,
|
|
@@ -76232,10 +76569,10 @@ function inlineType({
|
|
|
76232
76569
|
}
|
|
76233
76570
|
return result;
|
|
76234
76571
|
}
|
|
76235
|
-
function selectionTypeInfo(schema, filepath, rootType,
|
|
76236
|
-
const selectionName =
|
|
76572
|
+
function selectionTypeInfo(schema, filepath, rootType, selection) {
|
|
76573
|
+
const selectionName = selection.name.value;
|
|
76237
76574
|
let fields = {};
|
|
76238
|
-
if (
|
|
76575
|
+
if (selection.kind === "Field" && selection.name.value === "__typename") {
|
|
76239
76576
|
return {
|
|
76240
76577
|
field: {
|
|
76241
76578
|
name: "__typename",
|
|
@@ -76306,7 +76643,7 @@ async function generateDocumentTypes(config2, docs) {
|
|
|
76306
76643
|
filepath: filename,
|
|
76307
76644
|
selections: definition.selectionSet.selections,
|
|
76308
76645
|
fragmentDefinitions,
|
|
76309
|
-
|
|
76646
|
+
keepFragmentSpreadNodes: true
|
|
76310
76647
|
});
|
|
76311
76648
|
if (definition?.kind === "OperationDefinition") {
|
|
76312
76649
|
await generateOperationTypeDefs(
|
|
@@ -76530,39 +76867,26 @@ async function generateFragmentTypeDefs(config2, filepath, body, selections, def
|
|
|
76530
76867
|
if (!type) {
|
|
76531
76868
|
throw new Error("Should not get here");
|
|
76532
76869
|
}
|
|
76533
|
-
let extraExports = [];
|
|
76534
76870
|
let directive = definition.directives?.find(
|
|
76535
76871
|
(directive2) => directive2.name.value === config2.argumentsDirective
|
|
76536
76872
|
);
|
|
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
|
-
}
|
|
76873
|
+
let inputValue = !directive ? AST11.tsTypeLiteral([]) : AST11.tsTypeLiteral(
|
|
76874
|
+
(fragmentArgumentsDefinitions(config2, filepath, definition) || []).map(
|
|
76875
|
+
(definition2) => {
|
|
76876
|
+
return AST11.tsPropertySignature(
|
|
76877
|
+
AST11.identifier(definition2.variable.name.value),
|
|
76878
|
+
AST11.tsTypeAnnotation(
|
|
76879
|
+
tsTypeReference(config2, missingScalars, definition2, body)
|
|
76880
|
+
),
|
|
76881
|
+
definition2.type.kind !== "NonNullType"
|
|
76882
|
+
);
|
|
76883
|
+
}
|
|
76884
|
+
)
|
|
76885
|
+
);
|
|
76564
76886
|
body.push(
|
|
76565
|
-
|
|
76887
|
+
AST11.exportNamedDeclaration(
|
|
76888
|
+
AST11.tsTypeAliasDeclaration(AST11.identifier(inputTypeName), inputValue)
|
|
76889
|
+
),
|
|
76566
76890
|
AST11.exportNamedDeclaration(
|
|
76567
76891
|
AST11.tsTypeAliasDeclaration(
|
|
76568
76892
|
AST11.identifier(propTypeName),
|
|
@@ -76578,14 +76902,12 @@ async function generateFragmentTypeDefs(config2, filepath, body, selections, def
|
|
|
76578
76902
|
),
|
|
76579
76903
|
readonlyProperty(
|
|
76580
76904
|
AST11.tsPropertySignature(
|
|
76581
|
-
AST11.stringLiteral(
|
|
76905
|
+
AST11.stringLiteral(fragmentKey2),
|
|
76582
76906
|
AST11.tsTypeAnnotation(
|
|
76583
76907
|
AST11.tsTypeLiteral([
|
|
76584
76908
|
AST11.tsPropertySignature(
|
|
76585
76909
|
AST11.stringLiteral(propTypeName),
|
|
76586
|
-
AST11.tsTypeAnnotation(
|
|
76587
|
-
AST11.tsLiteralType(AST11.booleanLiteral(true))
|
|
76588
|
-
)
|
|
76910
|
+
AST11.tsTypeAnnotation(AST11.tsAnyKeyword())
|
|
76589
76911
|
)
|
|
76590
76912
|
])
|
|
76591
76913
|
)
|
|
@@ -77297,6 +77619,13 @@ async function addID(config2, documents) {
|
|
|
77297
77619
|
return;
|
|
77298
77620
|
}
|
|
77299
77621
|
return addKeysToSelection(config2, node, fragmentType);
|
|
77622
|
+
},
|
|
77623
|
+
FragmentDefinition(node) {
|
|
77624
|
+
const fragmentType = config2.schema.getType(node.typeCondition.name.value);
|
|
77625
|
+
if (!fragmentType) {
|
|
77626
|
+
return;
|
|
77627
|
+
}
|
|
77628
|
+
return addKeysToSelection(config2, node, fragmentType);
|
|
77300
77629
|
}
|
|
77301
77630
|
});
|
|
77302
77631
|
}
|
|
@@ -77315,7 +77644,7 @@ function addKeysToSelection(config2, node, fieldType) {
|
|
|
77315
77644
|
const selections = [...node.selectionSet.selections];
|
|
77316
77645
|
for (const keyField of keyFields) {
|
|
77317
77646
|
if (node.selectionSet.selections.find(
|
|
77318
|
-
(
|
|
77647
|
+
(selection) => selection.kind === "Field" && !selection.alias && selection.name.value === keyField
|
|
77319
77648
|
)) {
|
|
77320
77649
|
continue;
|
|
77321
77650
|
}
|
|
@@ -78905,8 +79234,8 @@ async function updatePackageJSON(targetPath) {
|
|
|
78905
79234
|
}
|
|
78906
79235
|
packageJSON.devDependencies = {
|
|
78907
79236
|
...packageJSON.devDependencies,
|
|
78908
|
-
houdini: "^1.0
|
|
78909
|
-
"houdini-svelte": "^1.0
|
|
79237
|
+
houdini: "^1.1.1-next.0",
|
|
79238
|
+
"houdini-svelte": "^1.1.1-next.0"
|
|
78910
79239
|
};
|
|
78911
79240
|
await fs_exports.writeFile(packagePath, JSON.stringify(packageJSON, null, 4));
|
|
78912
79241
|
}
|