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-esm/index.js
CHANGED
|
@@ -5122,7 +5122,7 @@ var require_definition = __commonJS({
|
|
|
5122
5122
|
exports.assertLeafType = assertLeafType;
|
|
5123
5123
|
exports.isCompositeType = isCompositeType;
|
|
5124
5124
|
exports.assertCompositeType = assertCompositeType;
|
|
5125
|
-
exports.isAbstractType =
|
|
5125
|
+
exports.isAbstractType = isAbstractType4;
|
|
5126
5126
|
exports.assertAbstractType = assertAbstractType;
|
|
5127
5127
|
exports.GraphQLList = GraphQLList6;
|
|
5128
5128
|
exports.GraphQLNonNull = GraphQLNonNull6;
|
|
@@ -5293,11 +5293,11 @@ var require_definition = __commonJS({
|
|
|
5293
5293
|
}
|
|
5294
5294
|
return type;
|
|
5295
5295
|
}
|
|
5296
|
-
function
|
|
5296
|
+
function isAbstractType4(type) {
|
|
5297
5297
|
return isInterfaceType12(type) || isUnionType13(type);
|
|
5298
5298
|
}
|
|
5299
5299
|
function assertAbstractType(type) {
|
|
5300
|
-
if (!
|
|
5300
|
+
if (!isAbstractType4(type)) {
|
|
5301
5301
|
throw new Error("Expected ".concat((0, _inspect.default)(type), " to be a GraphQL abstract type."));
|
|
5302
5302
|
}
|
|
5303
5303
|
return type;
|
|
@@ -8561,8 +8561,8 @@ var require_KnownFragmentNamesRule = __commonJS({
|
|
|
8561
8561
|
return {
|
|
8562
8562
|
FragmentSpread: function FragmentSpread(node) {
|
|
8563
8563
|
var fragmentName = node.name.value;
|
|
8564
|
-
var
|
|
8565
|
-
if (!
|
|
8564
|
+
var fragment2 = context.getFragment(fragmentName);
|
|
8565
|
+
if (!fragment2) {
|
|
8566
8566
|
context.reportError(new _GraphQLError.GraphQLError('Unknown fragment "'.concat(fragmentName, '".'), node.name));
|
|
8567
8567
|
}
|
|
8568
8568
|
}
|
|
@@ -8598,8 +8598,8 @@ var require_NoUnusedFragmentsRule = __commonJS({
|
|
|
8598
8598
|
for (var _i2 = 0; _i2 < operationDefs.length; _i2++) {
|
|
8599
8599
|
var operation = operationDefs[_i2];
|
|
8600
8600
|
for (var _i4 = 0, _context$getRecursive2 = context.getRecursivelyReferencedFragments(operation); _i4 < _context$getRecursive2.length; _i4++) {
|
|
8601
|
-
var
|
|
8602
|
-
fragmentNameUsed[
|
|
8601
|
+
var fragment2 = _context$getRecursive2[_i4];
|
|
8602
|
+
fragmentNameUsed[fragment2.name.value] = true;
|
|
8603
8603
|
}
|
|
8604
8604
|
}
|
|
8605
8605
|
for (var _i6 = 0; _i6 < fragmentDefs.length; _i6++) {
|
|
@@ -8689,13 +8689,13 @@ var require_NoFragmentCyclesRule = __commonJS({
|
|
|
8689
8689
|
return false;
|
|
8690
8690
|
}
|
|
8691
8691
|
};
|
|
8692
|
-
function detectCycleRecursive(
|
|
8693
|
-
if (visitedFrags[
|
|
8692
|
+
function detectCycleRecursive(fragment2) {
|
|
8693
|
+
if (visitedFrags[fragment2.name.value]) {
|
|
8694
8694
|
return;
|
|
8695
8695
|
}
|
|
8696
|
-
var fragmentName =
|
|
8696
|
+
var fragmentName = fragment2.name.value;
|
|
8697
8697
|
visitedFrags[fragmentName] = true;
|
|
8698
|
-
var spreadNodes = context.getFragmentSpreads(
|
|
8698
|
+
var spreadNodes = context.getFragmentSpreads(fragment2.selectionSet);
|
|
8699
8699
|
if (spreadNodes.length === 0) {
|
|
8700
8700
|
return;
|
|
8701
8701
|
}
|
|
@@ -9516,11 +9516,11 @@ var require_OverlappingFieldsCanBeMergedRule = __commonJS({
|
|
|
9516
9516
|
return conflicts;
|
|
9517
9517
|
}
|
|
9518
9518
|
function collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, fieldMap, fragmentName) {
|
|
9519
|
-
var
|
|
9520
|
-
if (!
|
|
9519
|
+
var fragment2 = context.getFragment(fragmentName);
|
|
9520
|
+
if (!fragment2) {
|
|
9521
9521
|
return;
|
|
9522
9522
|
}
|
|
9523
|
-
var _getReferencedFieldsA = getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames,
|
|
9523
|
+
var _getReferencedFieldsA = getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragment2), fieldMap2 = _getReferencedFieldsA[0], fragmentNames2 = _getReferencedFieldsA[1];
|
|
9524
9524
|
if (fieldMap === fieldMap2) {
|
|
9525
9525
|
return;
|
|
9526
9526
|
}
|
|
@@ -9691,38 +9691,38 @@ var require_OverlappingFieldsCanBeMergedRule = __commonJS({
|
|
|
9691
9691
|
}
|
|
9692
9692
|
return cached;
|
|
9693
9693
|
}
|
|
9694
|
-
function getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames,
|
|
9695
|
-
var cached = cachedFieldsAndFragmentNames.get(
|
|
9694
|
+
function getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragment2) {
|
|
9695
|
+
var cached = cachedFieldsAndFragmentNames.get(fragment2.selectionSet);
|
|
9696
9696
|
if (cached) {
|
|
9697
9697
|
return cached;
|
|
9698
9698
|
}
|
|
9699
|
-
var fragmentType = (0, _typeFromAST.typeFromAST)(context.getSchema(),
|
|
9700
|
-
return getFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragmentType,
|
|
9699
|
+
var fragmentType = (0, _typeFromAST.typeFromAST)(context.getSchema(), fragment2.typeCondition);
|
|
9700
|
+
return getFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragmentType, fragment2.selectionSet);
|
|
9701
9701
|
}
|
|
9702
9702
|
function _collectFieldsAndFragmentNames(context, parentType, selectionSet, nodeAndDefs, fragmentNames) {
|
|
9703
9703
|
for (var _i9 = 0, _selectionSet$selecti2 = selectionSet.selections; _i9 < _selectionSet$selecti2.length; _i9++) {
|
|
9704
|
-
var
|
|
9705
|
-
switch (
|
|
9704
|
+
var selection = _selectionSet$selecti2[_i9];
|
|
9705
|
+
switch (selection.kind) {
|
|
9706
9706
|
case _kinds.Kind.FIELD: {
|
|
9707
|
-
var fieldName =
|
|
9707
|
+
var fieldName = selection.name.value;
|
|
9708
9708
|
var fieldDef = void 0;
|
|
9709
9709
|
if ((0, _definition.isObjectType)(parentType) || (0, _definition.isInterfaceType)(parentType)) {
|
|
9710
9710
|
fieldDef = parentType.getFields()[fieldName];
|
|
9711
9711
|
}
|
|
9712
|
-
var responseName =
|
|
9712
|
+
var responseName = selection.alias ? selection.alias.value : fieldName;
|
|
9713
9713
|
if (!nodeAndDefs[responseName]) {
|
|
9714
9714
|
nodeAndDefs[responseName] = [];
|
|
9715
9715
|
}
|
|
9716
|
-
nodeAndDefs[responseName].push([parentType,
|
|
9716
|
+
nodeAndDefs[responseName].push([parentType, selection, fieldDef]);
|
|
9717
9717
|
break;
|
|
9718
9718
|
}
|
|
9719
9719
|
case _kinds.Kind.FRAGMENT_SPREAD:
|
|
9720
|
-
fragmentNames[
|
|
9720
|
+
fragmentNames[selection.name.value] = true;
|
|
9721
9721
|
break;
|
|
9722
9722
|
case _kinds.Kind.INLINE_FRAGMENT: {
|
|
9723
|
-
var typeCondition =
|
|
9723
|
+
var typeCondition = selection.typeCondition;
|
|
9724
9724
|
var inlineFragmentType = typeCondition ? (0, _typeFromAST.typeFromAST)(context.getSchema(), typeCondition) : parentType;
|
|
9725
|
-
_collectFieldsAndFragmentNames(context, inlineFragmentType,
|
|
9725
|
+
_collectFieldsAndFragmentNames(context, inlineFragmentType, selection.selectionSet, nodeAndDefs, fragmentNames);
|
|
9726
9726
|
break;
|
|
9727
9727
|
}
|
|
9728
9728
|
}
|
|
@@ -10258,11 +10258,11 @@ var require_ValidationContext = __commonJS({
|
|
|
10258
10258
|
while (setsToVisit.length !== 0) {
|
|
10259
10259
|
var set = setsToVisit.pop();
|
|
10260
10260
|
for (var _i2 = 0, _set$selections2 = set.selections; _i2 < _set$selections2.length; _i2++) {
|
|
10261
|
-
var
|
|
10262
|
-
if (
|
|
10263
|
-
spreads.push(
|
|
10264
|
-
} else if (
|
|
10265
|
-
setsToVisit.push(
|
|
10261
|
+
var selection = _set$selections2[_i2];
|
|
10262
|
+
if (selection.kind === _kinds.Kind.FRAGMENT_SPREAD) {
|
|
10263
|
+
spreads.push(selection);
|
|
10264
|
+
} else if (selection.selectionSet) {
|
|
10265
|
+
setsToVisit.push(selection.selectionSet);
|
|
10266
10266
|
}
|
|
10267
10267
|
}
|
|
10268
10268
|
}
|
|
@@ -10283,10 +10283,10 @@ var require_ValidationContext = __commonJS({
|
|
|
10283
10283
|
var fragName = spread.name.value;
|
|
10284
10284
|
if (collectedNames[fragName] !== true) {
|
|
10285
10285
|
collectedNames[fragName] = true;
|
|
10286
|
-
var
|
|
10287
|
-
if (
|
|
10288
|
-
fragments.push(
|
|
10289
|
-
nodesToVisit.push(
|
|
10286
|
+
var fragment2 = this.getFragment(fragName);
|
|
10287
|
+
if (fragment2) {
|
|
10288
|
+
fragments.push(fragment2);
|
|
10289
|
+
nodesToVisit.push(fragment2.selectionSet);
|
|
10290
10290
|
}
|
|
10291
10291
|
}
|
|
10292
10292
|
}
|
|
@@ -11199,37 +11199,37 @@ var require_execute = __commonJS({
|
|
|
11199
11199
|
}
|
|
11200
11200
|
function collectFields(exeContext, runtimeType, selectionSet, fields, visitedFragmentNames) {
|
|
11201
11201
|
for (var _i6 = 0, _selectionSet$selecti2 = selectionSet.selections; _i6 < _selectionSet$selecti2.length; _i6++) {
|
|
11202
|
-
var
|
|
11203
|
-
switch (
|
|
11202
|
+
var selection = _selectionSet$selecti2[_i6];
|
|
11203
|
+
switch (selection.kind) {
|
|
11204
11204
|
case _kinds.Kind.FIELD: {
|
|
11205
|
-
if (!shouldIncludeNode(exeContext,
|
|
11205
|
+
if (!shouldIncludeNode(exeContext, selection)) {
|
|
11206
11206
|
continue;
|
|
11207
11207
|
}
|
|
11208
|
-
var name = getFieldEntryKey(
|
|
11208
|
+
var name = getFieldEntryKey(selection);
|
|
11209
11209
|
if (!fields[name]) {
|
|
11210
11210
|
fields[name] = [];
|
|
11211
11211
|
}
|
|
11212
|
-
fields[name].push(
|
|
11212
|
+
fields[name].push(selection);
|
|
11213
11213
|
break;
|
|
11214
11214
|
}
|
|
11215
11215
|
case _kinds.Kind.INLINE_FRAGMENT: {
|
|
11216
|
-
if (!shouldIncludeNode(exeContext,
|
|
11216
|
+
if (!shouldIncludeNode(exeContext, selection) || !doesFragmentConditionMatch(exeContext, selection, runtimeType)) {
|
|
11217
11217
|
continue;
|
|
11218
11218
|
}
|
|
11219
|
-
collectFields(exeContext, runtimeType,
|
|
11219
|
+
collectFields(exeContext, runtimeType, selection.selectionSet, fields, visitedFragmentNames);
|
|
11220
11220
|
break;
|
|
11221
11221
|
}
|
|
11222
11222
|
case _kinds.Kind.FRAGMENT_SPREAD: {
|
|
11223
|
-
var fragName =
|
|
11224
|
-
if (visitedFragmentNames[fragName] || !shouldIncludeNode(exeContext,
|
|
11223
|
+
var fragName = selection.name.value;
|
|
11224
|
+
if (visitedFragmentNames[fragName] || !shouldIncludeNode(exeContext, selection)) {
|
|
11225
11225
|
continue;
|
|
11226
11226
|
}
|
|
11227
11227
|
visitedFragmentNames[fragName] = true;
|
|
11228
|
-
var
|
|
11229
|
-
if (!
|
|
11228
|
+
var fragment2 = exeContext.fragments[fragName];
|
|
11229
|
+
if (!fragment2 || !doesFragmentConditionMatch(exeContext, fragment2, runtimeType)) {
|
|
11230
11230
|
continue;
|
|
11231
11231
|
}
|
|
11232
|
-
collectFields(exeContext, runtimeType,
|
|
11232
|
+
collectFields(exeContext, runtimeType, fragment2.selectionSet, fields, visitedFragmentNames);
|
|
11233
11233
|
break;
|
|
11234
11234
|
}
|
|
11235
11235
|
}
|
|
@@ -11247,8 +11247,8 @@ var require_execute = __commonJS({
|
|
|
11247
11247
|
}
|
|
11248
11248
|
return true;
|
|
11249
11249
|
}
|
|
11250
|
-
function doesFragmentConditionMatch(exeContext,
|
|
11251
|
-
var typeConditionNode =
|
|
11250
|
+
function doesFragmentConditionMatch(exeContext, fragment2, type) {
|
|
11251
|
+
var typeConditionNode = fragment2.typeCondition;
|
|
11252
11252
|
if (!typeConditionNode) {
|
|
11253
11253
|
return true;
|
|
11254
11254
|
}
|
|
@@ -68481,14 +68481,14 @@ function deepEquals(objA, objB, map = /* @__PURE__ */ new WeakMap()) {
|
|
|
68481
68481
|
}
|
|
68482
68482
|
|
|
68483
68483
|
// src/runtime/lib/selection.ts
|
|
68484
|
-
function getFieldsForType(
|
|
68485
|
-
let targetSelection =
|
|
68486
|
-
if (
|
|
68487
|
-
const mappedType =
|
|
68484
|
+
function getFieldsForType(selection, __typename) {
|
|
68485
|
+
let targetSelection = selection.fields || {};
|
|
68486
|
+
if (selection.abstractFields && __typename) {
|
|
68487
|
+
const mappedType = selection.abstractFields.typeMap[__typename];
|
|
68488
68488
|
if (mappedType) {
|
|
68489
|
-
targetSelection =
|
|
68490
|
-
} else if (
|
|
68491
|
-
targetSelection =
|
|
68489
|
+
targetSelection = selection.abstractFields.fields[mappedType];
|
|
68490
|
+
} else if (selection.abstractFields.fields[__typename]) {
|
|
68491
|
+
targetSelection = selection.abstractFields.fields[__typename];
|
|
68492
68492
|
}
|
|
68493
68493
|
}
|
|
68494
68494
|
return targetSelection;
|
|
@@ -68496,7 +68496,7 @@ function getFieldsForType(selection2, __typename) {
|
|
|
68496
68496
|
|
|
68497
68497
|
// src/runtime/lib/scalars.ts
|
|
68498
68498
|
async function marshalSelection({
|
|
68499
|
-
selection
|
|
68499
|
+
selection,
|
|
68500
68500
|
data
|
|
68501
68501
|
}) {
|
|
68502
68502
|
const config2 = getCurrentConfig();
|
|
@@ -68504,18 +68504,18 @@ async function marshalSelection({
|
|
|
68504
68504
|
return data;
|
|
68505
68505
|
}
|
|
68506
68506
|
if (Array.isArray(data)) {
|
|
68507
|
-
return await Promise.all(data.map((val) => marshalSelection({ selection
|
|
68507
|
+
return await Promise.all(data.map((val) => marshalSelection({ selection, data: val })));
|
|
68508
68508
|
}
|
|
68509
|
-
const targetSelection = getFieldsForType(
|
|
68509
|
+
const targetSelection = getFieldsForType(selection, data["__typename"]);
|
|
68510
68510
|
return Object.fromEntries(
|
|
68511
68511
|
await Promise.all(
|
|
68512
68512
|
Object.entries(data).map(async ([fieldName, value]) => {
|
|
68513
|
-
const { type, selection:
|
|
68513
|
+
const { type, selection: selection2 } = targetSelection[fieldName];
|
|
68514
68514
|
if (!type) {
|
|
68515
68515
|
return [fieldName, value];
|
|
68516
68516
|
}
|
|
68517
|
-
if (
|
|
68518
|
-
return [fieldName, await marshalSelection({ selection:
|
|
68517
|
+
if (selection2) {
|
|
68518
|
+
return [fieldName, await marshalSelection({ selection: selection2, data: value })];
|
|
68519
68519
|
}
|
|
68520
68520
|
if (config2.scalars?.[type]) {
|
|
68521
68521
|
const marshalFn = config2.scalars[type].marshal;
|
|
@@ -68566,6 +68566,7 @@ var DataSource = {
|
|
|
68566
68566
|
Network: "network",
|
|
68567
68567
|
Ssr: "ssr"
|
|
68568
68568
|
};
|
|
68569
|
+
var fragmentKey = " $fragments";
|
|
68569
68570
|
|
|
68570
68571
|
// src/runtime/lib/key.ts
|
|
68571
68572
|
var computeKey = ({ field, args }) => {
|
|
@@ -70308,7 +70309,7 @@ var List = class {
|
|
|
70308
70309
|
recordType,
|
|
70309
70310
|
key,
|
|
70310
70311
|
listType,
|
|
70311
|
-
selection
|
|
70312
|
+
selection,
|
|
70312
70313
|
when,
|
|
70313
70314
|
filters,
|
|
70314
70315
|
connection,
|
|
@@ -70320,7 +70321,7 @@ var List = class {
|
|
|
70320
70321
|
this.key = key;
|
|
70321
70322
|
this.type = listType;
|
|
70322
70323
|
this.cache = manager.cache;
|
|
70323
|
-
this.selection =
|
|
70324
|
+
this.selection = selection;
|
|
70324
70325
|
this._when = when;
|
|
70325
70326
|
this.filters = filters;
|
|
70326
70327
|
this.name = name;
|
|
@@ -70331,19 +70332,19 @@ var List = class {
|
|
|
70331
70332
|
when(when) {
|
|
70332
70333
|
return this.manager.lists.get(this.name).get(this.recordID).when(when);
|
|
70333
70334
|
}
|
|
70334
|
-
append(
|
|
70335
|
-
return this.addToList(
|
|
70335
|
+
append(selection, data, variables = {}) {
|
|
70336
|
+
return this.addToList(selection, data, variables, "last");
|
|
70336
70337
|
}
|
|
70337
|
-
prepend(
|
|
70338
|
-
return this.addToList(
|
|
70338
|
+
prepend(selection, data, variables = {}) {
|
|
70339
|
+
return this.addToList(selection, data, variables, "first");
|
|
70339
70340
|
}
|
|
70340
|
-
addToList(
|
|
70341
|
+
addToList(selection, data, variables = {}, where) {
|
|
70341
70342
|
const listType = this.listType(data);
|
|
70342
70343
|
const dataID = this.cache._internal_unstable.id(listType, data);
|
|
70343
70344
|
if (!this.validateWhen() || !dataID) {
|
|
70344
70345
|
return;
|
|
70345
70346
|
}
|
|
70346
|
-
let insertSelection =
|
|
70347
|
+
let insertSelection = selection;
|
|
70347
70348
|
let insertData = data;
|
|
70348
70349
|
if (this.connection) {
|
|
70349
70350
|
insertSelection = {
|
|
@@ -70363,9 +70364,9 @@ var List = class {
|
|
|
70363
70364
|
type: listType,
|
|
70364
70365
|
keyRaw: "node",
|
|
70365
70366
|
selection: {
|
|
70366
|
-
...
|
|
70367
|
+
...selection,
|
|
70367
70368
|
fields: {
|
|
70368
|
-
...
|
|
70369
|
+
...selection.fields,
|
|
70369
70370
|
__typename: {
|
|
70370
70371
|
keyRaw: "__typename",
|
|
70371
70372
|
type: "String"
|
|
@@ -70394,9 +70395,9 @@ var List = class {
|
|
|
70394
70395
|
type: listType,
|
|
70395
70396
|
updates: ["append", "prepend"],
|
|
70396
70397
|
selection: {
|
|
70397
|
-
...
|
|
70398
|
+
...selection,
|
|
70398
70399
|
fields: {
|
|
70399
|
-
...
|
|
70400
|
+
...selection.fields,
|
|
70400
70401
|
__typename: {
|
|
70401
70402
|
keyRaw: "__typename",
|
|
70402
70403
|
type: "String"
|
|
@@ -70471,7 +70472,8 @@ var List = class {
|
|
|
70471
70472
|
this.cache._internal_unstable.getSelection({
|
|
70472
70473
|
parent: spec.parentID || this.manager.rootID,
|
|
70473
70474
|
selection: spec.selection,
|
|
70474
|
-
variables: spec.variables?.() || {}
|
|
70475
|
+
variables: spec.variables?.() || {},
|
|
70476
|
+
ignoreMasking: false
|
|
70475
70477
|
}).data
|
|
70476
70478
|
);
|
|
70477
70479
|
}
|
|
@@ -70507,9 +70509,9 @@ var List = class {
|
|
|
70507
70509
|
}
|
|
70508
70510
|
return ok;
|
|
70509
70511
|
}
|
|
70510
|
-
toggleElement(
|
|
70512
|
+
toggleElement(selection, data, variables = {}, where) {
|
|
70511
70513
|
if (!this.remove(data, variables)) {
|
|
70512
|
-
this.addToList(
|
|
70514
|
+
this.addToList(selection, data, variables, where);
|
|
70513
70515
|
}
|
|
70514
70516
|
}
|
|
70515
70517
|
*[Symbol.iterator]() {
|
|
@@ -71084,14 +71086,24 @@ var InMemorySubscriptions = class {
|
|
|
71084
71086
|
add({
|
|
71085
71087
|
parent,
|
|
71086
71088
|
spec,
|
|
71087
|
-
selection
|
|
71089
|
+
selection,
|
|
71088
71090
|
variables,
|
|
71089
71091
|
parentType
|
|
71090
71092
|
}) {
|
|
71091
71093
|
const __typename = this.cache._internal_unstable.storage.get(parent, "__typename").value;
|
|
71092
|
-
let targetSelection = getFieldsForType(
|
|
71094
|
+
let targetSelection = getFieldsForType(selection, __typename);
|
|
71093
71095
|
for (const fieldSelection of Object.values(targetSelection || {})) {
|
|
71094
|
-
const {
|
|
71096
|
+
const {
|
|
71097
|
+
keyRaw,
|
|
71098
|
+
selection: innerSelection,
|
|
71099
|
+
type,
|
|
71100
|
+
list,
|
|
71101
|
+
filters,
|
|
71102
|
+
visible
|
|
71103
|
+
} = fieldSelection;
|
|
71104
|
+
if (!visible) {
|
|
71105
|
+
continue;
|
|
71106
|
+
}
|
|
71095
71107
|
const key = evaluateKey(keyRaw, variables);
|
|
71096
71108
|
let targetSelection2;
|
|
71097
71109
|
if (innerSelection) {
|
|
@@ -71139,10 +71151,10 @@ var InMemorySubscriptions = class {
|
|
|
71139
71151
|
addFieldSubscription({
|
|
71140
71152
|
id,
|
|
71141
71153
|
key,
|
|
71142
|
-
selection
|
|
71154
|
+
selection,
|
|
71143
71155
|
type
|
|
71144
71156
|
}) {
|
|
71145
|
-
const spec =
|
|
71157
|
+
const spec = selection[0];
|
|
71146
71158
|
if (!this.subscribers[id]) {
|
|
71147
71159
|
this.subscribers[id] = {};
|
|
71148
71160
|
}
|
|
@@ -71154,7 +71166,7 @@ var InMemorySubscriptions = class {
|
|
|
71154
71166
|
}
|
|
71155
71167
|
this.keyVersions[key].add(key);
|
|
71156
71168
|
if (!this.subscribers[id][key].map(([{ set }]) => set).includes(spec.set)) {
|
|
71157
|
-
this.subscribers[id][key].push([spec,
|
|
71169
|
+
this.subscribers[id][key].push([spec, selection[1]]);
|
|
71158
71170
|
}
|
|
71159
71171
|
if (!this.referenceCounts[id]) {
|
|
71160
71172
|
this.referenceCounts[id] = {};
|
|
@@ -71165,14 +71177,13 @@ var InMemorySubscriptions = class {
|
|
|
71165
71177
|
const counts = this.referenceCounts[id][key];
|
|
71166
71178
|
counts.set(spec.set, (counts.get(spec.set) || 0) + 1);
|
|
71167
71179
|
this.cache._internal_unstable.lifetimes.resetLifetime(id, key);
|
|
71168
|
-
const { selection: innerSelection } = selection2[1]?.[key] ?? {};
|
|
71169
71180
|
}
|
|
71170
71181
|
registerList({
|
|
71171
71182
|
list,
|
|
71172
71183
|
id,
|
|
71173
71184
|
key,
|
|
71174
71185
|
parentType,
|
|
71175
|
-
selection
|
|
71186
|
+
selection,
|
|
71176
71187
|
filters,
|
|
71177
71188
|
variables
|
|
71178
71189
|
}) {
|
|
@@ -71183,7 +71194,7 @@ var InMemorySubscriptions = class {
|
|
|
71183
71194
|
recordType: this.cache._internal_unstable.storage.get(id, "__typename")?.value || parentType,
|
|
71184
71195
|
listType: list.type,
|
|
71185
71196
|
key,
|
|
71186
|
-
selection
|
|
71197
|
+
selection,
|
|
71187
71198
|
filters: Object.entries(filters || {}).reduce((acc, [key2, { kind, value }]) => {
|
|
71188
71199
|
return {
|
|
71189
71200
|
...acc,
|
|
@@ -71199,14 +71210,14 @@ var InMemorySubscriptions = class {
|
|
|
71199
71210
|
parentType
|
|
71200
71211
|
}) {
|
|
71201
71212
|
for (const [spec, targetSelection] of subscribers) {
|
|
71202
|
-
for (const
|
|
71213
|
+
for (const selection of Object.values(targetSelection ?? {})) {
|
|
71203
71214
|
const {
|
|
71204
71215
|
type: linkedType,
|
|
71205
71216
|
keyRaw,
|
|
71206
71217
|
selection: innerSelection,
|
|
71207
71218
|
list,
|
|
71208
71219
|
filters
|
|
71209
|
-
} =
|
|
71220
|
+
} = selection;
|
|
71210
71221
|
const key = evaluateKey(keyRaw, variables);
|
|
71211
71222
|
const fieldSelection = innerSelection ? getFieldsForType(innerSelection, parentType) : void 0;
|
|
71212
71223
|
this.addFieldSubscription({
|
|
@@ -71226,7 +71237,7 @@ var InMemorySubscriptions = class {
|
|
|
71226
71237
|
parentType: parentType || spec.rootType
|
|
71227
71238
|
});
|
|
71228
71239
|
}
|
|
71229
|
-
const childSelection =
|
|
71240
|
+
const childSelection = selection.selection;
|
|
71230
71241
|
if (childSelection) {
|
|
71231
71242
|
const { value: link } = this.cache._internal_unstable.storage.get(parent, key);
|
|
71232
71243
|
const children = !Array.isArray(link) ? [link] : flatten(link);
|
|
@@ -71253,11 +71264,11 @@ var InMemorySubscriptions = class {
|
|
|
71253
71264
|
get(id, field) {
|
|
71254
71265
|
return this.subscribers[id]?.[field] || [];
|
|
71255
71266
|
}
|
|
71256
|
-
remove(id,
|
|
71267
|
+
remove(id, selection, targets, variables, visited = []) {
|
|
71257
71268
|
visited.push(id);
|
|
71258
71269
|
const linkedIDs = [];
|
|
71259
71270
|
const __typename = this.cache._internal_unstable.storage.get(id, "__typename").value;
|
|
71260
|
-
let targetSelection = getFieldsForType(
|
|
71271
|
+
let targetSelection = getFieldsForType(selection, __typename);
|
|
71261
71272
|
for (const fieldSelection of Object.values(targetSelection || {})) {
|
|
71262
71273
|
const key = evaluateKey(fieldSelection.keyRaw, variables);
|
|
71263
71274
|
this.removeSubscribers(id, key, targets);
|
|
@@ -71319,7 +71330,7 @@ var InMemorySubscriptions = class {
|
|
|
71319
71330
|
// src/runtime/cache/cache.ts
|
|
71320
71331
|
var Cache = class {
|
|
71321
71332
|
_internal_unstable;
|
|
71322
|
-
constructor(config2) {
|
|
71333
|
+
constructor({ disabled, ...config2 } = {}) {
|
|
71323
71334
|
this._internal_unstable = new CacheInternal({
|
|
71324
71335
|
cache: this,
|
|
71325
71336
|
storage: new InMemoryStorage(),
|
|
@@ -71327,9 +71338,10 @@ var Cache = class {
|
|
|
71327
71338
|
lists: new ListManager(this, rootID),
|
|
71328
71339
|
lifetimes: new GarbageCollector(this),
|
|
71329
71340
|
staleManager: new StaleManager(this),
|
|
71330
|
-
schema: new SchemaManager(this)
|
|
71341
|
+
schema: new SchemaManager(this),
|
|
71342
|
+
disabled: disabled ?? typeof globalThis.window === "undefined"
|
|
71331
71343
|
});
|
|
71332
|
-
if (config2) {
|
|
71344
|
+
if (Object.keys(config2).length > 0) {
|
|
71333
71345
|
this.setConfig(defaultConfigValues(config2));
|
|
71334
71346
|
}
|
|
71335
71347
|
}
|
|
@@ -71348,7 +71360,8 @@ var Cache = class {
|
|
|
71348
71360
|
this._internal_unstable.getSelection({
|
|
71349
71361
|
parent: spec.parentID || rootID,
|
|
71350
71362
|
selection: spec.selection,
|
|
71351
|
-
variables: spec.variables?.() || {}
|
|
71363
|
+
variables: spec.variables?.() || {},
|
|
71364
|
+
ignoreMasking: false
|
|
71352
71365
|
}).data
|
|
71353
71366
|
);
|
|
71354
71367
|
}
|
|
@@ -71423,16 +71436,13 @@ var Cache = class {
|
|
|
71423
71436
|
getFieldTime(id, field) {
|
|
71424
71437
|
return this._internal_unstable.staleManager.getFieldTime(id, field);
|
|
71425
71438
|
}
|
|
71439
|
+
config() {
|
|
71440
|
+
return this._internal_unstable.config;
|
|
71441
|
+
}
|
|
71426
71442
|
};
|
|
71427
71443
|
var CacheInternal = class {
|
|
71428
71444
|
_disabled = false;
|
|
71429
|
-
|
|
71430
|
-
plugins: {
|
|
71431
|
-
"houdini-svelte": {
|
|
71432
|
-
client: ""
|
|
71433
|
-
}
|
|
71434
|
-
}
|
|
71435
|
-
});
|
|
71445
|
+
_config;
|
|
71436
71446
|
storage;
|
|
71437
71447
|
subscriptions;
|
|
71438
71448
|
lists;
|
|
@@ -71447,7 +71457,9 @@ var CacheInternal = class {
|
|
|
71447
71457
|
cache,
|
|
71448
71458
|
lifetimes,
|
|
71449
71459
|
staleManager,
|
|
71450
|
-
schema
|
|
71460
|
+
schema,
|
|
71461
|
+
disabled,
|
|
71462
|
+
config: config2
|
|
71451
71463
|
}) {
|
|
71452
71464
|
this.storage = storage;
|
|
71453
71465
|
this.subscriptions = subscriptions;
|
|
@@ -71456,7 +71468,8 @@ var CacheInternal = class {
|
|
|
71456
71468
|
this.lifetimes = lifetimes;
|
|
71457
71469
|
this.staleManager = staleManager;
|
|
71458
71470
|
this.schema = schema;
|
|
71459
|
-
this.
|
|
71471
|
+
this._config = config2;
|
|
71472
|
+
this._disabled = disabled;
|
|
71460
71473
|
try {
|
|
71461
71474
|
if (process.env.HOUDINI_TEST === "true") {
|
|
71462
71475
|
this._disabled = false;
|
|
@@ -71464,12 +71477,15 @@ var CacheInternal = class {
|
|
|
71464
71477
|
} catch {
|
|
71465
71478
|
}
|
|
71466
71479
|
}
|
|
71480
|
+
get config() {
|
|
71481
|
+
return this._config ?? getCurrentConfig();
|
|
71482
|
+
}
|
|
71467
71483
|
setConfig(config2) {
|
|
71468
|
-
this.
|
|
71484
|
+
this._config = config2;
|
|
71469
71485
|
}
|
|
71470
71486
|
writeSelection({
|
|
71471
71487
|
data,
|
|
71472
|
-
selection
|
|
71488
|
+
selection,
|
|
71473
71489
|
variables = {},
|
|
71474
71490
|
parent = rootID,
|
|
71475
71491
|
applyUpdates,
|
|
@@ -71481,9 +71497,9 @@ var CacheInternal = class {
|
|
|
71481
71497
|
if (this._disabled) {
|
|
71482
71498
|
return [];
|
|
71483
71499
|
}
|
|
71484
|
-
let targetSelection = getFieldsForType(
|
|
71500
|
+
let targetSelection = getFieldsForType(selection, data["__typename"]);
|
|
71485
71501
|
for (const [field, value] of Object.entries(data)) {
|
|
71486
|
-
if (!
|
|
71502
|
+
if (!selection || !targetSelection[field]) {
|
|
71487
71503
|
continue;
|
|
71488
71504
|
}
|
|
71489
71505
|
let {
|
|
@@ -71739,25 +71755,40 @@ var CacheInternal = class {
|
|
|
71739
71755
|
return toNotify;
|
|
71740
71756
|
}
|
|
71741
71757
|
getSelection({
|
|
71742
|
-
selection
|
|
71758
|
+
selection,
|
|
71743
71759
|
parent = rootID,
|
|
71744
71760
|
variables,
|
|
71745
|
-
stepsFromConnection = null
|
|
71761
|
+
stepsFromConnection = null,
|
|
71762
|
+
ignoreMasking
|
|
71746
71763
|
}) {
|
|
71747
71764
|
if (parent === null) {
|
|
71748
71765
|
return { data: null, partial: false, stale: false, hasData: true };
|
|
71749
71766
|
}
|
|
71750
71767
|
const target = {};
|
|
71768
|
+
if (selection.fragments) {
|
|
71769
|
+
target[fragmentKey] = Object.fromEntries(
|
|
71770
|
+
Object.entries(selection.fragments).map(([key, value]) => [
|
|
71771
|
+
key,
|
|
71772
|
+
{
|
|
71773
|
+
parent,
|
|
71774
|
+
variables: evaluateFragmentVariables(value, variables ?? {})
|
|
71775
|
+
}
|
|
71776
|
+
])
|
|
71777
|
+
);
|
|
71778
|
+
}
|
|
71751
71779
|
let hasData = false;
|
|
71752
71780
|
let partial = false;
|
|
71753
71781
|
let cascadeNull = false;
|
|
71754
71782
|
let stale = false;
|
|
71755
71783
|
const typename = this.storage.get(parent, "__typename").value;
|
|
71756
|
-
let targetSelection = getFieldsForType(
|
|
71784
|
+
let targetSelection = getFieldsForType(selection, typename);
|
|
71757
71785
|
for (const [
|
|
71758
71786
|
attributeName,
|
|
71759
|
-
{ type, keyRaw, selection: fieldSelection, nullable, list }
|
|
71787
|
+
{ type, keyRaw, selection: fieldSelection, nullable, list, visible }
|
|
71760
71788
|
] of Object.entries(targetSelection)) {
|
|
71789
|
+
if (!visible && !ignoreMasking) {
|
|
71790
|
+
continue;
|
|
71791
|
+
}
|
|
71761
71792
|
const key = evaluateKey(keyRaw, variables);
|
|
71762
71793
|
const { value } = this.storage.get(parent, key);
|
|
71763
71794
|
const dt_field = this.staleManager.getFieldTime(parent, key);
|
|
@@ -71797,7 +71828,8 @@ var CacheInternal = class {
|
|
|
71797
71828
|
fields: fieldSelection,
|
|
71798
71829
|
variables,
|
|
71799
71830
|
linkedList: value,
|
|
71800
|
-
stepsFromConnection: nextStep
|
|
71831
|
+
stepsFromConnection: nextStep,
|
|
71832
|
+
ignoreMasking: !!ignoreMasking
|
|
71801
71833
|
});
|
|
71802
71834
|
target[attributeName] = listValue.data;
|
|
71803
71835
|
if (listValue.partial) {
|
|
@@ -71814,7 +71846,8 @@ var CacheInternal = class {
|
|
|
71814
71846
|
parent: value,
|
|
71815
71847
|
selection: fieldSelection,
|
|
71816
71848
|
variables,
|
|
71817
|
-
stepsFromConnection: nextStep
|
|
71849
|
+
stepsFromConnection: nextStep,
|
|
71850
|
+
ignoreMasking
|
|
71818
71851
|
});
|
|
71819
71852
|
target[attributeName] = objectFields.data;
|
|
71820
71853
|
if (objectFields.partial) {
|
|
@@ -71858,7 +71891,8 @@ var CacheInternal = class {
|
|
|
71858
71891
|
fields,
|
|
71859
71892
|
variables,
|
|
71860
71893
|
linkedList,
|
|
71861
|
-
stepsFromConnection
|
|
71894
|
+
stepsFromConnection,
|
|
71895
|
+
ignoreMasking
|
|
71862
71896
|
}) {
|
|
71863
71897
|
const result = [];
|
|
71864
71898
|
let partialData = false;
|
|
@@ -71870,7 +71904,8 @@ var CacheInternal = class {
|
|
|
71870
71904
|
fields,
|
|
71871
71905
|
variables,
|
|
71872
71906
|
linkedList: entry,
|
|
71873
|
-
stepsFromConnection
|
|
71907
|
+
stepsFromConnection,
|
|
71908
|
+
ignoreMasking
|
|
71874
71909
|
});
|
|
71875
71910
|
result.push(nestedValue.data);
|
|
71876
71911
|
if (nestedValue.partial) {
|
|
@@ -71891,7 +71926,8 @@ var CacheInternal = class {
|
|
|
71891
71926
|
parent: entry,
|
|
71892
71927
|
selection: fields,
|
|
71893
71928
|
variables,
|
|
71894
|
-
stepsFromConnection
|
|
71929
|
+
stepsFromConnection,
|
|
71930
|
+
ignoreMasking
|
|
71895
71931
|
});
|
|
71896
71932
|
result.push(data);
|
|
71897
71933
|
if (partial) {
|
|
@@ -71994,11 +72030,54 @@ var CacheInternal = class {
|
|
|
71994
72030
|
}
|
|
71995
72031
|
}
|
|
71996
72032
|
};
|
|
72033
|
+
function evaluateFragmentVariables(variables, args) {
|
|
72034
|
+
return Object.fromEntries(
|
|
72035
|
+
Object.entries(variables).map(([key, value]) => [key, fragmentVariableValue(value, args)])
|
|
72036
|
+
);
|
|
72037
|
+
}
|
|
72038
|
+
function fragmentVariableValue(value, args) {
|
|
72039
|
+
if (value.kind === "StringValue") {
|
|
72040
|
+
return value.value;
|
|
72041
|
+
}
|
|
72042
|
+
if (value.kind === "BooleanValue") {
|
|
72043
|
+
return value.value;
|
|
72044
|
+
}
|
|
72045
|
+
if (value.kind === "EnumValue") {
|
|
72046
|
+
return value.value;
|
|
72047
|
+
}
|
|
72048
|
+
if (value.kind === "FloatValue") {
|
|
72049
|
+
return parseFloat(value.value);
|
|
72050
|
+
}
|
|
72051
|
+
if (value.kind === "IntValue") {
|
|
72052
|
+
return parseInt(value.value, 10);
|
|
72053
|
+
}
|
|
72054
|
+
if (value.kind === "NullValue") {
|
|
72055
|
+
return null;
|
|
72056
|
+
}
|
|
72057
|
+
if (value.kind === "Variable") {
|
|
72058
|
+
return args[value.name.value];
|
|
72059
|
+
}
|
|
72060
|
+
if (value.kind === "ListValue") {
|
|
72061
|
+
return value.values.map((value2) => fragmentVariableValue(value2, args));
|
|
72062
|
+
}
|
|
72063
|
+
if (value.kind === "ObjectValue") {
|
|
72064
|
+
return value.fields.reduce(
|
|
72065
|
+
(obj, field) => ({
|
|
72066
|
+
...obj,
|
|
72067
|
+
[field.name.value]: fragmentVariableValue(field.value, args)
|
|
72068
|
+
}),
|
|
72069
|
+
{}
|
|
72070
|
+
);
|
|
72071
|
+
}
|
|
72072
|
+
}
|
|
71997
72073
|
var rootID = "_ROOT_";
|
|
71998
72074
|
|
|
71999
72075
|
// src/runtime/cache/index.ts
|
|
72000
72076
|
var cache_default = new Cache();
|
|
72001
72077
|
|
|
72078
|
+
// src/runtime/client/plugins/cache.ts
|
|
72079
|
+
var serverSide = typeof globalThis.window === "undefined";
|
|
72080
|
+
|
|
72002
72081
|
// src/runtime/client/utils/documentPlugins.ts
|
|
72003
72082
|
var documentPlugin = (kind, source) => {
|
|
72004
72083
|
return () => {
|
|
@@ -72034,7 +72113,6 @@ var documentPlugin = (kind, source) => {
|
|
|
72034
72113
|
var query = documentPlugin(ArtifactKind.Query, function() {
|
|
72035
72114
|
let subscriptionSpec = null;
|
|
72036
72115
|
let lastVariables = null;
|
|
72037
|
-
let artifactName = "";
|
|
72038
72116
|
return {
|
|
72039
72117
|
start(ctx, { next }) {
|
|
72040
72118
|
ctx.variables = {
|
|
@@ -72044,8 +72122,7 @@ var query = documentPlugin(ArtifactKind.Query, function() {
|
|
|
72044
72122
|
next(ctx);
|
|
72045
72123
|
},
|
|
72046
72124
|
end(ctx, { resolve: resolve2, marshalVariables, variablesChanged }) {
|
|
72047
|
-
if (variablesChanged(ctx)) {
|
|
72048
|
-
artifactName = ctx.artifact.name;
|
|
72125
|
+
if (variablesChanged(ctx) && !ctx.cacheParams?.disableSubscriptions) {
|
|
72049
72126
|
if (subscriptionSpec) {
|
|
72050
72127
|
cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.() || {});
|
|
72051
72128
|
}
|
|
@@ -72066,19 +72143,61 @@ var query = documentPlugin(ArtifactKind.Query, function() {
|
|
|
72066
72143
|
});
|
|
72067
72144
|
}
|
|
72068
72145
|
};
|
|
72069
|
-
cache_default.subscribe(subscriptionSpec, lastVariables
|
|
72146
|
+
cache_default.subscribe(subscriptionSpec, lastVariables);
|
|
72070
72147
|
}
|
|
72071
72148
|
resolve2(ctx);
|
|
72072
72149
|
},
|
|
72073
72150
|
cleanup() {
|
|
72074
72151
|
if (subscriptionSpec) {
|
|
72075
|
-
cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.()
|
|
72152
|
+
cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.());
|
|
72076
72153
|
lastVariables = null;
|
|
72077
72154
|
}
|
|
72078
72155
|
}
|
|
72079
72156
|
};
|
|
72080
72157
|
});
|
|
72081
72158
|
|
|
72159
|
+
// src/runtime/client/plugins/fragment.ts
|
|
72160
|
+
var fragment = documentPlugin(ArtifactKind.Fragment, function() {
|
|
72161
|
+
let subscriptionSpec = null;
|
|
72162
|
+
return {
|
|
72163
|
+
start(ctx, { next, resolve: resolve2, variablesChanged, marshalVariables }) {
|
|
72164
|
+
if (!ctx.stuff.parentID) {
|
|
72165
|
+
return next(ctx);
|
|
72166
|
+
}
|
|
72167
|
+
if (variablesChanged(ctx) && !ctx.cacheParams?.disableSubscriptions) {
|
|
72168
|
+
if (subscriptionSpec) {
|
|
72169
|
+
cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.() || {});
|
|
72170
|
+
}
|
|
72171
|
+
const variables = marshalVariables(ctx);
|
|
72172
|
+
subscriptionSpec = {
|
|
72173
|
+
rootType: ctx.artifact.rootType,
|
|
72174
|
+
selection: ctx.artifact.selection,
|
|
72175
|
+
variables: () => variables,
|
|
72176
|
+
parentID: ctx.stuff.parentID,
|
|
72177
|
+
set: (newValue) => {
|
|
72178
|
+
resolve2(ctx, {
|
|
72179
|
+
data: newValue,
|
|
72180
|
+
errors: null,
|
|
72181
|
+
fetching: false,
|
|
72182
|
+
partial: false,
|
|
72183
|
+
stale: false,
|
|
72184
|
+
source: DataSource.Cache,
|
|
72185
|
+
variables
|
|
72186
|
+
});
|
|
72187
|
+
}
|
|
72188
|
+
};
|
|
72189
|
+
cache_default.subscribe(subscriptionSpec, variables);
|
|
72190
|
+
}
|
|
72191
|
+
next(ctx);
|
|
72192
|
+
},
|
|
72193
|
+
cleanup() {
|
|
72194
|
+
if (subscriptionSpec) {
|
|
72195
|
+
cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.());
|
|
72196
|
+
}
|
|
72197
|
+
}
|
|
72198
|
+
};
|
|
72199
|
+
});
|
|
72200
|
+
|
|
72082
72201
|
// src/runtime/client/plugins/mutation.ts
|
|
72083
72202
|
var mutation = documentPlugin(ArtifactKind.Mutation, () => {
|
|
72084
72203
|
return {
|
|
@@ -72234,6 +72353,7 @@ var Config = class {
|
|
|
72234
72353
|
this.schemaPollInterval = watchSchema?.interval ?? 2e3;
|
|
72235
72354
|
this.schemaPollHeaders = watchSchema?.headers ?? {};
|
|
72236
72355
|
this.rootDir = join2(this.projectRoot, "$houdini");
|
|
72356
|
+
this.#fragmentVariableMaps = {};
|
|
72237
72357
|
if (defaultKeys) {
|
|
72238
72358
|
this.defaultKeys = defaultKeys;
|
|
72239
72359
|
}
|
|
@@ -72383,7 +72503,7 @@ var Config = class {
|
|
|
72383
72503
|
return `$houdini/${this.artifactDirectoryName}/${name}`;
|
|
72384
72504
|
}
|
|
72385
72505
|
keyFieldsForType(type) {
|
|
72386
|
-
return keyFieldsForType(this.configFile, type);
|
|
72506
|
+
return this.schema.getQueryType()?.name === type ? [] : keyFieldsForType(this.configFile, type);
|
|
72387
72507
|
}
|
|
72388
72508
|
computeID(type, data) {
|
|
72389
72509
|
return computeID(this.configFile, type, data);
|
|
@@ -72402,7 +72522,7 @@ var Config = class {
|
|
|
72402
72522
|
({ kind }) => kind === graphql2.Kind.FRAGMENT_DEFINITION
|
|
72403
72523
|
);
|
|
72404
72524
|
if (fragmentDefinitions.length) {
|
|
72405
|
-
return fragmentDefinitions.
|
|
72525
|
+
return fragmentDefinitions[0].name.value;
|
|
72406
72526
|
}
|
|
72407
72527
|
throw new Error("Could not generate artifact name for document: " + graphql2.print(document));
|
|
72408
72528
|
}
|
|
@@ -72574,6 +72694,56 @@ var Config = class {
|
|
|
72574
72694
|
}, []) ?? [];
|
|
72575
72695
|
return !defaultDirectives.includes(name) && (internalDirectives.includes(name) || this.isDeleteDirective(name));
|
|
72576
72696
|
}
|
|
72697
|
+
#fragmentVariableMaps;
|
|
72698
|
+
registerFragmentVariablesHash({
|
|
72699
|
+
hash,
|
|
72700
|
+
args,
|
|
72701
|
+
fragment: fragment2
|
|
72702
|
+
}) {
|
|
72703
|
+
this.#fragmentVariableMaps[hash] = {
|
|
72704
|
+
args: this.#serializeValueMap(args),
|
|
72705
|
+
fragment: fragment2
|
|
72706
|
+
};
|
|
72707
|
+
}
|
|
72708
|
+
getFragmentVariablesHash(hash) {
|
|
72709
|
+
return this.#fragmentVariableMaps[hash] ?? {
|
|
72710
|
+
fragment: hash,
|
|
72711
|
+
args: {},
|
|
72712
|
+
hash
|
|
72713
|
+
};
|
|
72714
|
+
}
|
|
72715
|
+
#serializeValueMap(map) {
|
|
72716
|
+
if (!map) {
|
|
72717
|
+
return null;
|
|
72718
|
+
}
|
|
72719
|
+
return Object.fromEntries(
|
|
72720
|
+
Object.entries(map).map(([key, input]) => {
|
|
72721
|
+
const result = {
|
|
72722
|
+
kind: input.kind
|
|
72723
|
+
};
|
|
72724
|
+
if (typeof input === "object") {
|
|
72725
|
+
if ("value" in input) {
|
|
72726
|
+
result.value = input.value;
|
|
72727
|
+
}
|
|
72728
|
+
if ("values" in input) {
|
|
72729
|
+
result.values = input.values.map(
|
|
72730
|
+
(value) => this.#serializeValueMap({ foo: value }).foo
|
|
72731
|
+
);
|
|
72732
|
+
}
|
|
72733
|
+
if ("name" in input) {
|
|
72734
|
+
result.name = input.name;
|
|
72735
|
+
}
|
|
72736
|
+
if ("fields" in input) {
|
|
72737
|
+
result.fields = input.fields.map((field) => ({
|
|
72738
|
+
name: field.name,
|
|
72739
|
+
value: this.#serializeValueMap({ foo: field.value }).foo
|
|
72740
|
+
}));
|
|
72741
|
+
}
|
|
72742
|
+
}
|
|
72743
|
+
return [key, result];
|
|
72744
|
+
})
|
|
72745
|
+
);
|
|
72746
|
+
}
|
|
72577
72747
|
isListFragment(name) {
|
|
72578
72748
|
return name.endsWith(this.insertFragmentSuffix) || name.endsWith(this.removeFragmentSuffix) || name.endsWith(this.toggleFragmentSuffix);
|
|
72579
72749
|
}
|
|
@@ -73079,11 +73249,17 @@ function deepMerge(filepath, ...targets) {
|
|
|
73079
73249
|
if (targets.length === 1) {
|
|
73080
73250
|
return targets[0];
|
|
73081
73251
|
} else if (targets.length === 2) {
|
|
73082
|
-
return (0, import_deepmerge.default)(targets[0], targets[1]
|
|
73252
|
+
return (0, import_deepmerge.default)(targets[0], targets[1], {
|
|
73253
|
+
arrayMerge: (source, update) => [...new Set(source.concat(update))]
|
|
73254
|
+
});
|
|
73083
73255
|
}
|
|
73084
73256
|
return deepMerge(filepath, targets[0], deepMerge(filepath, ...targets.slice(1)));
|
|
73085
73257
|
} catch (e2) {
|
|
73086
|
-
throw new HoudiniError({
|
|
73258
|
+
throw new HoudiniError({
|
|
73259
|
+
filepath,
|
|
73260
|
+
message: "could not merge: " + targets,
|
|
73261
|
+
description: e2.message
|
|
73262
|
+
});
|
|
73087
73263
|
}
|
|
73088
73264
|
}
|
|
73089
73265
|
|
|
@@ -73365,16 +73541,16 @@ function flattenSelections({
|
|
|
73365
73541
|
filepath,
|
|
73366
73542
|
selections,
|
|
73367
73543
|
fragmentDefinitions,
|
|
73368
|
-
|
|
73369
|
-
|
|
73544
|
+
ignoreMaskDisable,
|
|
73545
|
+
keepFragmentSpreadNodes
|
|
73370
73546
|
}) {
|
|
73371
73547
|
const fields = new FieldCollection({
|
|
73372
73548
|
config: config2,
|
|
73373
73549
|
filepath,
|
|
73374
73550
|
selections,
|
|
73375
73551
|
fragmentDefinitions,
|
|
73376
|
-
|
|
73377
|
-
|
|
73552
|
+
ignoreMaskDisable: !!ignoreMaskDisable,
|
|
73553
|
+
keepFragmentSpreadNodes: !!keepFragmentSpreadNodes
|
|
73378
73554
|
});
|
|
73379
73555
|
return fields.toSelectionSet();
|
|
73380
73556
|
}
|
|
@@ -73385,57 +73561,60 @@ var FieldCollection = class {
|
|
|
73385
73561
|
fields;
|
|
73386
73562
|
inlineFragments;
|
|
73387
73563
|
fragmentSpreads;
|
|
73388
|
-
applyFragments;
|
|
73389
73564
|
ignoreMaskDisable;
|
|
73565
|
+
keepFragmentSpreadNodes;
|
|
73390
73566
|
constructor(args) {
|
|
73391
73567
|
this.config = args.config;
|
|
73392
73568
|
this.fragmentDefinitions = args.fragmentDefinitions;
|
|
73393
|
-
this.applyFragments = args.applyFragments;
|
|
73394
73569
|
this.ignoreMaskDisable = args.ignoreMaskDisable;
|
|
73570
|
+
this.keepFragmentSpreadNodes = args.keepFragmentSpreadNodes;
|
|
73395
73571
|
this.fields = {};
|
|
73396
73572
|
this.inlineFragments = {};
|
|
73397
73573
|
this.fragmentSpreads = {};
|
|
73398
73574
|
this.filepath = args.filepath;
|
|
73399
|
-
for (const
|
|
73400
|
-
this.add(
|
|
73575
|
+
for (const selection of args.selections) {
|
|
73576
|
+
this.add(selection);
|
|
73401
73577
|
}
|
|
73402
73578
|
}
|
|
73403
73579
|
get size() {
|
|
73404
73580
|
return Object.keys(this.fields).length + Object.keys(this.inlineFragments).length + Object.keys(this.fragmentSpreads).length;
|
|
73405
73581
|
}
|
|
73406
|
-
add(
|
|
73407
|
-
if (
|
|
73408
|
-
const key =
|
|
73582
|
+
add(selection) {
|
|
73583
|
+
if (selection.kind === "Field") {
|
|
73584
|
+
const key = selection.alias?.value || selection.name.value;
|
|
73409
73585
|
if (!this.fields[key]) {
|
|
73410
73586
|
this.fields[key] = {
|
|
73411
|
-
astNode:
|
|
73587
|
+
astNode: selection,
|
|
73412
73588
|
selection: this.empty()
|
|
73413
73589
|
};
|
|
73414
73590
|
}
|
|
73415
|
-
for (const subselect of
|
|
73591
|
+
for (const subselect of selection.selectionSet?.selections || []) {
|
|
73416
73592
|
this.fields[key].selection.add(subselect);
|
|
73417
73593
|
}
|
|
73594
|
+
this.fields[key].selection.fragmentSpreads = {
|
|
73595
|
+
...this.collectFragmentSpreads(selection.selectionSet?.selections ?? []),
|
|
73596
|
+
...this.fields[key].selection.fragmentSpreads
|
|
73597
|
+
};
|
|
73418
73598
|
return;
|
|
73419
73599
|
}
|
|
73420
|
-
if (
|
|
73421
|
-
for (const subselect of
|
|
73600
|
+
if (selection.kind === "InlineFragment" && !selection.typeCondition) {
|
|
73601
|
+
for (const subselect of selection.selectionSet.selections) {
|
|
73422
73602
|
this.add(subselect);
|
|
73423
73603
|
}
|
|
73424
73604
|
}
|
|
73425
|
-
if (
|
|
73426
|
-
this.walkInlineFragment(
|
|
73605
|
+
if (selection.kind === "InlineFragment" && selection.typeCondition) {
|
|
73606
|
+
this.walkInlineFragment(selection);
|
|
73427
73607
|
return;
|
|
73428
73608
|
}
|
|
73429
|
-
if (
|
|
73430
|
-
this.fragmentSpreads[selection2.name.value] = selection2;
|
|
73609
|
+
if (selection.kind === "FragmentSpread") {
|
|
73431
73610
|
let includeFragments = this.config.defaultFragmentMasking === "disable";
|
|
73432
|
-
const maskEnableDirective =
|
|
73611
|
+
const maskEnableDirective = selection.directives?.find(
|
|
73433
73612
|
({ name }) => name.value === this.config.maskEnableDirective
|
|
73434
73613
|
);
|
|
73435
73614
|
if (maskEnableDirective) {
|
|
73436
73615
|
includeFragments = false;
|
|
73437
73616
|
}
|
|
73438
|
-
const maskDisableDirective =
|
|
73617
|
+
const maskDisableDirective = selection.directives?.find(
|
|
73439
73618
|
({ name }) => name.value === this.config.maskDisableDirective
|
|
73440
73619
|
);
|
|
73441
73620
|
if (maskDisableDirective) {
|
|
@@ -73444,14 +73623,17 @@ var FieldCollection = class {
|
|
|
73444
73623
|
if (this.ignoreMaskDisable) {
|
|
73445
73624
|
includeFragments = true;
|
|
73446
73625
|
}
|
|
73447
|
-
if (
|
|
73626
|
+
if (this.keepFragmentSpreadNodes) {
|
|
73627
|
+
this.fragmentSpreads[selection.name.value] = selection;
|
|
73628
|
+
}
|
|
73629
|
+
if (!includeFragments) {
|
|
73448
73630
|
return;
|
|
73449
73631
|
}
|
|
73450
|
-
const definition = this.fragmentDefinitions[
|
|
73632
|
+
const definition = this.fragmentDefinitions[selection.name.value];
|
|
73451
73633
|
if (!definition) {
|
|
73452
73634
|
throw new HoudiniError({
|
|
73453
73635
|
filepath: this.filepath,
|
|
73454
|
-
message: "Could not find referenced fragment definition: " +
|
|
73636
|
+
message: "Could not find referenced fragment definition: " + selection.name.value + "\n" + JSON.stringify(Object.keys(this.fragmentDefinitions), null, 4)
|
|
73455
73637
|
});
|
|
73456
73638
|
}
|
|
73457
73639
|
this.add({
|
|
@@ -73470,37 +73652,67 @@ var FieldCollection = class {
|
|
|
73470
73652
|
});
|
|
73471
73653
|
}
|
|
73472
73654
|
}
|
|
73655
|
+
collectFragmentSpreads(selections, result = {}) {
|
|
73656
|
+
for (const selection of selections) {
|
|
73657
|
+
if (selection.kind === "Field") {
|
|
73658
|
+
continue;
|
|
73659
|
+
}
|
|
73660
|
+
if (selection.kind === "InlineFragment") {
|
|
73661
|
+
this.collectFragmentSpreads(selection.selectionSet.selections, result);
|
|
73662
|
+
continue;
|
|
73663
|
+
}
|
|
73664
|
+
if (selection.kind === "FragmentSpread") {
|
|
73665
|
+
result[selection.name.value] = selection;
|
|
73666
|
+
continue;
|
|
73667
|
+
}
|
|
73668
|
+
}
|
|
73669
|
+
return result;
|
|
73670
|
+
}
|
|
73473
73671
|
toSelectionSet() {
|
|
73474
|
-
return Object.values(this.inlineFragments).flatMap((
|
|
73475
|
-
if (
|
|
73672
|
+
return Object.values(this.inlineFragments).flatMap((fragment2) => {
|
|
73673
|
+
if (fragment2.selection.size === 0) {
|
|
73476
73674
|
return [];
|
|
73477
73675
|
}
|
|
73478
|
-
|
|
73479
|
-
...
|
|
73676
|
+
fragment2.astNode = {
|
|
73677
|
+
...fragment2.astNode,
|
|
73480
73678
|
selectionSet: {
|
|
73481
|
-
...
|
|
73482
|
-
selections:
|
|
73679
|
+
...fragment2.astNode.selectionSet,
|
|
73680
|
+
selections: fragment2.selection.toSelectionSet()
|
|
73483
73681
|
}
|
|
73484
73682
|
};
|
|
73485
|
-
return [
|
|
73683
|
+
return [fragment2.astNode];
|
|
73486
73684
|
}).concat(
|
|
73487
73685
|
Object.values(this.fields).map((field) => {
|
|
73488
|
-
|
|
73489
|
-
field.astNode
|
|
73490
|
-
|
|
73491
|
-
|
|
73686
|
+
return {
|
|
73687
|
+
...field.astNode,
|
|
73688
|
+
selectionSet: field.astNode.selectionSet ? {
|
|
73689
|
+
kind: "SelectionSet",
|
|
73690
|
+
selections: field.selection.toSelectionSet()
|
|
73691
|
+
} : void 0
|
|
73692
|
+
};
|
|
73492
73693
|
})
|
|
73493
|
-
).concat(
|
|
73694
|
+
).concat(
|
|
73695
|
+
Object.values(this.fragmentSpreads).map((spread) => {
|
|
73696
|
+
return {
|
|
73697
|
+
kind: "FragmentSpread",
|
|
73698
|
+
name: {
|
|
73699
|
+
kind: "Name",
|
|
73700
|
+
value: spread.name.value
|
|
73701
|
+
},
|
|
73702
|
+
directives: spread.directives
|
|
73703
|
+
};
|
|
73704
|
+
})
|
|
73705
|
+
);
|
|
73494
73706
|
}
|
|
73495
|
-
walkInlineFragment(
|
|
73496
|
-
const key =
|
|
73707
|
+
walkInlineFragment(selection) {
|
|
73708
|
+
const key = selection.typeCondition.name.value;
|
|
73497
73709
|
if (!this.inlineFragments[key]) {
|
|
73498
73710
|
this.inlineFragments[key] = {
|
|
73499
|
-
astNode:
|
|
73711
|
+
astNode: selection,
|
|
73500
73712
|
selection: this.empty()
|
|
73501
73713
|
};
|
|
73502
73714
|
}
|
|
73503
|
-
for (const subselect of
|
|
73715
|
+
for (const subselect of selection.selectionSet.selections || []) {
|
|
73504
73716
|
if (subselect.kind !== "InlineFragment" || !subselect.typeCondition) {
|
|
73505
73717
|
this.inlineFragments[key].selection.add(subselect);
|
|
73506
73718
|
continue;
|
|
@@ -73514,8 +73726,8 @@ var FieldCollection = class {
|
|
|
73514
73726
|
fragmentDefinitions: this.fragmentDefinitions,
|
|
73515
73727
|
selections: [],
|
|
73516
73728
|
filepath: this.filepath,
|
|
73517
|
-
|
|
73518
|
-
|
|
73729
|
+
ignoreMaskDisable: this.ignoreMaskDisable,
|
|
73730
|
+
keepFragmentSpreadNodes: this.keepFragmentSpreadNodes
|
|
73519
73731
|
});
|
|
73520
73732
|
}
|
|
73521
73733
|
};
|
|
@@ -73593,13 +73805,13 @@ function murmurHash(str) {
|
|
|
73593
73805
|
// src/codegen/transforms/fragmentVariables.ts
|
|
73594
73806
|
var graphql5 = __toESM(require_graphql2(), 1);
|
|
73595
73807
|
|
|
73596
|
-
// src/codegen/transforms/
|
|
73808
|
+
// src/codegen/transforms/collectDefinitions.ts
|
|
73597
73809
|
var import_graphql30 = __toESM(require_graphql2(), 1);
|
|
73598
73810
|
async function includeFragmentDefinitions(config2, documents) {
|
|
73599
|
-
const fragments =
|
|
73811
|
+
const fragments = collectDefinitions(config2, documents);
|
|
73600
73812
|
for (const [index, { name, document, filename }] of documents.entries()) {
|
|
73601
73813
|
const operation = document.definitions.find(
|
|
73602
|
-
(
|
|
73814
|
+
(def) => def.kind === import_graphql30.Kind.OPERATION_DEFINITION || def.kind === "FragmentDefinition"
|
|
73603
73815
|
);
|
|
73604
73816
|
if (!operation) {
|
|
73605
73817
|
continue;
|
|
@@ -73618,7 +73830,7 @@ async function includeFragmentDefinitions(config2, documents) {
|
|
|
73618
73830
|
};
|
|
73619
73831
|
}
|
|
73620
73832
|
}
|
|
73621
|
-
function
|
|
73833
|
+
function collectDefinitions(config2, docs) {
|
|
73622
73834
|
return docs.reduce((acc, doc) => {
|
|
73623
73835
|
const definitions = doc.document.definitions.reduce(
|
|
73624
73836
|
(prev, definition) => definition.kind !== "FragmentDefinition" ? prev : {
|
|
@@ -73642,11 +73854,11 @@ function findRequiredFragments(selectionSet) {
|
|
|
73642
73854
|
return [];
|
|
73643
73855
|
}
|
|
73644
73856
|
const referencedFragments = [];
|
|
73645
|
-
for (const
|
|
73646
|
-
if (
|
|
73647
|
-
referencedFragments.push(
|
|
73648
|
-
} else if (
|
|
73649
|
-
referencedFragments.push(...findRequiredFragments(
|
|
73857
|
+
for (const selection of selectionSet.selections) {
|
|
73858
|
+
if (selection.kind === import_graphql30.Kind.FRAGMENT_SPREAD) {
|
|
73859
|
+
referencedFragments.push(selection.name.value);
|
|
73860
|
+
} else if (selection.selectionSet) {
|
|
73861
|
+
referencedFragments.push(...findRequiredFragments(selection.selectionSet));
|
|
73650
73862
|
}
|
|
73651
73863
|
}
|
|
73652
73864
|
return referencedFragments;
|
|
@@ -73679,7 +73891,7 @@ function flattenFragments(filepath, operation, fragments) {
|
|
|
73679
73891
|
// src/codegen/transforms/fragmentVariables.ts
|
|
73680
73892
|
var GraphqlKinds2 = graphql5.Kind;
|
|
73681
73893
|
async function fragmentVariables(config2, documents) {
|
|
73682
|
-
const fragments =
|
|
73894
|
+
const fragments = collectDefinitions(config2, documents);
|
|
73683
73895
|
const generatedFragments = {};
|
|
73684
73896
|
const visitedFragments = /* @__PURE__ */ new Set();
|
|
73685
73897
|
for (const doc2 of documents) {
|
|
@@ -73739,9 +73951,17 @@ function inlineFragmentArgs({
|
|
|
73739
73951
|
).reduce((acc, arg) => ({ ...acc, [arg.name]: arg }), {});
|
|
73740
73952
|
const result = graphql5.visit(document, {
|
|
73741
73953
|
FragmentSpread(node) {
|
|
73954
|
+
if (!fragmentDefinitions[node.name.value]) {
|
|
73955
|
+
throw new Error("Could not find definition for fragment" + node.name.value);
|
|
73956
|
+
}
|
|
73742
73957
|
const { definition } = fragmentDefinitions[node.name.value];
|
|
73743
73958
|
let { args, hash } = collectWithArguments(config2, filepath, node, scope);
|
|
73744
73959
|
const newFragmentName = `${node.name.value}${hash}`;
|
|
73960
|
+
config2.registerFragmentVariablesHash({
|
|
73961
|
+
hash: newFragmentName,
|
|
73962
|
+
fragment: node.name.value,
|
|
73963
|
+
args
|
|
73964
|
+
});
|
|
73745
73965
|
if (!visitedFragments.has(newFragmentName)) {
|
|
73746
73966
|
visitedFragments.add(newFragmentName);
|
|
73747
73967
|
const defaultArguments = collectDefaultArgumentValues(config2, filepath, definition);
|
|
@@ -74140,7 +74360,7 @@ function operationObject({
|
|
|
74140
74360
|
listName,
|
|
74141
74361
|
operationKind,
|
|
74142
74362
|
type,
|
|
74143
|
-
selection
|
|
74363
|
+
selection,
|
|
74144
74364
|
filepath
|
|
74145
74365
|
}) {
|
|
74146
74366
|
let parentID;
|
|
@@ -74148,7 +74368,7 @@ function operationObject({
|
|
|
74148
74368
|
let position = config2.internalListPosition;
|
|
74149
74369
|
let allLists = config2.defaultListTarget ?? void 0;
|
|
74150
74370
|
let operationWhen;
|
|
74151
|
-
const internalDirectives =
|
|
74371
|
+
const internalDirectives = selection.directives?.filter(
|
|
74152
74372
|
(directive) => config2.isInternalDirective(directive.name.value)
|
|
74153
74373
|
);
|
|
74154
74374
|
if (internalDirectives && internalDirectives.length > 0) {
|
|
@@ -74384,7 +74604,7 @@ async function paginate(config2, documents) {
|
|
|
74384
74604
|
let fragmentName = "";
|
|
74385
74605
|
let refetchQueryName = "";
|
|
74386
74606
|
let nodeQuery = false;
|
|
74387
|
-
let
|
|
74607
|
+
let fragment2 = "";
|
|
74388
74608
|
let paginateMode = config2.defaultPaginateMode;
|
|
74389
74609
|
doc.document = graphql10.visit(doc.document, {
|
|
74390
74610
|
OperationDefinition(node) {
|
|
@@ -74427,7 +74647,7 @@ async function paginate(config2, documents) {
|
|
|
74427
74647
|
};
|
|
74428
74648
|
},
|
|
74429
74649
|
FragmentDefinition(node) {
|
|
74430
|
-
|
|
74650
|
+
fragment2 = node.typeCondition.name.value;
|
|
74431
74651
|
fragmentName = node.name.value;
|
|
74432
74652
|
refetchQueryName = config2.paginationQueryName(fragmentName);
|
|
74433
74653
|
nodeQuery = node.typeCondition.name.value !== config2.schema.getQueryType()?.name;
|
|
@@ -74474,17 +74694,17 @@ async function paginate(config2, documents) {
|
|
|
74474
74694
|
}
|
|
74475
74695
|
});
|
|
74476
74696
|
let targetType = config2.schema.getQueryType()?.name || "";
|
|
74477
|
-
if (
|
|
74697
|
+
if (fragment2) {
|
|
74478
74698
|
const nodeInterface = config2.schema.getType("Node");
|
|
74479
74699
|
if (nodeInterface) {
|
|
74480
74700
|
const { objects, interfaces } = config2.schema.getImplementations(nodeInterface);
|
|
74481
|
-
if (objects.find((obj) => obj.name ===
|
|
74701
|
+
if (objects.find((obj) => obj.name === fragment2) || interfaces.find((int) => int.name === fragment2)) {
|
|
74482
74702
|
targetType = "Node";
|
|
74483
74703
|
} else {
|
|
74484
|
-
targetType =
|
|
74704
|
+
targetType = fragment2;
|
|
74485
74705
|
}
|
|
74486
74706
|
} else {
|
|
74487
|
-
targetType =
|
|
74707
|
+
targetType = fragment2;
|
|
74488
74708
|
}
|
|
74489
74709
|
}
|
|
74490
74710
|
const pageSize = flags.first.defaultValue ?? flags.last.defaultValue ?? flags.limit.defaultValue;
|
|
@@ -74506,7 +74726,7 @@ async function paginate(config2, documents) {
|
|
|
74506
74726
|
start,
|
|
74507
74727
|
mode: paginateMode
|
|
74508
74728
|
};
|
|
74509
|
-
if (!
|
|
74729
|
+
if (!fragment2) {
|
|
74510
74730
|
continue;
|
|
74511
74731
|
}
|
|
74512
74732
|
const paginationArgs = Object.entries(flags).filter(([_, { enabled }]) => enabled).map(([key, value]) => ({ name: key, ...value }));
|
|
@@ -74527,15 +74747,22 @@ async function paginate(config2, documents) {
|
|
|
74527
74747
|
["arguments"]: paginationArgs.map(
|
|
74528
74748
|
({ name }) => variableAsArgument(name)
|
|
74529
74749
|
)
|
|
74750
|
+
},
|
|
74751
|
+
{
|
|
74752
|
+
kind: graphql10.Kind.DIRECTIVE,
|
|
74753
|
+
name: {
|
|
74754
|
+
kind: "Name",
|
|
74755
|
+
value: config2.maskDisableDirective
|
|
74756
|
+
}
|
|
74530
74757
|
}
|
|
74531
74758
|
]
|
|
74532
74759
|
}
|
|
74533
74760
|
];
|
|
74534
|
-
const keys = config2.keyFieldsForType(!nodeQuery ? config2.schema.getQueryType()?.name || "" :
|
|
74535
|
-
if (
|
|
74761
|
+
const keys = config2.keyFieldsForType(!nodeQuery ? config2.schema.getQueryType()?.name || "" : fragment2).flatMap((key) => {
|
|
74762
|
+
if (fragment2 === config2.schema.getQueryType()?.name) {
|
|
74536
74763
|
return [];
|
|
74537
74764
|
}
|
|
74538
|
-
const fragmentType = config2.schema.getType(
|
|
74765
|
+
const fragmentType = config2.schema.getType(fragment2);
|
|
74539
74766
|
const { type, wrappers } = unwrapType(
|
|
74540
74767
|
config2,
|
|
74541
74768
|
fragmentType.getFields()[key].type
|
|
@@ -74547,7 +74774,7 @@ async function paginate(config2, documents) {
|
|
|
74547
74774
|
}
|
|
74548
74775
|
];
|
|
74549
74776
|
});
|
|
74550
|
-
const typeConfig = config2.typeConfig?.[
|
|
74777
|
+
const typeConfig = config2.typeConfig?.[fragment2];
|
|
74551
74778
|
const queryDoc = {
|
|
74552
74779
|
kind: graphql10.Kind.DOCUMENT,
|
|
74553
74780
|
definitions: [
|
|
@@ -74889,7 +75116,7 @@ async function addListFragments(config2, documents) {
|
|
|
74889
75116
|
);
|
|
74890
75117
|
const targetField = ancestors[ancestors.length - 1];
|
|
74891
75118
|
const targetFieldDefinition = parentType.getFields()[targetField.name.value];
|
|
74892
|
-
const { selection
|
|
75119
|
+
const { selection, type, connection } = connectionSelection(
|
|
74893
75120
|
config2,
|
|
74894
75121
|
targetFieldDefinition,
|
|
74895
75122
|
parentTypeFromAncestors(
|
|
@@ -74900,7 +75127,7 @@ async function addListFragments(config2, documents) {
|
|
|
74900
75127
|
ancestors[ancestors.length - 1].selectionSet
|
|
74901
75128
|
);
|
|
74902
75129
|
lists[nameArg.value.value] = {
|
|
74903
|
-
selection
|
|
75130
|
+
selection,
|
|
74904
75131
|
type,
|
|
74905
75132
|
filename: doc.filename
|
|
74906
75133
|
};
|
|
@@ -74978,14 +75205,14 @@ async function addListFragments(config2, documents) {
|
|
|
74978
75205
|
const generatedDoc = {
|
|
74979
75206
|
kind: graphql11.Kind.DOCUMENT,
|
|
74980
75207
|
definitions: Object.entries(lists).flatMap(
|
|
74981
|
-
([name, { selection
|
|
75208
|
+
([name, { selection, type }]) => {
|
|
74982
75209
|
const schemaType = config2.schema.getType(type.name);
|
|
74983
|
-
if (!
|
|
75210
|
+
if (!selection) {
|
|
74984
75211
|
throw new HoudiniError({ message: "Lists must have a selection" });
|
|
74985
75212
|
}
|
|
74986
75213
|
const fragmentSelection = {
|
|
74987
75214
|
kind: graphql11.Kind.SELECTION_SET,
|
|
74988
|
-
selections: [...
|
|
75215
|
+
selections: [...selection.selections]
|
|
74989
75216
|
};
|
|
74990
75217
|
if (schemaType && fragmentSelection && !fragmentSelection?.selections.find(
|
|
74991
75218
|
(field) => field.kind === "Field" && config2.keyFieldsForType(type.name).includes(field.name.value)
|
|
@@ -75077,7 +75304,7 @@ async function addListFragments(config2, documents) {
|
|
|
75077
75304
|
artifact: null
|
|
75078
75305
|
});
|
|
75079
75306
|
}
|
|
75080
|
-
function connectionSelection(config2, field, type,
|
|
75307
|
+
function connectionSelection(config2, field, type, selection) {
|
|
75081
75308
|
const fieldArgs = field.args.reduce(
|
|
75082
75309
|
(args, arg) => ({
|
|
75083
75310
|
...args,
|
|
@@ -75086,34 +75313,34 @@ function connectionSelection(config2, field, type, selection2) {
|
|
|
75086
75313
|
{}
|
|
75087
75314
|
);
|
|
75088
75315
|
if (fieldArgs["limit"]) {
|
|
75089
|
-
return { selection
|
|
75316
|
+
return { selection, type, connection: false, error: null };
|
|
75090
75317
|
}
|
|
75091
75318
|
const forwardPagination = fieldArgs["first"] === "Int" && ["Cursor", "String"].includes(fieldArgs["after"]);
|
|
75092
75319
|
const backwardsPagination = fieldArgs["last"] === "Int" && ["Cursor", "String"].includes(fieldArgs["before"]);
|
|
75093
75320
|
if (!forwardPagination && !backwardsPagination) {
|
|
75094
|
-
return { selection
|
|
75321
|
+
return { selection, type, connection: false, error: missingPaginationArgMessage(config2) };
|
|
75095
75322
|
}
|
|
75096
|
-
const edgesField =
|
|
75097
|
-
(
|
|
75323
|
+
const edgesField = selection?.selections.find(
|
|
75324
|
+
(selection2) => selection2.kind === "Field" && selection2.name.value === "edges"
|
|
75098
75325
|
);
|
|
75099
75326
|
if (!edgesField) {
|
|
75100
|
-
return { selection
|
|
75327
|
+
return { selection, type, connection: false, error: missingEdgeSelectionMessage(config2) };
|
|
75101
75328
|
}
|
|
75102
75329
|
const nodeSelection = edgesField.selectionSet?.selections.find(
|
|
75103
|
-
(
|
|
75330
|
+
(selection2) => selection2.kind === "Field" && selection2.name.value === "node"
|
|
75104
75331
|
);
|
|
75105
75332
|
if (!nodeSelection.selectionSet) {
|
|
75106
|
-
return { selection
|
|
75333
|
+
return { selection, type, connection: false, error: missingNodeSelectionMessage(config2) };
|
|
75107
75334
|
}
|
|
75108
75335
|
const edgeField = unwrapType(config2, field.type).type.getFields()["edges"];
|
|
75109
75336
|
const { wrappers, type: edgeFieldType } = unwrapType(config2, edgeField.type);
|
|
75110
75337
|
const list = wrappers[wrappers.length - 2] === "List" /* List */;
|
|
75111
75338
|
if (!list) {
|
|
75112
|
-
return { selection
|
|
75339
|
+
return { selection, type, connection: false, error: edgeInvalidTypeMessage(config2) };
|
|
75113
75340
|
}
|
|
75114
75341
|
const nodeField = edgeFieldType.getFields()["node"];
|
|
75115
75342
|
if (!nodeField) {
|
|
75116
|
-
return { selection
|
|
75343
|
+
return { selection, type, connection: false, error: nodeNotDefinedMessage(config2) };
|
|
75117
75344
|
}
|
|
75118
75345
|
return {
|
|
75119
75346
|
selection: nodeSelection.selectionSet,
|
|
@@ -75192,59 +75419,45 @@ function fieldKey(config2, field) {
|
|
|
75192
75419
|
}
|
|
75193
75420
|
|
|
75194
75421
|
// src/codegen/generators/artifacts/selection.ts
|
|
75195
|
-
function
|
|
75422
|
+
function selection_default(args) {
|
|
75423
|
+
const typeMap = {};
|
|
75424
|
+
const abstractTypes = [];
|
|
75425
|
+
return mergeSelection({
|
|
75426
|
+
object: prepareSelection({ ...args, typeMap, abstractTypes }),
|
|
75427
|
+
filepath: args.filepath,
|
|
75428
|
+
typeMap,
|
|
75429
|
+
abstractTypes
|
|
75430
|
+
});
|
|
75431
|
+
}
|
|
75432
|
+
function prepareSelection({
|
|
75196
75433
|
config: config2,
|
|
75197
75434
|
filepath,
|
|
75198
75435
|
rootType,
|
|
75199
75436
|
selections,
|
|
75200
75437
|
operations,
|
|
75201
75438
|
path: path2 = [],
|
|
75202
|
-
includeFragments,
|
|
75203
75439
|
document,
|
|
75204
|
-
inConnection
|
|
75440
|
+
inConnection,
|
|
75441
|
+
typeMap,
|
|
75442
|
+
abstractTypes
|
|
75205
75443
|
}) {
|
|
75206
75444
|
let object = {};
|
|
75207
|
-
const typeMap = {};
|
|
75208
|
-
const abstractTypes = [];
|
|
75209
75445
|
for (const field of selections) {
|
|
75210
|
-
if (field.kind === "
|
|
75211
|
-
const fragmentDefinition = document.document.definitions.find(
|
|
75212
|
-
(defn) => defn.kind === "FragmentDefinition" && defn.name.value === field.name.value
|
|
75213
|
-
);
|
|
75214
|
-
if (!fragmentDefinition) {
|
|
75215
|
-
throw new HoudiniError({
|
|
75216
|
-
filepath,
|
|
75217
|
-
message: "selection: could not find definition for fragment " + field.name.value
|
|
75218
|
-
});
|
|
75219
|
-
}
|
|
75220
|
-
object = deepMerge(
|
|
75221
|
-
filepath,
|
|
75222
|
-
object,
|
|
75223
|
-
selection({
|
|
75224
|
-
config: config2,
|
|
75225
|
-
filepath,
|
|
75226
|
-
rootType: fragmentDefinition.typeCondition.name.value,
|
|
75227
|
-
operations,
|
|
75228
|
-
selections: fragmentDefinition.selectionSet.selections,
|
|
75229
|
-
path: path2,
|
|
75230
|
-
includeFragments,
|
|
75231
|
-
document
|
|
75232
|
-
})
|
|
75233
|
-
);
|
|
75234
|
-
} else if (field.kind === "InlineFragment") {
|
|
75446
|
+
if (field.kind === "InlineFragment") {
|
|
75235
75447
|
if (!field.typeCondition || field.typeCondition.name.value === rootType) {
|
|
75236
75448
|
object.fields = deepMerge(
|
|
75237
75449
|
filepath,
|
|
75238
75450
|
object.fields || {},
|
|
75239
|
-
|
|
75451
|
+
prepareSelection({
|
|
75240
75452
|
config: config2,
|
|
75241
75453
|
filepath,
|
|
75242
75454
|
rootType: field.typeCondition?.name.value || rootType,
|
|
75243
75455
|
operations,
|
|
75244
75456
|
selections: field.selectionSet.selections,
|
|
75245
75457
|
path: path2,
|
|
75246
|
-
|
|
75247
|
-
|
|
75458
|
+
document,
|
|
75459
|
+
typeMap,
|
|
75460
|
+
abstractTypes
|
|
75248
75461
|
}).fields || {}
|
|
75249
75462
|
);
|
|
75250
75463
|
} else {
|
|
@@ -75282,15 +75495,16 @@ function selection({
|
|
|
75282
75495
|
}
|
|
75283
75496
|
object.abstractFields.fields = {
|
|
75284
75497
|
...object.abstractFields.fields,
|
|
75285
|
-
[field.typeCondition.name.value]:
|
|
75498
|
+
[field.typeCondition.name.value]: prepareSelection({
|
|
75286
75499
|
config: config2,
|
|
75287
75500
|
filepath,
|
|
75288
75501
|
rootType: field.typeCondition?.name.value || rootType,
|
|
75289
75502
|
operations,
|
|
75290
75503
|
selections: field.selectionSet.selections,
|
|
75291
75504
|
path: path2,
|
|
75292
|
-
|
|
75293
|
-
|
|
75505
|
+
document,
|
|
75506
|
+
typeMap,
|
|
75507
|
+
abstractTypes
|
|
75294
75508
|
}).fields
|
|
75295
75509
|
};
|
|
75296
75510
|
}
|
|
@@ -75311,10 +75525,14 @@ function selection({
|
|
|
75311
75525
|
}
|
|
75312
75526
|
const typeName = fieldType.toString();
|
|
75313
75527
|
const pathSoFar = path2.concat(attributeName);
|
|
75314
|
-
const
|
|
75528
|
+
const keys = config2.keyFieldsForType(rootType);
|
|
75529
|
+
let fieldObj = {
|
|
75315
75530
|
type: typeName,
|
|
75316
75531
|
keyRaw: fieldKey(config2, field)
|
|
75317
75532
|
};
|
|
75533
|
+
if (keys.includes(field.name.value)) {
|
|
75534
|
+
fieldObj.visible = true;
|
|
75535
|
+
}
|
|
75318
75536
|
if (nullable) {
|
|
75319
75537
|
fieldObj.nullable = true;
|
|
75320
75538
|
}
|
|
@@ -75362,16 +75580,17 @@ function selection({
|
|
|
75362
75580
|
}
|
|
75363
75581
|
if (field.selectionSet) {
|
|
75364
75582
|
const connectionState = paginated && document.refetch?.method === "cursor" || continueConnection;
|
|
75365
|
-
fieldObj.selection =
|
|
75583
|
+
fieldObj.selection = prepareSelection({
|
|
75366
75584
|
config: config2,
|
|
75367
75585
|
filepath,
|
|
75368
75586
|
rootType: typeName,
|
|
75369
75587
|
selections: field.selectionSet.selections,
|
|
75370
75588
|
operations,
|
|
75371
75589
|
path: pathSoFar,
|
|
75372
|
-
includeFragments,
|
|
75373
75590
|
document,
|
|
75374
|
-
inConnection: connectionState
|
|
75591
|
+
inConnection: connectionState,
|
|
75592
|
+
typeMap,
|
|
75593
|
+
abstractTypes
|
|
75375
75594
|
});
|
|
75376
75595
|
}
|
|
75377
75596
|
if (field.arguments?.length && fieldObj.list) {
|
|
@@ -75386,12 +75605,29 @@ function selection({
|
|
|
75386
75605
|
if (graphql13.isInterfaceType(fieldType) || graphql13.isUnionType(fieldType)) {
|
|
75387
75606
|
fieldObj.abstract = true;
|
|
75388
75607
|
}
|
|
75608
|
+
if (object.fields?.[attributeName]) {
|
|
75609
|
+
fieldObj = deepMerge(filepath, object.fields[attributeName], fieldObj);
|
|
75610
|
+
}
|
|
75389
75611
|
object.fields = {
|
|
75390
75612
|
...object.fields,
|
|
75391
75613
|
[attributeName]: fieldObj
|
|
75392
75614
|
};
|
|
75615
|
+
} else if (field.kind === "FragmentSpread") {
|
|
75616
|
+
const { fragment: fragment2, args } = config2.getFragmentVariablesHash(field.name.value);
|
|
75617
|
+
object.fragments = {
|
|
75618
|
+
...object.fragments,
|
|
75619
|
+
[fragment2]: args ?? {}
|
|
75620
|
+
};
|
|
75393
75621
|
}
|
|
75394
75622
|
}
|
|
75623
|
+
return object;
|
|
75624
|
+
}
|
|
75625
|
+
function mergeSelection({
|
|
75626
|
+
filepath,
|
|
75627
|
+
object,
|
|
75628
|
+
typeMap,
|
|
75629
|
+
abstractTypes
|
|
75630
|
+
}) {
|
|
75395
75631
|
if (Object.keys(object.fields || {}).length > 0 && object.abstractFields && Object.keys(object.abstractFields.fields).length > 0) {
|
|
75396
75632
|
for (const [typeName, possibles] of Object.entries(typeMap)) {
|
|
75397
75633
|
let overlap = false;
|
|
@@ -75399,8 +75635,8 @@ function selection({
|
|
|
75399
75635
|
if (object.abstractFields.fields[typeName]) {
|
|
75400
75636
|
object.abstractFields.fields[typeName] = deepMerge(
|
|
75401
75637
|
filepath,
|
|
75402
|
-
object.abstractFields.fields[typeName]
|
|
75403
|
-
object.abstractFields.fields[possible]
|
|
75638
|
+
object.abstractFields.fields[typeName] ?? {},
|
|
75639
|
+
object.abstractFields.fields[possible] ?? {}
|
|
75404
75640
|
);
|
|
75405
75641
|
overlap = true;
|
|
75406
75642
|
}
|
|
@@ -75431,6 +75667,30 @@ function selection({
|
|
|
75431
75667
|
}
|
|
75432
75668
|
}
|
|
75433
75669
|
}
|
|
75670
|
+
for (const [key, value] of Object.entries(object.fields ?? {})) {
|
|
75671
|
+
const selection = value.selection;
|
|
75672
|
+
if (selection) {
|
|
75673
|
+
mergeSelection({
|
|
75674
|
+
filepath,
|
|
75675
|
+
typeMap,
|
|
75676
|
+
abstractTypes,
|
|
75677
|
+
object: selection
|
|
75678
|
+
});
|
|
75679
|
+
}
|
|
75680
|
+
}
|
|
75681
|
+
for (const [type, selection] of Object.entries(object.abstractFields?.fields ?? {})) {
|
|
75682
|
+
for (const [key, value] of Object.entries(selection ?? {})) {
|
|
75683
|
+
const selection2 = value.selection;
|
|
75684
|
+
if (selection2) {
|
|
75685
|
+
mergeSelection({
|
|
75686
|
+
filepath,
|
|
75687
|
+
typeMap,
|
|
75688
|
+
abstractTypes,
|
|
75689
|
+
object: selection2
|
|
75690
|
+
});
|
|
75691
|
+
}
|
|
75692
|
+
}
|
|
75693
|
+
}
|
|
75434
75694
|
return object;
|
|
75435
75695
|
}
|
|
75436
75696
|
|
|
@@ -75495,7 +75755,12 @@ function artifactGenerator(stats) {
|
|
|
75495
75755
|
writeIndexFile(config2, docs)
|
|
75496
75756
|
].concat(
|
|
75497
75757
|
docs.map(async (doc) => {
|
|
75498
|
-
const {
|
|
75758
|
+
const {
|
|
75759
|
+
document,
|
|
75760
|
+
name,
|
|
75761
|
+
generateArtifact,
|
|
75762
|
+
originalParsed
|
|
75763
|
+
} = doc;
|
|
75499
75764
|
if (!generateArtifact) {
|
|
75500
75765
|
return;
|
|
75501
75766
|
}
|
|
@@ -75534,6 +75799,16 @@ function artifactGenerator(stats) {
|
|
|
75534
75799
|
);
|
|
75535
75800
|
let rootType = "";
|
|
75536
75801
|
let selectionSet;
|
|
75802
|
+
let originalSelectionSet = null;
|
|
75803
|
+
const fragmentDefinitions = doc.document.definitions.filter(
|
|
75804
|
+
(definition) => definition.kind === "FragmentDefinition"
|
|
75805
|
+
).reduce(
|
|
75806
|
+
(prev, definition) => ({
|
|
75807
|
+
...prev,
|
|
75808
|
+
[definition.name.value]: definition
|
|
75809
|
+
}),
|
|
75810
|
+
{}
|
|
75811
|
+
);
|
|
75537
75812
|
if (docKind !== ArtifactKind.Fragment) {
|
|
75538
75813
|
const operation = operations[0];
|
|
75539
75814
|
if (operation.operation === "query") {
|
|
@@ -75550,9 +75825,12 @@ function artifactGenerator(stats) {
|
|
|
75550
75825
|
});
|
|
75551
75826
|
}
|
|
75552
75827
|
selectionSet = operation.selectionSet;
|
|
75828
|
+
if (originalParsed.definitions[0].kind === "OperationDefinition") {
|
|
75829
|
+
originalSelectionSet = originalParsed.definitions[0].selectionSet;
|
|
75830
|
+
}
|
|
75553
75831
|
} else {
|
|
75554
75832
|
const matchingFragment = fragments.find(
|
|
75555
|
-
(
|
|
75833
|
+
(fragment2) => fragment2.name.value === name
|
|
75556
75834
|
);
|
|
75557
75835
|
if (!matchingFragment) {
|
|
75558
75836
|
throw new HoudiniError({
|
|
@@ -75562,6 +75840,12 @@ function artifactGenerator(stats) {
|
|
|
75562
75840
|
}
|
|
75563
75841
|
rootType = matchingFragment.typeCondition.name.value;
|
|
75564
75842
|
selectionSet = matchingFragment.selectionSet;
|
|
75843
|
+
if (originalParsed.definitions[0].kind === "FragmentDefinition") {
|
|
75844
|
+
originalSelectionSet = originalParsed.definitions[0].selectionSet;
|
|
75845
|
+
}
|
|
75846
|
+
}
|
|
75847
|
+
if (!originalSelectionSet) {
|
|
75848
|
+
throw new Error("Not original selection set!");
|
|
75565
75849
|
}
|
|
75566
75850
|
let inputs = operations[0]?.variableDefinitions;
|
|
75567
75851
|
let directive = fragments[0]?.directives?.find(
|
|
@@ -75570,21 +75854,18 @@ function artifactGenerator(stats) {
|
|
|
75570
75854
|
if (docKind === ArtifactKind.Fragment && directive) {
|
|
75571
75855
|
inputs = fragmentArgumentsDefinitions(config2, doc.filename, fragments[0]);
|
|
75572
75856
|
}
|
|
75573
|
-
const
|
|
75857
|
+
const mask = selection_default({
|
|
75574
75858
|
config: config2,
|
|
75575
75859
|
filepath: doc.filename,
|
|
75576
|
-
|
|
75577
|
-
|
|
75578
|
-
|
|
75579
|
-
|
|
75580
|
-
|
|
75581
|
-
|
|
75582
|
-
|
|
75583
|
-
|
|
75584
|
-
|
|
75585
|
-
),
|
|
75586
|
-
ignoreMaskDisable: docKind === "HoudiniQuery",
|
|
75587
|
-
applyFragments: docKind !== "HoudiniFragment"
|
|
75860
|
+
rootType,
|
|
75861
|
+
operations: {},
|
|
75862
|
+
document: doc,
|
|
75863
|
+
selections: flattenSelections({
|
|
75864
|
+
config: config2,
|
|
75865
|
+
filepath: doc.filename,
|
|
75866
|
+
selections: selectionSet.selections,
|
|
75867
|
+
fragmentDefinitions
|
|
75868
|
+
})
|
|
75588
75869
|
});
|
|
75589
75870
|
let artifact = {
|
|
75590
75871
|
name,
|
|
@@ -75593,21 +75874,29 @@ function artifactGenerator(stats) {
|
|
|
75593
75874
|
refetch: doc.refetch,
|
|
75594
75875
|
raw: rawString,
|
|
75595
75876
|
rootType,
|
|
75596
|
-
selection:
|
|
75877
|
+
selection: selection_default({
|
|
75597
75878
|
config: config2,
|
|
75598
75879
|
filepath: doc.filename,
|
|
75599
75880
|
rootType,
|
|
75600
|
-
selections:
|
|
75881
|
+
selections: flattenSelections({
|
|
75882
|
+
config: config2,
|
|
75883
|
+
filepath: doc.filename,
|
|
75884
|
+
selections: selectionSet.selections,
|
|
75885
|
+
fragmentDefinitions,
|
|
75886
|
+
ignoreMaskDisable: docKind !== "HoudiniFragment",
|
|
75887
|
+
keepFragmentSpreadNodes: true
|
|
75888
|
+
}),
|
|
75601
75889
|
operations: operationsByPath(
|
|
75602
75890
|
config2,
|
|
75603
75891
|
doc.filename,
|
|
75604
75892
|
operations[0],
|
|
75605
75893
|
filterTypes
|
|
75606
75894
|
),
|
|
75607
|
-
includeFragments: docKind !== "HoudiniFragment",
|
|
75608
75895
|
document: doc
|
|
75609
|
-
})
|
|
75896
|
+
}),
|
|
75897
|
+
pluginData: {}
|
|
75610
75898
|
};
|
|
75899
|
+
applyMask(config2, artifact.selection, mask);
|
|
75611
75900
|
artifact.pluginData = {};
|
|
75612
75901
|
for (const plugin2 of config2.plugins) {
|
|
75613
75902
|
if (!plugin2.artifactData) {
|
|
@@ -75684,6 +75973,49 @@ function artifactGenerator(stats) {
|
|
|
75684
75973
|
stats.deleted = await cleanupFiles(config2.artifactDirectory, listOfArtifacts);
|
|
75685
75974
|
};
|
|
75686
75975
|
}
|
|
75976
|
+
function applyMask(config2, target, mask) {
|
|
75977
|
+
for (const [fieldName, value] of Object.entries(mask.fields ?? {})) {
|
|
75978
|
+
const targetSelection = target.fields?.[fieldName];
|
|
75979
|
+
if (!targetSelection || !mask.fields) {
|
|
75980
|
+
continue;
|
|
75981
|
+
}
|
|
75982
|
+
targetSelection.visible = true;
|
|
75983
|
+
if (targetSelection.selection && value.selection) {
|
|
75984
|
+
applyMask(config2, targetSelection.selection, value.selection);
|
|
75985
|
+
}
|
|
75986
|
+
}
|
|
75987
|
+
for (const [type, selection] of Object.entries(mask.abstractFields?.fields ?? {})) {
|
|
75988
|
+
if (!selection) {
|
|
75989
|
+
continue;
|
|
75990
|
+
}
|
|
75991
|
+
if (target.abstractFields?.fields[type]) {
|
|
75992
|
+
applyMask(config2, { fields: target.abstractFields.fields[type] }, { fields: selection });
|
|
75993
|
+
}
|
|
75994
|
+
const targetType = config2.schema.getType(type);
|
|
75995
|
+
if (!targetType) {
|
|
75996
|
+
continue;
|
|
75997
|
+
}
|
|
75998
|
+
if (graphql14.isAbstractType(targetType)) {
|
|
75999
|
+
for (const possible of config2.schema.getPossibleTypes(targetType)) {
|
|
76000
|
+
if (target.abstractFields?.fields[possible.name]) {
|
|
76001
|
+
applyMask(
|
|
76002
|
+
config2,
|
|
76003
|
+
{ fields: target.abstractFields.fields[possible.name] },
|
|
76004
|
+
{ fields: selection }
|
|
76005
|
+
);
|
|
76006
|
+
}
|
|
76007
|
+
}
|
|
76008
|
+
}
|
|
76009
|
+
const mappedType = target.abstractFields?.typeMap[type];
|
|
76010
|
+
if (target.abstractFields && mappedType && target.abstractFields.fields[mappedType]) {
|
|
76011
|
+
applyMask(
|
|
76012
|
+
config2,
|
|
76013
|
+
{ fields: target.abstractFields.fields[mappedType] },
|
|
76014
|
+
{ fields: selection }
|
|
76015
|
+
);
|
|
76016
|
+
}
|
|
76017
|
+
}
|
|
76018
|
+
}
|
|
75687
76019
|
|
|
75688
76020
|
// src/codegen/generators/runtime/graphqlFunction.ts
|
|
75689
76021
|
var recast6 = __toESM(require_main2(), 1);
|
|
@@ -76009,7 +76341,7 @@ function addReferencedInputTypes(config2, filepath, body, visitedTypes, missingS
|
|
|
76009
76341
|
var graphql18 = __toESM(require_graphql2(), 1);
|
|
76010
76342
|
var recast10 = __toESM(require_main2(), 1);
|
|
76011
76343
|
var AST10 = recast10.types.builders;
|
|
76012
|
-
var
|
|
76344
|
+
var fragmentKey2 = " $fragments";
|
|
76013
76345
|
function inlineType({
|
|
76014
76346
|
config: config2,
|
|
76015
76347
|
filepath,
|
|
@@ -76049,24 +76381,24 @@ function inlineType({
|
|
|
76049
76381
|
const rootObj = type;
|
|
76050
76382
|
const inlineFragments = {};
|
|
76051
76383
|
const selectedFields = [];
|
|
76052
|
-
for (const
|
|
76053
|
-
if (
|
|
76054
|
-
const fragmentType = config2.schema.getType(
|
|
76384
|
+
for (const selection of selections) {
|
|
76385
|
+
if (selection.kind === "InlineFragment" && selection.typeCondition) {
|
|
76386
|
+
const fragmentType = config2.schema.getType(selection.typeCondition.name.value);
|
|
76055
76387
|
if (!graphql18.isInterfaceType(type) && !graphql18.isUnionType(type)) {
|
|
76056
|
-
selectedFields.push(...
|
|
76388
|
+
selectedFields.push(...selection.selectionSet.selections);
|
|
76057
76389
|
continue;
|
|
76058
76390
|
}
|
|
76059
76391
|
if (!graphql18.isInterfaceType(fragmentType) && !graphql18.isUnionType(fragmentType)) {
|
|
76060
76392
|
if (!inlineFragments[fragmentType.name]) {
|
|
76061
76393
|
inlineFragments[fragmentType.name] = [];
|
|
76062
76394
|
}
|
|
76063
|
-
inlineFragments[fragmentType.name].push(...
|
|
76395
|
+
inlineFragments[fragmentType.name].push(...selection.selectionSet.selections);
|
|
76064
76396
|
continue;
|
|
76065
76397
|
}
|
|
76066
76398
|
const possibleParents = config2.schema.getPossibleTypes(type).map((t2) => t2.name);
|
|
76067
76399
|
const freeSelections = [];
|
|
76068
76400
|
const typeSpecificSelections = {};
|
|
76069
|
-
for (const node of
|
|
76401
|
+
for (const node of selection.selectionSet.selections) {
|
|
76070
76402
|
if (node.kind !== "InlineFragment") {
|
|
76071
76403
|
freeSelections.push(node);
|
|
76072
76404
|
} else if (node.typeCondition) {
|
|
@@ -76089,23 +76421,30 @@ function inlineType({
|
|
|
76089
76421
|
);
|
|
76090
76422
|
}
|
|
76091
76423
|
}
|
|
76092
|
-
} else if (
|
|
76093
|
-
selectedFields.push(...
|
|
76424
|
+
} else if (selection.kind === "InlineFragment" && !selection.typeCondition) {
|
|
76425
|
+
selectedFields.push(...selection.selectionSet.selections);
|
|
76094
76426
|
} else {
|
|
76095
|
-
selectedFields.push(
|
|
76427
|
+
selectedFields.push(selection);
|
|
76096
76428
|
}
|
|
76097
76429
|
}
|
|
76430
|
+
const fields = Object.values(
|
|
76431
|
+
selectedFields.filter((field) => field.kind === "Field").reduce(
|
|
76432
|
+
(sel, field) => ({
|
|
76433
|
+
...sel,
|
|
76434
|
+
[field.alias?.value ?? field.name.value]: field
|
|
76435
|
+
}),
|
|
76436
|
+
{}
|
|
76437
|
+
)
|
|
76438
|
+
);
|
|
76098
76439
|
result = AST10.tsTypeLiteral([
|
|
76099
|
-
...(
|
|
76100
|
-
|
|
76101
|
-
|
|
76102
|
-
const { field } = selectionTypeInfo(config2.schema, filepath, rootObj, selection2);
|
|
76103
|
-
const attributeName = selection2.alias?.value || selection2.name.value;
|
|
76440
|
+
...fields.map((selection) => {
|
|
76441
|
+
const { field } = selectionTypeInfo(config2.schema, filepath, rootObj, selection);
|
|
76442
|
+
const attributeName = selection.alias?.value || selection.name.value;
|
|
76104
76443
|
let attributeType = inlineType({
|
|
76105
76444
|
config: config2,
|
|
76106
76445
|
filepath,
|
|
76107
76446
|
rootType: field.type,
|
|
76108
|
-
selections:
|
|
76447
|
+
selections: selection.selectionSet?.selections,
|
|
76109
76448
|
root: false,
|
|
76110
76449
|
allowReadonly,
|
|
76111
76450
|
visitedTypes,
|
|
@@ -76114,7 +76453,7 @@ function inlineType({
|
|
|
76114
76453
|
includeFragments,
|
|
76115
76454
|
allOptional
|
|
76116
76455
|
});
|
|
76117
|
-
const hasIncludeOrSkipDirective =
|
|
76456
|
+
const hasIncludeOrSkipDirective = selection.directives && selection.directives.filter(
|
|
76118
76457
|
(directive) => directive.name.value === "include" || directive.name.value === "skip"
|
|
76119
76458
|
).length > 0;
|
|
76120
76459
|
if (hasIncludeOrSkipDirective) {
|
|
@@ -76138,15 +76477,13 @@ function inlineType({
|
|
|
76138
76477
|
result.members.push(
|
|
76139
76478
|
readonlyProperty(
|
|
76140
76479
|
AST10.tsPropertySignature(
|
|
76141
|
-
AST10.
|
|
76480
|
+
AST10.stringLiteral(fragmentKey2),
|
|
76142
76481
|
AST10.tsTypeAnnotation(
|
|
76143
76482
|
AST10.tsTypeLiteral(
|
|
76144
76483
|
(fragmentSpreads || []).map(
|
|
76145
76484
|
(fragmentSpread) => AST10.tsPropertySignature(
|
|
76146
76485
|
AST10.identifier(fragmentSpread.name.value),
|
|
76147
|
-
AST10.tsTypeAnnotation(
|
|
76148
|
-
AST10.tsLiteralType(AST10.booleanLiteral(true))
|
|
76149
|
-
)
|
|
76486
|
+
AST10.tsTypeAnnotation(AST10.tsTypeLiteral([]))
|
|
76150
76487
|
)
|
|
76151
76488
|
)
|
|
76152
76489
|
)
|
|
@@ -76156,7 +76493,7 @@ function inlineType({
|
|
|
76156
76493
|
)
|
|
76157
76494
|
);
|
|
76158
76495
|
}
|
|
76159
|
-
const inlineFragmentSelections = Object.entries(inlineFragments).flatMap(([typeName,
|
|
76496
|
+
const inlineFragmentSelections = Object.entries(inlineFragments).flatMap(([typeName, fragment2]) => {
|
|
76160
76497
|
const fragmentRootType = config2.schema.getType(typeName);
|
|
76161
76498
|
if (!fragmentRootType) {
|
|
76162
76499
|
return [];
|
|
@@ -76165,7 +76502,7 @@ function inlineType({
|
|
|
76165
76502
|
config: config2,
|
|
76166
76503
|
filepath,
|
|
76167
76504
|
rootType: fragmentRootType,
|
|
76168
|
-
selections:
|
|
76505
|
+
selections: fragment2,
|
|
76169
76506
|
allowReadonly,
|
|
76170
76507
|
visitedTypes,
|
|
76171
76508
|
root,
|
|
@@ -76237,10 +76574,10 @@ function inlineType({
|
|
|
76237
76574
|
}
|
|
76238
76575
|
return result;
|
|
76239
76576
|
}
|
|
76240
|
-
function selectionTypeInfo(schema, filepath, rootType,
|
|
76241
|
-
const selectionName =
|
|
76577
|
+
function selectionTypeInfo(schema, filepath, rootType, selection) {
|
|
76578
|
+
const selectionName = selection.name.value;
|
|
76242
76579
|
let fields = {};
|
|
76243
|
-
if (
|
|
76580
|
+
if (selection.kind === "Field" && selection.name.value === "__typename") {
|
|
76244
76581
|
return {
|
|
76245
76582
|
field: {
|
|
76246
76583
|
name: "__typename",
|
|
@@ -76311,7 +76648,7 @@ async function generateDocumentTypes(config2, docs) {
|
|
|
76311
76648
|
filepath: filename,
|
|
76312
76649
|
selections: definition.selectionSet.selections,
|
|
76313
76650
|
fragmentDefinitions,
|
|
76314
|
-
|
|
76651
|
+
keepFragmentSpreadNodes: true
|
|
76315
76652
|
});
|
|
76316
76653
|
if (definition?.kind === "OperationDefinition") {
|
|
76317
76654
|
await generateOperationTypeDefs(
|
|
@@ -76535,39 +76872,26 @@ async function generateFragmentTypeDefs(config2, filepath, body, selections, def
|
|
|
76535
76872
|
if (!type) {
|
|
76536
76873
|
throw new Error("Should not get here");
|
|
76537
76874
|
}
|
|
76538
|
-
let extraExports = [];
|
|
76539
76875
|
let directive = definition.directives?.find(
|
|
76540
76876
|
(directive2) => directive2.name.value === config2.argumentsDirective
|
|
76541
76877
|
);
|
|
76542
|
-
|
|
76543
|
-
|
|
76544
|
-
|
|
76545
|
-
AST11.
|
|
76546
|
-
AST11.identifier(
|
|
76547
|
-
AST11.
|
|
76548
|
-
(
|
|
76549
|
-
|
|
76550
|
-
|
|
76551
|
-
|
|
76552
|
-
|
|
76553
|
-
|
|
76554
|
-
|
|
76555
|
-
missingScalars,
|
|
76556
|
-
definition2,
|
|
76557
|
-
body
|
|
76558
|
-
)
|
|
76559
|
-
),
|
|
76560
|
-
definition2.type.kind !== "NonNullType"
|
|
76561
|
-
);
|
|
76562
|
-
}
|
|
76563
|
-
)
|
|
76564
|
-
)
|
|
76565
|
-
)
|
|
76566
|
-
)
|
|
76567
|
-
);
|
|
76568
|
-
}
|
|
76878
|
+
let inputValue = !directive ? AST11.tsTypeLiteral([]) : AST11.tsTypeLiteral(
|
|
76879
|
+
(fragmentArgumentsDefinitions(config2, filepath, definition) || []).map(
|
|
76880
|
+
(definition2) => {
|
|
76881
|
+
return AST11.tsPropertySignature(
|
|
76882
|
+
AST11.identifier(definition2.variable.name.value),
|
|
76883
|
+
AST11.tsTypeAnnotation(
|
|
76884
|
+
tsTypeReference(config2, missingScalars, definition2, body)
|
|
76885
|
+
),
|
|
76886
|
+
definition2.type.kind !== "NonNullType"
|
|
76887
|
+
);
|
|
76888
|
+
}
|
|
76889
|
+
)
|
|
76890
|
+
);
|
|
76569
76891
|
body.push(
|
|
76570
|
-
|
|
76892
|
+
AST11.exportNamedDeclaration(
|
|
76893
|
+
AST11.tsTypeAliasDeclaration(AST11.identifier(inputTypeName), inputValue)
|
|
76894
|
+
),
|
|
76571
76895
|
AST11.exportNamedDeclaration(
|
|
76572
76896
|
AST11.tsTypeAliasDeclaration(
|
|
76573
76897
|
AST11.identifier(propTypeName),
|
|
@@ -76583,14 +76907,12 @@ async function generateFragmentTypeDefs(config2, filepath, body, selections, def
|
|
|
76583
76907
|
),
|
|
76584
76908
|
readonlyProperty(
|
|
76585
76909
|
AST11.tsPropertySignature(
|
|
76586
|
-
AST11.stringLiteral(
|
|
76910
|
+
AST11.stringLiteral(fragmentKey2),
|
|
76587
76911
|
AST11.tsTypeAnnotation(
|
|
76588
76912
|
AST11.tsTypeLiteral([
|
|
76589
76913
|
AST11.tsPropertySignature(
|
|
76590
76914
|
AST11.stringLiteral(propTypeName),
|
|
76591
|
-
AST11.tsTypeAnnotation(
|
|
76592
|
-
AST11.tsLiteralType(AST11.booleanLiteral(true))
|
|
76593
|
-
)
|
|
76915
|
+
AST11.tsTypeAnnotation(AST11.tsAnyKeyword())
|
|
76594
76916
|
)
|
|
76595
76917
|
])
|
|
76596
76918
|
)
|
|
@@ -77302,6 +77624,13 @@ async function addID(config2, documents) {
|
|
|
77302
77624
|
return;
|
|
77303
77625
|
}
|
|
77304
77626
|
return addKeysToSelection(config2, node, fragmentType);
|
|
77627
|
+
},
|
|
77628
|
+
FragmentDefinition(node) {
|
|
77629
|
+
const fragmentType = config2.schema.getType(node.typeCondition.name.value);
|
|
77630
|
+
if (!fragmentType) {
|
|
77631
|
+
return;
|
|
77632
|
+
}
|
|
77633
|
+
return addKeysToSelection(config2, node, fragmentType);
|
|
77305
77634
|
}
|
|
77306
77635
|
});
|
|
77307
77636
|
}
|
|
@@ -77320,7 +77649,7 @@ function addKeysToSelection(config2, node, fieldType) {
|
|
|
77320
77649
|
const selections = [...node.selectionSet.selections];
|
|
77321
77650
|
for (const keyField of keyFields) {
|
|
77322
77651
|
if (node.selectionSet.selections.find(
|
|
77323
|
-
(
|
|
77652
|
+
(selection) => selection.kind === "Field" && !selection.alias && selection.name.value === keyField
|
|
77324
77653
|
)) {
|
|
77325
77654
|
continue;
|
|
77326
77655
|
}
|
|
@@ -78910,8 +79239,8 @@ async function updatePackageJSON(targetPath) {
|
|
|
78910
79239
|
}
|
|
78911
79240
|
packageJSON.devDependencies = {
|
|
78912
79241
|
...packageJSON.devDependencies,
|
|
78913
|
-
houdini: "^1.0
|
|
78914
|
-
"houdini-svelte": "^1.0
|
|
79242
|
+
houdini: "^1.1.1-next.0",
|
|
79243
|
+
"houdini-svelte": "^1.1.1-next.0"
|
|
78915
79244
|
};
|
|
78916
79245
|
await fs_exports.writeFile(packagePath, JSON.stringify(packageJSON, null, 4));
|
|
78917
79246
|
}
|