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/test-esm/index.js
CHANGED
|
@@ -3368,7 +3368,7 @@ var require_definition = __commonJS({
|
|
|
3368
3368
|
exports.assertLeafType = assertLeafType;
|
|
3369
3369
|
exports.isCompositeType = isCompositeType;
|
|
3370
3370
|
exports.assertCompositeType = assertCompositeType;
|
|
3371
|
-
exports.isAbstractType =
|
|
3371
|
+
exports.isAbstractType = isAbstractType4;
|
|
3372
3372
|
exports.assertAbstractType = assertAbstractType;
|
|
3373
3373
|
exports.GraphQLList = GraphQLList2;
|
|
3374
3374
|
exports.GraphQLNonNull = GraphQLNonNull2;
|
|
@@ -3539,11 +3539,11 @@ var require_definition = __commonJS({
|
|
|
3539
3539
|
}
|
|
3540
3540
|
return type;
|
|
3541
3541
|
}
|
|
3542
|
-
function
|
|
3542
|
+
function isAbstractType4(type) {
|
|
3543
3543
|
return isInterfaceType6(type) || isUnionType7(type);
|
|
3544
3544
|
}
|
|
3545
3545
|
function assertAbstractType(type) {
|
|
3546
|
-
if (!
|
|
3546
|
+
if (!isAbstractType4(type)) {
|
|
3547
3547
|
throw new Error("Expected ".concat((0, _inspect.default)(type), " to be a GraphQL abstract type."));
|
|
3548
3548
|
}
|
|
3549
3549
|
return type;
|
|
@@ -6807,8 +6807,8 @@ var require_KnownFragmentNamesRule = __commonJS({
|
|
|
6807
6807
|
return {
|
|
6808
6808
|
FragmentSpread: function FragmentSpread(node) {
|
|
6809
6809
|
var fragmentName = node.name.value;
|
|
6810
|
-
var
|
|
6811
|
-
if (!
|
|
6810
|
+
var fragment2 = context.getFragment(fragmentName);
|
|
6811
|
+
if (!fragment2) {
|
|
6812
6812
|
context.reportError(new _GraphQLError.GraphQLError('Unknown fragment "'.concat(fragmentName, '".'), node.name));
|
|
6813
6813
|
}
|
|
6814
6814
|
}
|
|
@@ -6844,8 +6844,8 @@ var require_NoUnusedFragmentsRule = __commonJS({
|
|
|
6844
6844
|
for (var _i2 = 0; _i2 < operationDefs.length; _i2++) {
|
|
6845
6845
|
var operation = operationDefs[_i2];
|
|
6846
6846
|
for (var _i4 = 0, _context$getRecursive2 = context.getRecursivelyReferencedFragments(operation); _i4 < _context$getRecursive2.length; _i4++) {
|
|
6847
|
-
var
|
|
6848
|
-
fragmentNameUsed[
|
|
6847
|
+
var fragment2 = _context$getRecursive2[_i4];
|
|
6848
|
+
fragmentNameUsed[fragment2.name.value] = true;
|
|
6849
6849
|
}
|
|
6850
6850
|
}
|
|
6851
6851
|
for (var _i6 = 0; _i6 < fragmentDefs.length; _i6++) {
|
|
@@ -6935,13 +6935,13 @@ var require_NoFragmentCyclesRule = __commonJS({
|
|
|
6935
6935
|
return false;
|
|
6936
6936
|
}
|
|
6937
6937
|
};
|
|
6938
|
-
function detectCycleRecursive(
|
|
6939
|
-
if (visitedFrags[
|
|
6938
|
+
function detectCycleRecursive(fragment2) {
|
|
6939
|
+
if (visitedFrags[fragment2.name.value]) {
|
|
6940
6940
|
return;
|
|
6941
6941
|
}
|
|
6942
|
-
var fragmentName =
|
|
6942
|
+
var fragmentName = fragment2.name.value;
|
|
6943
6943
|
visitedFrags[fragmentName] = true;
|
|
6944
|
-
var spreadNodes = context.getFragmentSpreads(
|
|
6944
|
+
var spreadNodes = context.getFragmentSpreads(fragment2.selectionSet);
|
|
6945
6945
|
if (spreadNodes.length === 0) {
|
|
6946
6946
|
return;
|
|
6947
6947
|
}
|
|
@@ -7762,11 +7762,11 @@ var require_OverlappingFieldsCanBeMergedRule = __commonJS({
|
|
|
7762
7762
|
return conflicts;
|
|
7763
7763
|
}
|
|
7764
7764
|
function collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, fieldMap, fragmentName) {
|
|
7765
|
-
var
|
|
7766
|
-
if (!
|
|
7765
|
+
var fragment2 = context.getFragment(fragmentName);
|
|
7766
|
+
if (!fragment2) {
|
|
7767
7767
|
return;
|
|
7768
7768
|
}
|
|
7769
|
-
var _getReferencedFieldsA = getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames,
|
|
7769
|
+
var _getReferencedFieldsA = getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragment2), fieldMap2 = _getReferencedFieldsA[0], fragmentNames2 = _getReferencedFieldsA[1];
|
|
7770
7770
|
if (fieldMap === fieldMap2) {
|
|
7771
7771
|
return;
|
|
7772
7772
|
}
|
|
@@ -7937,38 +7937,38 @@ var require_OverlappingFieldsCanBeMergedRule = __commonJS({
|
|
|
7937
7937
|
}
|
|
7938
7938
|
return cached;
|
|
7939
7939
|
}
|
|
7940
|
-
function getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames,
|
|
7941
|
-
var cached = cachedFieldsAndFragmentNames.get(
|
|
7940
|
+
function getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragment2) {
|
|
7941
|
+
var cached = cachedFieldsAndFragmentNames.get(fragment2.selectionSet);
|
|
7942
7942
|
if (cached) {
|
|
7943
7943
|
return cached;
|
|
7944
7944
|
}
|
|
7945
|
-
var fragmentType = (0, _typeFromAST.typeFromAST)(context.getSchema(),
|
|
7946
|
-
return getFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragmentType,
|
|
7945
|
+
var fragmentType = (0, _typeFromAST.typeFromAST)(context.getSchema(), fragment2.typeCondition);
|
|
7946
|
+
return getFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragmentType, fragment2.selectionSet);
|
|
7947
7947
|
}
|
|
7948
7948
|
function _collectFieldsAndFragmentNames(context, parentType, selectionSet, nodeAndDefs, fragmentNames) {
|
|
7949
7949
|
for (var _i9 = 0, _selectionSet$selecti2 = selectionSet.selections; _i9 < _selectionSet$selecti2.length; _i9++) {
|
|
7950
|
-
var
|
|
7951
|
-
switch (
|
|
7950
|
+
var selection = _selectionSet$selecti2[_i9];
|
|
7951
|
+
switch (selection.kind) {
|
|
7952
7952
|
case _kinds.Kind.FIELD: {
|
|
7953
|
-
var fieldName =
|
|
7953
|
+
var fieldName = selection.name.value;
|
|
7954
7954
|
var fieldDef = void 0;
|
|
7955
7955
|
if ((0, _definition.isObjectType)(parentType) || (0, _definition.isInterfaceType)(parentType)) {
|
|
7956
7956
|
fieldDef = parentType.getFields()[fieldName];
|
|
7957
7957
|
}
|
|
7958
|
-
var responseName =
|
|
7958
|
+
var responseName = selection.alias ? selection.alias.value : fieldName;
|
|
7959
7959
|
if (!nodeAndDefs[responseName]) {
|
|
7960
7960
|
nodeAndDefs[responseName] = [];
|
|
7961
7961
|
}
|
|
7962
|
-
nodeAndDefs[responseName].push([parentType,
|
|
7962
|
+
nodeAndDefs[responseName].push([parentType, selection, fieldDef]);
|
|
7963
7963
|
break;
|
|
7964
7964
|
}
|
|
7965
7965
|
case _kinds.Kind.FRAGMENT_SPREAD:
|
|
7966
|
-
fragmentNames[
|
|
7966
|
+
fragmentNames[selection.name.value] = true;
|
|
7967
7967
|
break;
|
|
7968
7968
|
case _kinds.Kind.INLINE_FRAGMENT: {
|
|
7969
|
-
var typeCondition =
|
|
7969
|
+
var typeCondition = selection.typeCondition;
|
|
7970
7970
|
var inlineFragmentType = typeCondition ? (0, _typeFromAST.typeFromAST)(context.getSchema(), typeCondition) : parentType;
|
|
7971
|
-
_collectFieldsAndFragmentNames(context, inlineFragmentType,
|
|
7971
|
+
_collectFieldsAndFragmentNames(context, inlineFragmentType, selection.selectionSet, nodeAndDefs, fragmentNames);
|
|
7972
7972
|
break;
|
|
7973
7973
|
}
|
|
7974
7974
|
}
|
|
@@ -8504,11 +8504,11 @@ var require_ValidationContext = __commonJS({
|
|
|
8504
8504
|
while (setsToVisit.length !== 0) {
|
|
8505
8505
|
var set = setsToVisit.pop();
|
|
8506
8506
|
for (var _i2 = 0, _set$selections2 = set.selections; _i2 < _set$selections2.length; _i2++) {
|
|
8507
|
-
var
|
|
8508
|
-
if (
|
|
8509
|
-
spreads.push(
|
|
8510
|
-
} else if (
|
|
8511
|
-
setsToVisit.push(
|
|
8507
|
+
var selection = _set$selections2[_i2];
|
|
8508
|
+
if (selection.kind === _kinds.Kind.FRAGMENT_SPREAD) {
|
|
8509
|
+
spreads.push(selection);
|
|
8510
|
+
} else if (selection.selectionSet) {
|
|
8511
|
+
setsToVisit.push(selection.selectionSet);
|
|
8512
8512
|
}
|
|
8513
8513
|
}
|
|
8514
8514
|
}
|
|
@@ -8529,10 +8529,10 @@ var require_ValidationContext = __commonJS({
|
|
|
8529
8529
|
var fragName = spread.name.value;
|
|
8530
8530
|
if (collectedNames[fragName] !== true) {
|
|
8531
8531
|
collectedNames[fragName] = true;
|
|
8532
|
-
var
|
|
8533
|
-
if (
|
|
8534
|
-
fragments.push(
|
|
8535
|
-
nodesToVisit.push(
|
|
8532
|
+
var fragment2 = this.getFragment(fragName);
|
|
8533
|
+
if (fragment2) {
|
|
8534
|
+
fragments.push(fragment2);
|
|
8535
|
+
nodesToVisit.push(fragment2.selectionSet);
|
|
8536
8536
|
}
|
|
8537
8537
|
}
|
|
8538
8538
|
}
|
|
@@ -9445,37 +9445,37 @@ var require_execute = __commonJS({
|
|
|
9445
9445
|
}
|
|
9446
9446
|
function collectFields(exeContext, runtimeType, selectionSet, fields, visitedFragmentNames) {
|
|
9447
9447
|
for (var _i6 = 0, _selectionSet$selecti2 = selectionSet.selections; _i6 < _selectionSet$selecti2.length; _i6++) {
|
|
9448
|
-
var
|
|
9449
|
-
switch (
|
|
9448
|
+
var selection = _selectionSet$selecti2[_i6];
|
|
9449
|
+
switch (selection.kind) {
|
|
9450
9450
|
case _kinds.Kind.FIELD: {
|
|
9451
|
-
if (!shouldIncludeNode(exeContext,
|
|
9451
|
+
if (!shouldIncludeNode(exeContext, selection)) {
|
|
9452
9452
|
continue;
|
|
9453
9453
|
}
|
|
9454
|
-
var name = getFieldEntryKey(
|
|
9454
|
+
var name = getFieldEntryKey(selection);
|
|
9455
9455
|
if (!fields[name]) {
|
|
9456
9456
|
fields[name] = [];
|
|
9457
9457
|
}
|
|
9458
|
-
fields[name].push(
|
|
9458
|
+
fields[name].push(selection);
|
|
9459
9459
|
break;
|
|
9460
9460
|
}
|
|
9461
9461
|
case _kinds.Kind.INLINE_FRAGMENT: {
|
|
9462
|
-
if (!shouldIncludeNode(exeContext,
|
|
9462
|
+
if (!shouldIncludeNode(exeContext, selection) || !doesFragmentConditionMatch(exeContext, selection, runtimeType)) {
|
|
9463
9463
|
continue;
|
|
9464
9464
|
}
|
|
9465
|
-
collectFields(exeContext, runtimeType,
|
|
9465
|
+
collectFields(exeContext, runtimeType, selection.selectionSet, fields, visitedFragmentNames);
|
|
9466
9466
|
break;
|
|
9467
9467
|
}
|
|
9468
9468
|
case _kinds.Kind.FRAGMENT_SPREAD: {
|
|
9469
|
-
var fragName =
|
|
9470
|
-
if (visitedFragmentNames[fragName] || !shouldIncludeNode(exeContext,
|
|
9469
|
+
var fragName = selection.name.value;
|
|
9470
|
+
if (visitedFragmentNames[fragName] || !shouldIncludeNode(exeContext, selection)) {
|
|
9471
9471
|
continue;
|
|
9472
9472
|
}
|
|
9473
9473
|
visitedFragmentNames[fragName] = true;
|
|
9474
|
-
var
|
|
9475
|
-
if (!
|
|
9474
|
+
var fragment2 = exeContext.fragments[fragName];
|
|
9475
|
+
if (!fragment2 || !doesFragmentConditionMatch(exeContext, fragment2, runtimeType)) {
|
|
9476
9476
|
continue;
|
|
9477
9477
|
}
|
|
9478
|
-
collectFields(exeContext, runtimeType,
|
|
9478
|
+
collectFields(exeContext, runtimeType, fragment2.selectionSet, fields, visitedFragmentNames);
|
|
9479
9479
|
break;
|
|
9480
9480
|
}
|
|
9481
9481
|
}
|
|
@@ -9493,8 +9493,8 @@ var require_execute = __commonJS({
|
|
|
9493
9493
|
}
|
|
9494
9494
|
return true;
|
|
9495
9495
|
}
|
|
9496
|
-
function doesFragmentConditionMatch(exeContext,
|
|
9497
|
-
var typeConditionNode =
|
|
9496
|
+
function doesFragmentConditionMatch(exeContext, fragment2, type) {
|
|
9497
|
+
var typeConditionNode = fragment2.typeCondition;
|
|
9498
9498
|
if (!typeConditionNode) {
|
|
9499
9499
|
return true;
|
|
9500
9500
|
}
|
|
@@ -54209,14 +54209,14 @@ function deepEquals(objA, objB, map = /* @__PURE__ */ new WeakMap()) {
|
|
|
54209
54209
|
}
|
|
54210
54210
|
|
|
54211
54211
|
// src/runtime/lib/selection.ts
|
|
54212
|
-
function getFieldsForType(
|
|
54213
|
-
let targetSelection =
|
|
54214
|
-
if (
|
|
54215
|
-
const mappedType =
|
|
54212
|
+
function getFieldsForType(selection, __typename) {
|
|
54213
|
+
let targetSelection = selection.fields || {};
|
|
54214
|
+
if (selection.abstractFields && __typename) {
|
|
54215
|
+
const mappedType = selection.abstractFields.typeMap[__typename];
|
|
54216
54216
|
if (mappedType) {
|
|
54217
|
-
targetSelection =
|
|
54218
|
-
} else if (
|
|
54219
|
-
targetSelection =
|
|
54217
|
+
targetSelection = selection.abstractFields.fields[mappedType];
|
|
54218
|
+
} else if (selection.abstractFields.fields[__typename]) {
|
|
54219
|
+
targetSelection = selection.abstractFields.fields[__typename];
|
|
54220
54220
|
}
|
|
54221
54221
|
}
|
|
54222
54222
|
return targetSelection;
|
|
@@ -54224,7 +54224,7 @@ function getFieldsForType(selection2, __typename) {
|
|
|
54224
54224
|
|
|
54225
54225
|
// src/runtime/lib/scalars.ts
|
|
54226
54226
|
async function marshalSelection({
|
|
54227
|
-
selection
|
|
54227
|
+
selection,
|
|
54228
54228
|
data
|
|
54229
54229
|
}) {
|
|
54230
54230
|
const config2 = getCurrentConfig();
|
|
@@ -54232,18 +54232,18 @@ async function marshalSelection({
|
|
|
54232
54232
|
return data;
|
|
54233
54233
|
}
|
|
54234
54234
|
if (Array.isArray(data)) {
|
|
54235
|
-
return await Promise.all(data.map((val) => marshalSelection({ selection
|
|
54235
|
+
return await Promise.all(data.map((val) => marshalSelection({ selection, data: val })));
|
|
54236
54236
|
}
|
|
54237
|
-
const targetSelection = getFieldsForType(
|
|
54237
|
+
const targetSelection = getFieldsForType(selection, data["__typename"]);
|
|
54238
54238
|
return Object.fromEntries(
|
|
54239
54239
|
await Promise.all(
|
|
54240
54240
|
Object.entries(data).map(async ([fieldName, value]) => {
|
|
54241
|
-
const { type, selection:
|
|
54241
|
+
const { type, selection: selection2 } = targetSelection[fieldName];
|
|
54242
54242
|
if (!type) {
|
|
54243
54243
|
return [fieldName, value];
|
|
54244
54244
|
}
|
|
54245
|
-
if (
|
|
54246
|
-
return [fieldName, await marshalSelection({ selection:
|
|
54245
|
+
if (selection2) {
|
|
54246
|
+
return [fieldName, await marshalSelection({ selection: selection2, data: value })];
|
|
54247
54247
|
}
|
|
54248
54248
|
if (config2.scalars?.[type]) {
|
|
54249
54249
|
const marshalFn = config2.scalars[type].marshal;
|
|
@@ -54294,6 +54294,7 @@ var DataSource = {
|
|
|
54294
54294
|
Network: "network",
|
|
54295
54295
|
Ssr: "ssr"
|
|
54296
54296
|
};
|
|
54297
|
+
var fragmentKey = " $fragments";
|
|
54297
54298
|
|
|
54298
54299
|
// src/runtime/lib/key.ts
|
|
54299
54300
|
var computeKey = ({ field, args }) => {
|
|
@@ -54780,7 +54781,7 @@ var List = class {
|
|
|
54780
54781
|
recordType,
|
|
54781
54782
|
key,
|
|
54782
54783
|
listType,
|
|
54783
|
-
selection
|
|
54784
|
+
selection,
|
|
54784
54785
|
when,
|
|
54785
54786
|
filters,
|
|
54786
54787
|
connection,
|
|
@@ -54792,7 +54793,7 @@ var List = class {
|
|
|
54792
54793
|
this.key = key;
|
|
54793
54794
|
this.type = listType;
|
|
54794
54795
|
this.cache = manager.cache;
|
|
54795
|
-
this.selection =
|
|
54796
|
+
this.selection = selection;
|
|
54796
54797
|
this._when = when;
|
|
54797
54798
|
this.filters = filters;
|
|
54798
54799
|
this.name = name;
|
|
@@ -54803,19 +54804,19 @@ var List = class {
|
|
|
54803
54804
|
when(when) {
|
|
54804
54805
|
return this.manager.lists.get(this.name).get(this.recordID).when(when);
|
|
54805
54806
|
}
|
|
54806
|
-
append(
|
|
54807
|
-
return this.addToList(
|
|
54807
|
+
append(selection, data, variables = {}) {
|
|
54808
|
+
return this.addToList(selection, data, variables, "last");
|
|
54808
54809
|
}
|
|
54809
|
-
prepend(
|
|
54810
|
-
return this.addToList(
|
|
54810
|
+
prepend(selection, data, variables = {}) {
|
|
54811
|
+
return this.addToList(selection, data, variables, "first");
|
|
54811
54812
|
}
|
|
54812
|
-
addToList(
|
|
54813
|
+
addToList(selection, data, variables = {}, where) {
|
|
54813
54814
|
const listType = this.listType(data);
|
|
54814
54815
|
const dataID = this.cache._internal_unstable.id(listType, data);
|
|
54815
54816
|
if (!this.validateWhen() || !dataID) {
|
|
54816
54817
|
return;
|
|
54817
54818
|
}
|
|
54818
|
-
let insertSelection =
|
|
54819
|
+
let insertSelection = selection;
|
|
54819
54820
|
let insertData = data;
|
|
54820
54821
|
if (this.connection) {
|
|
54821
54822
|
insertSelection = {
|
|
@@ -54835,9 +54836,9 @@ var List = class {
|
|
|
54835
54836
|
type: listType,
|
|
54836
54837
|
keyRaw: "node",
|
|
54837
54838
|
selection: {
|
|
54838
|
-
...
|
|
54839
|
+
...selection,
|
|
54839
54840
|
fields: {
|
|
54840
|
-
...
|
|
54841
|
+
...selection.fields,
|
|
54841
54842
|
__typename: {
|
|
54842
54843
|
keyRaw: "__typename",
|
|
54843
54844
|
type: "String"
|
|
@@ -54866,9 +54867,9 @@ var List = class {
|
|
|
54866
54867
|
type: listType,
|
|
54867
54868
|
updates: ["append", "prepend"],
|
|
54868
54869
|
selection: {
|
|
54869
|
-
...
|
|
54870
|
+
...selection,
|
|
54870
54871
|
fields: {
|
|
54871
|
-
...
|
|
54872
|
+
...selection.fields,
|
|
54872
54873
|
__typename: {
|
|
54873
54874
|
keyRaw: "__typename",
|
|
54874
54875
|
type: "String"
|
|
@@ -54943,7 +54944,8 @@ var List = class {
|
|
|
54943
54944
|
this.cache._internal_unstable.getSelection({
|
|
54944
54945
|
parent: spec.parentID || this.manager.rootID,
|
|
54945
54946
|
selection: spec.selection,
|
|
54946
|
-
variables: spec.variables?.() || {}
|
|
54947
|
+
variables: spec.variables?.() || {},
|
|
54948
|
+
ignoreMasking: false
|
|
54947
54949
|
}).data
|
|
54948
54950
|
);
|
|
54949
54951
|
}
|
|
@@ -54979,9 +54981,9 @@ var List = class {
|
|
|
54979
54981
|
}
|
|
54980
54982
|
return ok;
|
|
54981
54983
|
}
|
|
54982
|
-
toggleElement(
|
|
54984
|
+
toggleElement(selection, data, variables = {}, where) {
|
|
54983
54985
|
if (!this.remove(data, variables)) {
|
|
54984
|
-
this.addToList(
|
|
54986
|
+
this.addToList(selection, data, variables, where);
|
|
54985
54987
|
}
|
|
54986
54988
|
}
|
|
54987
54989
|
*[Symbol.iterator]() {
|
|
@@ -55556,14 +55558,24 @@ var InMemorySubscriptions = class {
|
|
|
55556
55558
|
add({
|
|
55557
55559
|
parent,
|
|
55558
55560
|
spec,
|
|
55559
|
-
selection
|
|
55561
|
+
selection,
|
|
55560
55562
|
variables,
|
|
55561
55563
|
parentType
|
|
55562
55564
|
}) {
|
|
55563
55565
|
const __typename = this.cache._internal_unstable.storage.get(parent, "__typename").value;
|
|
55564
|
-
let targetSelection = getFieldsForType(
|
|
55566
|
+
let targetSelection = getFieldsForType(selection, __typename);
|
|
55565
55567
|
for (const fieldSelection of Object.values(targetSelection || {})) {
|
|
55566
|
-
const {
|
|
55568
|
+
const {
|
|
55569
|
+
keyRaw,
|
|
55570
|
+
selection: innerSelection,
|
|
55571
|
+
type,
|
|
55572
|
+
list,
|
|
55573
|
+
filters,
|
|
55574
|
+
visible
|
|
55575
|
+
} = fieldSelection;
|
|
55576
|
+
if (!visible) {
|
|
55577
|
+
continue;
|
|
55578
|
+
}
|
|
55567
55579
|
const key = evaluateKey(keyRaw, variables);
|
|
55568
55580
|
let targetSelection2;
|
|
55569
55581
|
if (innerSelection) {
|
|
@@ -55611,10 +55623,10 @@ var InMemorySubscriptions = class {
|
|
|
55611
55623
|
addFieldSubscription({
|
|
55612
55624
|
id,
|
|
55613
55625
|
key,
|
|
55614
|
-
selection
|
|
55626
|
+
selection,
|
|
55615
55627
|
type
|
|
55616
55628
|
}) {
|
|
55617
|
-
const spec =
|
|
55629
|
+
const spec = selection[0];
|
|
55618
55630
|
if (!this.subscribers[id]) {
|
|
55619
55631
|
this.subscribers[id] = {};
|
|
55620
55632
|
}
|
|
@@ -55626,7 +55638,7 @@ var InMemorySubscriptions = class {
|
|
|
55626
55638
|
}
|
|
55627
55639
|
this.keyVersions[key].add(key);
|
|
55628
55640
|
if (!this.subscribers[id][key].map(([{ set }]) => set).includes(spec.set)) {
|
|
55629
|
-
this.subscribers[id][key].push([spec,
|
|
55641
|
+
this.subscribers[id][key].push([spec, selection[1]]);
|
|
55630
55642
|
}
|
|
55631
55643
|
if (!this.referenceCounts[id]) {
|
|
55632
55644
|
this.referenceCounts[id] = {};
|
|
@@ -55637,14 +55649,13 @@ var InMemorySubscriptions = class {
|
|
|
55637
55649
|
const counts = this.referenceCounts[id][key];
|
|
55638
55650
|
counts.set(spec.set, (counts.get(spec.set) || 0) + 1);
|
|
55639
55651
|
this.cache._internal_unstable.lifetimes.resetLifetime(id, key);
|
|
55640
|
-
const { selection: innerSelection } = selection2[1]?.[key] ?? {};
|
|
55641
55652
|
}
|
|
55642
55653
|
registerList({
|
|
55643
55654
|
list,
|
|
55644
55655
|
id,
|
|
55645
55656
|
key,
|
|
55646
55657
|
parentType,
|
|
55647
|
-
selection
|
|
55658
|
+
selection,
|
|
55648
55659
|
filters,
|
|
55649
55660
|
variables
|
|
55650
55661
|
}) {
|
|
@@ -55655,7 +55666,7 @@ var InMemorySubscriptions = class {
|
|
|
55655
55666
|
recordType: this.cache._internal_unstable.storage.get(id, "__typename")?.value || parentType,
|
|
55656
55667
|
listType: list.type,
|
|
55657
55668
|
key,
|
|
55658
|
-
selection
|
|
55669
|
+
selection,
|
|
55659
55670
|
filters: Object.entries(filters || {}).reduce((acc, [key2, { kind, value }]) => {
|
|
55660
55671
|
return {
|
|
55661
55672
|
...acc,
|
|
@@ -55671,14 +55682,14 @@ var InMemorySubscriptions = class {
|
|
|
55671
55682
|
parentType
|
|
55672
55683
|
}) {
|
|
55673
55684
|
for (const [spec, targetSelection] of subscribers) {
|
|
55674
|
-
for (const
|
|
55685
|
+
for (const selection of Object.values(targetSelection ?? {})) {
|
|
55675
55686
|
const {
|
|
55676
55687
|
type: linkedType,
|
|
55677
55688
|
keyRaw,
|
|
55678
55689
|
selection: innerSelection,
|
|
55679
55690
|
list,
|
|
55680
55691
|
filters
|
|
55681
|
-
} =
|
|
55692
|
+
} = selection;
|
|
55682
55693
|
const key = evaluateKey(keyRaw, variables);
|
|
55683
55694
|
const fieldSelection = innerSelection ? getFieldsForType(innerSelection, parentType) : void 0;
|
|
55684
55695
|
this.addFieldSubscription({
|
|
@@ -55698,7 +55709,7 @@ var InMemorySubscriptions = class {
|
|
|
55698
55709
|
parentType: parentType || spec.rootType
|
|
55699
55710
|
});
|
|
55700
55711
|
}
|
|
55701
|
-
const childSelection =
|
|
55712
|
+
const childSelection = selection.selection;
|
|
55702
55713
|
if (childSelection) {
|
|
55703
55714
|
const { value: link } = this.cache._internal_unstable.storage.get(parent, key);
|
|
55704
55715
|
const children = !Array.isArray(link) ? [link] : flatten(link);
|
|
@@ -55725,11 +55736,11 @@ var InMemorySubscriptions = class {
|
|
|
55725
55736
|
get(id, field) {
|
|
55726
55737
|
return this.subscribers[id]?.[field] || [];
|
|
55727
55738
|
}
|
|
55728
|
-
remove(id,
|
|
55739
|
+
remove(id, selection, targets, variables, visited = []) {
|
|
55729
55740
|
visited.push(id);
|
|
55730
55741
|
const linkedIDs = [];
|
|
55731
55742
|
const __typename = this.cache._internal_unstable.storage.get(id, "__typename").value;
|
|
55732
|
-
let targetSelection = getFieldsForType(
|
|
55743
|
+
let targetSelection = getFieldsForType(selection, __typename);
|
|
55733
55744
|
for (const fieldSelection of Object.values(targetSelection || {})) {
|
|
55734
55745
|
const key = evaluateKey(fieldSelection.keyRaw, variables);
|
|
55735
55746
|
this.removeSubscribers(id, key, targets);
|
|
@@ -55791,7 +55802,7 @@ var InMemorySubscriptions = class {
|
|
|
55791
55802
|
// src/runtime/cache/cache.ts
|
|
55792
55803
|
var Cache = class {
|
|
55793
55804
|
_internal_unstable;
|
|
55794
|
-
constructor(config2) {
|
|
55805
|
+
constructor({ disabled, ...config2 } = {}) {
|
|
55795
55806
|
this._internal_unstable = new CacheInternal({
|
|
55796
55807
|
cache: this,
|
|
55797
55808
|
storage: new InMemoryStorage(),
|
|
@@ -55799,9 +55810,10 @@ var Cache = class {
|
|
|
55799
55810
|
lists: new ListManager(this, rootID),
|
|
55800
55811
|
lifetimes: new GarbageCollector(this),
|
|
55801
55812
|
staleManager: new StaleManager(this),
|
|
55802
|
-
schema: new SchemaManager(this)
|
|
55813
|
+
schema: new SchemaManager(this),
|
|
55814
|
+
disabled: disabled ?? typeof globalThis.window === "undefined"
|
|
55803
55815
|
});
|
|
55804
|
-
if (config2) {
|
|
55816
|
+
if (Object.keys(config2).length > 0) {
|
|
55805
55817
|
this.setConfig(defaultConfigValues(config2));
|
|
55806
55818
|
}
|
|
55807
55819
|
}
|
|
@@ -55820,7 +55832,8 @@ var Cache = class {
|
|
|
55820
55832
|
this._internal_unstable.getSelection({
|
|
55821
55833
|
parent: spec.parentID || rootID,
|
|
55822
55834
|
selection: spec.selection,
|
|
55823
|
-
variables: spec.variables?.() || {}
|
|
55835
|
+
variables: spec.variables?.() || {},
|
|
55836
|
+
ignoreMasking: false
|
|
55824
55837
|
}).data
|
|
55825
55838
|
);
|
|
55826
55839
|
}
|
|
@@ -55895,16 +55908,13 @@ var Cache = class {
|
|
|
55895
55908
|
getFieldTime(id, field) {
|
|
55896
55909
|
return this._internal_unstable.staleManager.getFieldTime(id, field);
|
|
55897
55910
|
}
|
|
55911
|
+
config() {
|
|
55912
|
+
return this._internal_unstable.config;
|
|
55913
|
+
}
|
|
55898
55914
|
};
|
|
55899
55915
|
var CacheInternal = class {
|
|
55900
55916
|
_disabled = false;
|
|
55901
|
-
|
|
55902
|
-
plugins: {
|
|
55903
|
-
"houdini-svelte": {
|
|
55904
|
-
client: ""
|
|
55905
|
-
}
|
|
55906
|
-
}
|
|
55907
|
-
});
|
|
55917
|
+
_config;
|
|
55908
55918
|
storage;
|
|
55909
55919
|
subscriptions;
|
|
55910
55920
|
lists;
|
|
@@ -55919,7 +55929,9 @@ var CacheInternal = class {
|
|
|
55919
55929
|
cache,
|
|
55920
55930
|
lifetimes,
|
|
55921
55931
|
staleManager,
|
|
55922
|
-
schema
|
|
55932
|
+
schema,
|
|
55933
|
+
disabled,
|
|
55934
|
+
config: config2
|
|
55923
55935
|
}) {
|
|
55924
55936
|
this.storage = storage;
|
|
55925
55937
|
this.subscriptions = subscriptions;
|
|
@@ -55928,7 +55940,8 @@ var CacheInternal = class {
|
|
|
55928
55940
|
this.lifetimes = lifetimes;
|
|
55929
55941
|
this.staleManager = staleManager;
|
|
55930
55942
|
this.schema = schema;
|
|
55931
|
-
this.
|
|
55943
|
+
this._config = config2;
|
|
55944
|
+
this._disabled = disabled;
|
|
55932
55945
|
try {
|
|
55933
55946
|
if (process.env.HOUDINI_TEST === "true") {
|
|
55934
55947
|
this._disabled = false;
|
|
@@ -55936,12 +55949,15 @@ var CacheInternal = class {
|
|
|
55936
55949
|
} catch {
|
|
55937
55950
|
}
|
|
55938
55951
|
}
|
|
55952
|
+
get config() {
|
|
55953
|
+
return this._config ?? getCurrentConfig();
|
|
55954
|
+
}
|
|
55939
55955
|
setConfig(config2) {
|
|
55940
|
-
this.
|
|
55956
|
+
this._config = config2;
|
|
55941
55957
|
}
|
|
55942
55958
|
writeSelection({
|
|
55943
55959
|
data,
|
|
55944
|
-
selection
|
|
55960
|
+
selection,
|
|
55945
55961
|
variables = {},
|
|
55946
55962
|
parent = rootID,
|
|
55947
55963
|
applyUpdates,
|
|
@@ -55953,9 +55969,9 @@ var CacheInternal = class {
|
|
|
55953
55969
|
if (this._disabled) {
|
|
55954
55970
|
return [];
|
|
55955
55971
|
}
|
|
55956
|
-
let targetSelection = getFieldsForType(
|
|
55972
|
+
let targetSelection = getFieldsForType(selection, data["__typename"]);
|
|
55957
55973
|
for (const [field, value] of Object.entries(data)) {
|
|
55958
|
-
if (!
|
|
55974
|
+
if (!selection || !targetSelection[field]) {
|
|
55959
55975
|
continue;
|
|
55960
55976
|
}
|
|
55961
55977
|
let {
|
|
@@ -56211,25 +56227,40 @@ var CacheInternal = class {
|
|
|
56211
56227
|
return toNotify;
|
|
56212
56228
|
}
|
|
56213
56229
|
getSelection({
|
|
56214
|
-
selection
|
|
56230
|
+
selection,
|
|
56215
56231
|
parent = rootID,
|
|
56216
56232
|
variables,
|
|
56217
|
-
stepsFromConnection = null
|
|
56233
|
+
stepsFromConnection = null,
|
|
56234
|
+
ignoreMasking
|
|
56218
56235
|
}) {
|
|
56219
56236
|
if (parent === null) {
|
|
56220
56237
|
return { data: null, partial: false, stale: false, hasData: true };
|
|
56221
56238
|
}
|
|
56222
56239
|
const target = {};
|
|
56240
|
+
if (selection.fragments) {
|
|
56241
|
+
target[fragmentKey] = Object.fromEntries(
|
|
56242
|
+
Object.entries(selection.fragments).map(([key, value]) => [
|
|
56243
|
+
key,
|
|
56244
|
+
{
|
|
56245
|
+
parent,
|
|
56246
|
+
variables: evaluateFragmentVariables(value, variables ?? {})
|
|
56247
|
+
}
|
|
56248
|
+
])
|
|
56249
|
+
);
|
|
56250
|
+
}
|
|
56223
56251
|
let hasData = false;
|
|
56224
56252
|
let partial = false;
|
|
56225
56253
|
let cascadeNull = false;
|
|
56226
56254
|
let stale = false;
|
|
56227
56255
|
const typename = this.storage.get(parent, "__typename").value;
|
|
56228
|
-
let targetSelection = getFieldsForType(
|
|
56256
|
+
let targetSelection = getFieldsForType(selection, typename);
|
|
56229
56257
|
for (const [
|
|
56230
56258
|
attributeName,
|
|
56231
|
-
{ type, keyRaw, selection: fieldSelection, nullable, list }
|
|
56259
|
+
{ type, keyRaw, selection: fieldSelection, nullable, list, visible }
|
|
56232
56260
|
] of Object.entries(targetSelection)) {
|
|
56261
|
+
if (!visible && !ignoreMasking) {
|
|
56262
|
+
continue;
|
|
56263
|
+
}
|
|
56233
56264
|
const key = evaluateKey(keyRaw, variables);
|
|
56234
56265
|
const { value } = this.storage.get(parent, key);
|
|
56235
56266
|
const dt_field = this.staleManager.getFieldTime(parent, key);
|
|
@@ -56269,7 +56300,8 @@ var CacheInternal = class {
|
|
|
56269
56300
|
fields: fieldSelection,
|
|
56270
56301
|
variables,
|
|
56271
56302
|
linkedList: value,
|
|
56272
|
-
stepsFromConnection: nextStep
|
|
56303
|
+
stepsFromConnection: nextStep,
|
|
56304
|
+
ignoreMasking: !!ignoreMasking
|
|
56273
56305
|
});
|
|
56274
56306
|
target[attributeName] = listValue.data;
|
|
56275
56307
|
if (listValue.partial) {
|
|
@@ -56286,7 +56318,8 @@ var CacheInternal = class {
|
|
|
56286
56318
|
parent: value,
|
|
56287
56319
|
selection: fieldSelection,
|
|
56288
56320
|
variables,
|
|
56289
|
-
stepsFromConnection: nextStep
|
|
56321
|
+
stepsFromConnection: nextStep,
|
|
56322
|
+
ignoreMasking
|
|
56290
56323
|
});
|
|
56291
56324
|
target[attributeName] = objectFields.data;
|
|
56292
56325
|
if (objectFields.partial) {
|
|
@@ -56330,7 +56363,8 @@ var CacheInternal = class {
|
|
|
56330
56363
|
fields,
|
|
56331
56364
|
variables,
|
|
56332
56365
|
linkedList,
|
|
56333
|
-
stepsFromConnection
|
|
56366
|
+
stepsFromConnection,
|
|
56367
|
+
ignoreMasking
|
|
56334
56368
|
}) {
|
|
56335
56369
|
const result = [];
|
|
56336
56370
|
let partialData = false;
|
|
@@ -56342,7 +56376,8 @@ var CacheInternal = class {
|
|
|
56342
56376
|
fields,
|
|
56343
56377
|
variables,
|
|
56344
56378
|
linkedList: entry,
|
|
56345
|
-
stepsFromConnection
|
|
56379
|
+
stepsFromConnection,
|
|
56380
|
+
ignoreMasking
|
|
56346
56381
|
});
|
|
56347
56382
|
result.push(nestedValue.data);
|
|
56348
56383
|
if (nestedValue.partial) {
|
|
@@ -56363,7 +56398,8 @@ var CacheInternal = class {
|
|
|
56363
56398
|
parent: entry,
|
|
56364
56399
|
selection: fields,
|
|
56365
56400
|
variables,
|
|
56366
|
-
stepsFromConnection
|
|
56401
|
+
stepsFromConnection,
|
|
56402
|
+
ignoreMasking
|
|
56367
56403
|
});
|
|
56368
56404
|
result.push(data);
|
|
56369
56405
|
if (partial) {
|
|
@@ -56466,11 +56502,54 @@ var CacheInternal = class {
|
|
|
56466
56502
|
}
|
|
56467
56503
|
}
|
|
56468
56504
|
};
|
|
56505
|
+
function evaluateFragmentVariables(variables, args) {
|
|
56506
|
+
return Object.fromEntries(
|
|
56507
|
+
Object.entries(variables).map(([key, value]) => [key, fragmentVariableValue(value, args)])
|
|
56508
|
+
);
|
|
56509
|
+
}
|
|
56510
|
+
function fragmentVariableValue(value, args) {
|
|
56511
|
+
if (value.kind === "StringValue") {
|
|
56512
|
+
return value.value;
|
|
56513
|
+
}
|
|
56514
|
+
if (value.kind === "BooleanValue") {
|
|
56515
|
+
return value.value;
|
|
56516
|
+
}
|
|
56517
|
+
if (value.kind === "EnumValue") {
|
|
56518
|
+
return value.value;
|
|
56519
|
+
}
|
|
56520
|
+
if (value.kind === "FloatValue") {
|
|
56521
|
+
return parseFloat(value.value);
|
|
56522
|
+
}
|
|
56523
|
+
if (value.kind === "IntValue") {
|
|
56524
|
+
return parseInt(value.value, 10);
|
|
56525
|
+
}
|
|
56526
|
+
if (value.kind === "NullValue") {
|
|
56527
|
+
return null;
|
|
56528
|
+
}
|
|
56529
|
+
if (value.kind === "Variable") {
|
|
56530
|
+
return args[value.name.value];
|
|
56531
|
+
}
|
|
56532
|
+
if (value.kind === "ListValue") {
|
|
56533
|
+
return value.values.map((value2) => fragmentVariableValue(value2, args));
|
|
56534
|
+
}
|
|
56535
|
+
if (value.kind === "ObjectValue") {
|
|
56536
|
+
return value.fields.reduce(
|
|
56537
|
+
(obj, field) => ({
|
|
56538
|
+
...obj,
|
|
56539
|
+
[field.name.value]: fragmentVariableValue(field.value, args)
|
|
56540
|
+
}),
|
|
56541
|
+
{}
|
|
56542
|
+
);
|
|
56543
|
+
}
|
|
56544
|
+
}
|
|
56469
56545
|
var rootID = "_ROOT_";
|
|
56470
56546
|
|
|
56471
56547
|
// src/runtime/cache/index.ts
|
|
56472
56548
|
var cache_default = new Cache();
|
|
56473
56549
|
|
|
56550
|
+
// src/runtime/client/plugins/cache.ts
|
|
56551
|
+
var serverSide = typeof globalThis.window === "undefined";
|
|
56552
|
+
|
|
56474
56553
|
// src/runtime/client/utils/documentPlugins.ts
|
|
56475
56554
|
var documentPlugin = (kind, source) => {
|
|
56476
56555
|
return () => {
|
|
@@ -56506,7 +56585,6 @@ var documentPlugin = (kind, source) => {
|
|
|
56506
56585
|
var query = documentPlugin(ArtifactKind.Query, function() {
|
|
56507
56586
|
let subscriptionSpec = null;
|
|
56508
56587
|
let lastVariables = null;
|
|
56509
|
-
let artifactName = "";
|
|
56510
56588
|
return {
|
|
56511
56589
|
start(ctx, { next }) {
|
|
56512
56590
|
ctx.variables = {
|
|
@@ -56516,8 +56594,7 @@ var query = documentPlugin(ArtifactKind.Query, function() {
|
|
|
56516
56594
|
next(ctx);
|
|
56517
56595
|
},
|
|
56518
56596
|
end(ctx, { resolve: resolve2, marshalVariables, variablesChanged }) {
|
|
56519
|
-
if (variablesChanged(ctx)) {
|
|
56520
|
-
artifactName = ctx.artifact.name;
|
|
56597
|
+
if (variablesChanged(ctx) && !ctx.cacheParams?.disableSubscriptions) {
|
|
56521
56598
|
if (subscriptionSpec) {
|
|
56522
56599
|
cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.() || {});
|
|
56523
56600
|
}
|
|
@@ -56538,19 +56615,61 @@ var query = documentPlugin(ArtifactKind.Query, function() {
|
|
|
56538
56615
|
});
|
|
56539
56616
|
}
|
|
56540
56617
|
};
|
|
56541
|
-
cache_default.subscribe(subscriptionSpec, lastVariables
|
|
56618
|
+
cache_default.subscribe(subscriptionSpec, lastVariables);
|
|
56542
56619
|
}
|
|
56543
56620
|
resolve2(ctx);
|
|
56544
56621
|
},
|
|
56545
56622
|
cleanup() {
|
|
56546
56623
|
if (subscriptionSpec) {
|
|
56547
|
-
cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.()
|
|
56624
|
+
cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.());
|
|
56548
56625
|
lastVariables = null;
|
|
56549
56626
|
}
|
|
56550
56627
|
}
|
|
56551
56628
|
};
|
|
56552
56629
|
});
|
|
56553
56630
|
|
|
56631
|
+
// src/runtime/client/plugins/fragment.ts
|
|
56632
|
+
var fragment = documentPlugin(ArtifactKind.Fragment, function() {
|
|
56633
|
+
let subscriptionSpec = null;
|
|
56634
|
+
return {
|
|
56635
|
+
start(ctx, { next, resolve: resolve2, variablesChanged, marshalVariables }) {
|
|
56636
|
+
if (!ctx.stuff.parentID) {
|
|
56637
|
+
return next(ctx);
|
|
56638
|
+
}
|
|
56639
|
+
if (variablesChanged(ctx) && !ctx.cacheParams?.disableSubscriptions) {
|
|
56640
|
+
if (subscriptionSpec) {
|
|
56641
|
+
cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.() || {});
|
|
56642
|
+
}
|
|
56643
|
+
const variables = marshalVariables(ctx);
|
|
56644
|
+
subscriptionSpec = {
|
|
56645
|
+
rootType: ctx.artifact.rootType,
|
|
56646
|
+
selection: ctx.artifact.selection,
|
|
56647
|
+
variables: () => variables,
|
|
56648
|
+
parentID: ctx.stuff.parentID,
|
|
56649
|
+
set: (newValue) => {
|
|
56650
|
+
resolve2(ctx, {
|
|
56651
|
+
data: newValue,
|
|
56652
|
+
errors: null,
|
|
56653
|
+
fetching: false,
|
|
56654
|
+
partial: false,
|
|
56655
|
+
stale: false,
|
|
56656
|
+
source: DataSource.Cache,
|
|
56657
|
+
variables
|
|
56658
|
+
});
|
|
56659
|
+
}
|
|
56660
|
+
};
|
|
56661
|
+
cache_default.subscribe(subscriptionSpec, variables);
|
|
56662
|
+
}
|
|
56663
|
+
next(ctx);
|
|
56664
|
+
},
|
|
56665
|
+
cleanup() {
|
|
56666
|
+
if (subscriptionSpec) {
|
|
56667
|
+
cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.());
|
|
56668
|
+
}
|
|
56669
|
+
}
|
|
56670
|
+
};
|
|
56671
|
+
});
|
|
56672
|
+
|
|
56554
56673
|
// src/runtime/client/plugins/mutation.ts
|
|
56555
56674
|
var mutation = documentPlugin(ArtifactKind.Mutation, () => {
|
|
56556
56675
|
return {
|
|
@@ -56706,6 +56825,7 @@ var Config = class {
|
|
|
56706
56825
|
this.schemaPollInterval = watchSchema?.interval ?? 2e3;
|
|
56707
56826
|
this.schemaPollHeaders = watchSchema?.headers ?? {};
|
|
56708
56827
|
this.rootDir = join(this.projectRoot, "$houdini");
|
|
56828
|
+
this.#fragmentVariableMaps = {};
|
|
56709
56829
|
if (defaultKeys) {
|
|
56710
56830
|
this.defaultKeys = defaultKeys;
|
|
56711
56831
|
}
|
|
@@ -56855,7 +56975,7 @@ var Config = class {
|
|
|
56855
56975
|
return `$houdini/${this.artifactDirectoryName}/${name}`;
|
|
56856
56976
|
}
|
|
56857
56977
|
keyFieldsForType(type) {
|
|
56858
|
-
return keyFieldsForType(this.configFile, type);
|
|
56978
|
+
return this.schema.getQueryType()?.name === type ? [] : keyFieldsForType(this.configFile, type);
|
|
56859
56979
|
}
|
|
56860
56980
|
computeID(type, data) {
|
|
56861
56981
|
return computeID(this.configFile, type, data);
|
|
@@ -56874,7 +56994,7 @@ var Config = class {
|
|
|
56874
56994
|
({ kind }) => kind === graphql.Kind.FRAGMENT_DEFINITION
|
|
56875
56995
|
);
|
|
56876
56996
|
if (fragmentDefinitions.length) {
|
|
56877
|
-
return fragmentDefinitions.
|
|
56997
|
+
return fragmentDefinitions[0].name.value;
|
|
56878
56998
|
}
|
|
56879
56999
|
throw new Error("Could not generate artifact name for document: " + graphql.print(document));
|
|
56880
57000
|
}
|
|
@@ -57046,6 +57166,56 @@ var Config = class {
|
|
|
57046
57166
|
}, []) ?? [];
|
|
57047
57167
|
return !defaultDirectives.includes(name) && (internalDirectives.includes(name) || this.isDeleteDirective(name));
|
|
57048
57168
|
}
|
|
57169
|
+
#fragmentVariableMaps;
|
|
57170
|
+
registerFragmentVariablesHash({
|
|
57171
|
+
hash,
|
|
57172
|
+
args,
|
|
57173
|
+
fragment: fragment2
|
|
57174
|
+
}) {
|
|
57175
|
+
this.#fragmentVariableMaps[hash] = {
|
|
57176
|
+
args: this.#serializeValueMap(args),
|
|
57177
|
+
fragment: fragment2
|
|
57178
|
+
};
|
|
57179
|
+
}
|
|
57180
|
+
getFragmentVariablesHash(hash) {
|
|
57181
|
+
return this.#fragmentVariableMaps[hash] ?? {
|
|
57182
|
+
fragment: hash,
|
|
57183
|
+
args: {},
|
|
57184
|
+
hash
|
|
57185
|
+
};
|
|
57186
|
+
}
|
|
57187
|
+
#serializeValueMap(map) {
|
|
57188
|
+
if (!map) {
|
|
57189
|
+
return null;
|
|
57190
|
+
}
|
|
57191
|
+
return Object.fromEntries(
|
|
57192
|
+
Object.entries(map).map(([key, input]) => {
|
|
57193
|
+
const result = {
|
|
57194
|
+
kind: input.kind
|
|
57195
|
+
};
|
|
57196
|
+
if (typeof input === "object") {
|
|
57197
|
+
if ("value" in input) {
|
|
57198
|
+
result.value = input.value;
|
|
57199
|
+
}
|
|
57200
|
+
if ("values" in input) {
|
|
57201
|
+
result.values = input.values.map(
|
|
57202
|
+
(value) => this.#serializeValueMap({ foo: value }).foo
|
|
57203
|
+
);
|
|
57204
|
+
}
|
|
57205
|
+
if ("name" in input) {
|
|
57206
|
+
result.name = input.name;
|
|
57207
|
+
}
|
|
57208
|
+
if ("fields" in input) {
|
|
57209
|
+
result.fields = input.fields.map((field) => ({
|
|
57210
|
+
name: field.name,
|
|
57211
|
+
value: this.#serializeValueMap({ foo: field.value }).foo
|
|
57212
|
+
}));
|
|
57213
|
+
}
|
|
57214
|
+
}
|
|
57215
|
+
return [key, result];
|
|
57216
|
+
})
|
|
57217
|
+
);
|
|
57218
|
+
}
|
|
57049
57219
|
isListFragment(name) {
|
|
57050
57220
|
return name.endsWith(this.insertFragmentSuffix) || name.endsWith(this.removeFragmentSuffix) || name.endsWith(this.toggleFragmentSuffix);
|
|
57051
57221
|
}
|
|
@@ -57330,11 +57500,17 @@ function deepMerge(filepath, ...targets) {
|
|
|
57330
57500
|
if (targets.length === 1) {
|
|
57331
57501
|
return targets[0];
|
|
57332
57502
|
} else if (targets.length === 2) {
|
|
57333
|
-
return (0, import_deepmerge.default)(targets[0], targets[1]
|
|
57503
|
+
return (0, import_deepmerge.default)(targets[0], targets[1], {
|
|
57504
|
+
arrayMerge: (source, update) => [...new Set(source.concat(update))]
|
|
57505
|
+
});
|
|
57334
57506
|
}
|
|
57335
57507
|
return deepMerge(filepath, targets[0], deepMerge(filepath, ...targets.slice(1)));
|
|
57336
57508
|
} catch (e) {
|
|
57337
|
-
throw new HoudiniError({
|
|
57509
|
+
throw new HoudiniError({
|
|
57510
|
+
filepath,
|
|
57511
|
+
message: "could not merge: " + targets,
|
|
57512
|
+
description: e.message
|
|
57513
|
+
});
|
|
57338
57514
|
}
|
|
57339
57515
|
}
|
|
57340
57516
|
|
|
@@ -57378,16 +57554,16 @@ function flattenSelections({
|
|
|
57378
57554
|
filepath,
|
|
57379
57555
|
selections,
|
|
57380
57556
|
fragmentDefinitions,
|
|
57381
|
-
|
|
57382
|
-
|
|
57557
|
+
ignoreMaskDisable,
|
|
57558
|
+
keepFragmentSpreadNodes
|
|
57383
57559
|
}) {
|
|
57384
57560
|
const fields = new FieldCollection({
|
|
57385
57561
|
config: config2,
|
|
57386
57562
|
filepath,
|
|
57387
57563
|
selections,
|
|
57388
57564
|
fragmentDefinitions,
|
|
57389
|
-
|
|
57390
|
-
|
|
57565
|
+
ignoreMaskDisable: !!ignoreMaskDisable,
|
|
57566
|
+
keepFragmentSpreadNodes: !!keepFragmentSpreadNodes
|
|
57391
57567
|
});
|
|
57392
57568
|
return fields.toSelectionSet();
|
|
57393
57569
|
}
|
|
@@ -57398,57 +57574,60 @@ var FieldCollection = class {
|
|
|
57398
57574
|
fields;
|
|
57399
57575
|
inlineFragments;
|
|
57400
57576
|
fragmentSpreads;
|
|
57401
|
-
applyFragments;
|
|
57402
57577
|
ignoreMaskDisable;
|
|
57578
|
+
keepFragmentSpreadNodes;
|
|
57403
57579
|
constructor(args) {
|
|
57404
57580
|
this.config = args.config;
|
|
57405
57581
|
this.fragmentDefinitions = args.fragmentDefinitions;
|
|
57406
|
-
this.applyFragments = args.applyFragments;
|
|
57407
57582
|
this.ignoreMaskDisable = args.ignoreMaskDisable;
|
|
57583
|
+
this.keepFragmentSpreadNodes = args.keepFragmentSpreadNodes;
|
|
57408
57584
|
this.fields = {};
|
|
57409
57585
|
this.inlineFragments = {};
|
|
57410
57586
|
this.fragmentSpreads = {};
|
|
57411
57587
|
this.filepath = args.filepath;
|
|
57412
|
-
for (const
|
|
57413
|
-
this.add(
|
|
57588
|
+
for (const selection of args.selections) {
|
|
57589
|
+
this.add(selection);
|
|
57414
57590
|
}
|
|
57415
57591
|
}
|
|
57416
57592
|
get size() {
|
|
57417
57593
|
return Object.keys(this.fields).length + Object.keys(this.inlineFragments).length + Object.keys(this.fragmentSpreads).length;
|
|
57418
57594
|
}
|
|
57419
|
-
add(
|
|
57420
|
-
if (
|
|
57421
|
-
const key =
|
|
57595
|
+
add(selection) {
|
|
57596
|
+
if (selection.kind === "Field") {
|
|
57597
|
+
const key = selection.alias?.value || selection.name.value;
|
|
57422
57598
|
if (!this.fields[key]) {
|
|
57423
57599
|
this.fields[key] = {
|
|
57424
|
-
astNode:
|
|
57600
|
+
astNode: selection,
|
|
57425
57601
|
selection: this.empty()
|
|
57426
57602
|
};
|
|
57427
57603
|
}
|
|
57428
|
-
for (const subselect of
|
|
57604
|
+
for (const subselect of selection.selectionSet?.selections || []) {
|
|
57429
57605
|
this.fields[key].selection.add(subselect);
|
|
57430
57606
|
}
|
|
57607
|
+
this.fields[key].selection.fragmentSpreads = {
|
|
57608
|
+
...this.collectFragmentSpreads(selection.selectionSet?.selections ?? []),
|
|
57609
|
+
...this.fields[key].selection.fragmentSpreads
|
|
57610
|
+
};
|
|
57431
57611
|
return;
|
|
57432
57612
|
}
|
|
57433
|
-
if (
|
|
57434
|
-
for (const subselect of
|
|
57613
|
+
if (selection.kind === "InlineFragment" && !selection.typeCondition) {
|
|
57614
|
+
for (const subselect of selection.selectionSet.selections) {
|
|
57435
57615
|
this.add(subselect);
|
|
57436
57616
|
}
|
|
57437
57617
|
}
|
|
57438
|
-
if (
|
|
57439
|
-
this.walkInlineFragment(
|
|
57618
|
+
if (selection.kind === "InlineFragment" && selection.typeCondition) {
|
|
57619
|
+
this.walkInlineFragment(selection);
|
|
57440
57620
|
return;
|
|
57441
57621
|
}
|
|
57442
|
-
if (
|
|
57443
|
-
this.fragmentSpreads[selection2.name.value] = selection2;
|
|
57622
|
+
if (selection.kind === "FragmentSpread") {
|
|
57444
57623
|
let includeFragments = this.config.defaultFragmentMasking === "disable";
|
|
57445
|
-
const maskEnableDirective =
|
|
57624
|
+
const maskEnableDirective = selection.directives?.find(
|
|
57446
57625
|
({ name }) => name.value === this.config.maskEnableDirective
|
|
57447
57626
|
);
|
|
57448
57627
|
if (maskEnableDirective) {
|
|
57449
57628
|
includeFragments = false;
|
|
57450
57629
|
}
|
|
57451
|
-
const maskDisableDirective =
|
|
57630
|
+
const maskDisableDirective = selection.directives?.find(
|
|
57452
57631
|
({ name }) => name.value === this.config.maskDisableDirective
|
|
57453
57632
|
);
|
|
57454
57633
|
if (maskDisableDirective) {
|
|
@@ -57457,14 +57636,17 @@ var FieldCollection = class {
|
|
|
57457
57636
|
if (this.ignoreMaskDisable) {
|
|
57458
57637
|
includeFragments = true;
|
|
57459
57638
|
}
|
|
57460
|
-
if (
|
|
57639
|
+
if (this.keepFragmentSpreadNodes) {
|
|
57640
|
+
this.fragmentSpreads[selection.name.value] = selection;
|
|
57641
|
+
}
|
|
57642
|
+
if (!includeFragments) {
|
|
57461
57643
|
return;
|
|
57462
57644
|
}
|
|
57463
|
-
const definition = this.fragmentDefinitions[
|
|
57645
|
+
const definition = this.fragmentDefinitions[selection.name.value];
|
|
57464
57646
|
if (!definition) {
|
|
57465
57647
|
throw new HoudiniError({
|
|
57466
57648
|
filepath: this.filepath,
|
|
57467
|
-
message: "Could not find referenced fragment definition: " +
|
|
57649
|
+
message: "Could not find referenced fragment definition: " + selection.name.value + "\n" + JSON.stringify(Object.keys(this.fragmentDefinitions), null, 4)
|
|
57468
57650
|
});
|
|
57469
57651
|
}
|
|
57470
57652
|
this.add({
|
|
@@ -57483,37 +57665,67 @@ var FieldCollection = class {
|
|
|
57483
57665
|
});
|
|
57484
57666
|
}
|
|
57485
57667
|
}
|
|
57668
|
+
collectFragmentSpreads(selections, result = {}) {
|
|
57669
|
+
for (const selection of selections) {
|
|
57670
|
+
if (selection.kind === "Field") {
|
|
57671
|
+
continue;
|
|
57672
|
+
}
|
|
57673
|
+
if (selection.kind === "InlineFragment") {
|
|
57674
|
+
this.collectFragmentSpreads(selection.selectionSet.selections, result);
|
|
57675
|
+
continue;
|
|
57676
|
+
}
|
|
57677
|
+
if (selection.kind === "FragmentSpread") {
|
|
57678
|
+
result[selection.name.value] = selection;
|
|
57679
|
+
continue;
|
|
57680
|
+
}
|
|
57681
|
+
}
|
|
57682
|
+
return result;
|
|
57683
|
+
}
|
|
57486
57684
|
toSelectionSet() {
|
|
57487
|
-
return Object.values(this.inlineFragments).flatMap((
|
|
57488
|
-
if (
|
|
57685
|
+
return Object.values(this.inlineFragments).flatMap((fragment2) => {
|
|
57686
|
+
if (fragment2.selection.size === 0) {
|
|
57489
57687
|
return [];
|
|
57490
57688
|
}
|
|
57491
|
-
|
|
57492
|
-
...
|
|
57689
|
+
fragment2.astNode = {
|
|
57690
|
+
...fragment2.astNode,
|
|
57493
57691
|
selectionSet: {
|
|
57494
|
-
...
|
|
57495
|
-
selections:
|
|
57692
|
+
...fragment2.astNode.selectionSet,
|
|
57693
|
+
selections: fragment2.selection.toSelectionSet()
|
|
57496
57694
|
}
|
|
57497
57695
|
};
|
|
57498
|
-
return [
|
|
57696
|
+
return [fragment2.astNode];
|
|
57499
57697
|
}).concat(
|
|
57500
57698
|
Object.values(this.fields).map((field) => {
|
|
57501
|
-
|
|
57502
|
-
field.astNode
|
|
57503
|
-
|
|
57504
|
-
|
|
57699
|
+
return {
|
|
57700
|
+
...field.astNode,
|
|
57701
|
+
selectionSet: field.astNode.selectionSet ? {
|
|
57702
|
+
kind: "SelectionSet",
|
|
57703
|
+
selections: field.selection.toSelectionSet()
|
|
57704
|
+
} : void 0
|
|
57705
|
+
};
|
|
57706
|
+
})
|
|
57707
|
+
).concat(
|
|
57708
|
+
Object.values(this.fragmentSpreads).map((spread) => {
|
|
57709
|
+
return {
|
|
57710
|
+
kind: "FragmentSpread",
|
|
57711
|
+
name: {
|
|
57712
|
+
kind: "Name",
|
|
57713
|
+
value: spread.name.value
|
|
57714
|
+
},
|
|
57715
|
+
directives: spread.directives
|
|
57716
|
+
};
|
|
57505
57717
|
})
|
|
57506
|
-
)
|
|
57718
|
+
);
|
|
57507
57719
|
}
|
|
57508
|
-
walkInlineFragment(
|
|
57509
|
-
const key =
|
|
57720
|
+
walkInlineFragment(selection) {
|
|
57721
|
+
const key = selection.typeCondition.name.value;
|
|
57510
57722
|
if (!this.inlineFragments[key]) {
|
|
57511
57723
|
this.inlineFragments[key] = {
|
|
57512
|
-
astNode:
|
|
57724
|
+
astNode: selection,
|
|
57513
57725
|
selection: this.empty()
|
|
57514
57726
|
};
|
|
57515
57727
|
}
|
|
57516
|
-
for (const subselect of
|
|
57728
|
+
for (const subselect of selection.selectionSet.selections || []) {
|
|
57517
57729
|
if (subselect.kind !== "InlineFragment" || !subselect.typeCondition) {
|
|
57518
57730
|
this.inlineFragments[key].selection.add(subselect);
|
|
57519
57731
|
continue;
|
|
@@ -57527,8 +57739,8 @@ var FieldCollection = class {
|
|
|
57527
57739
|
fragmentDefinitions: this.fragmentDefinitions,
|
|
57528
57740
|
selections: [],
|
|
57529
57741
|
filepath: this.filepath,
|
|
57530
|
-
|
|
57531
|
-
|
|
57742
|
+
ignoreMaskDisable: this.ignoreMaskDisable,
|
|
57743
|
+
keepFragmentSpreadNodes: this.keepFragmentSpreadNodes
|
|
57532
57744
|
});
|
|
57533
57745
|
}
|
|
57534
57746
|
};
|
|
@@ -57606,13 +57818,13 @@ function murmurHash(str) {
|
|
|
57606
57818
|
// src/codegen/transforms/fragmentVariables.ts
|
|
57607
57819
|
var graphql3 = __toESM(require_graphql2(), 1);
|
|
57608
57820
|
|
|
57609
|
-
// src/codegen/transforms/
|
|
57821
|
+
// src/codegen/transforms/collectDefinitions.ts
|
|
57610
57822
|
var import_graphql = __toESM(require_graphql2(), 1);
|
|
57611
57823
|
async function includeFragmentDefinitions(config2, documents) {
|
|
57612
|
-
const fragments =
|
|
57824
|
+
const fragments = collectDefinitions(config2, documents);
|
|
57613
57825
|
for (const [index, { name, document, filename }] of documents.entries()) {
|
|
57614
57826
|
const operation = document.definitions.find(
|
|
57615
|
-
(
|
|
57827
|
+
(def) => def.kind === import_graphql.Kind.OPERATION_DEFINITION || def.kind === "FragmentDefinition"
|
|
57616
57828
|
);
|
|
57617
57829
|
if (!operation) {
|
|
57618
57830
|
continue;
|
|
@@ -57631,7 +57843,7 @@ async function includeFragmentDefinitions(config2, documents) {
|
|
|
57631
57843
|
};
|
|
57632
57844
|
}
|
|
57633
57845
|
}
|
|
57634
|
-
function
|
|
57846
|
+
function collectDefinitions(config2, docs) {
|
|
57635
57847
|
return docs.reduce((acc, doc) => {
|
|
57636
57848
|
const definitions = doc.document.definitions.reduce(
|
|
57637
57849
|
(prev, definition) => definition.kind !== "FragmentDefinition" ? prev : {
|
|
@@ -57655,11 +57867,11 @@ function findRequiredFragments(selectionSet) {
|
|
|
57655
57867
|
return [];
|
|
57656
57868
|
}
|
|
57657
57869
|
const referencedFragments = [];
|
|
57658
|
-
for (const
|
|
57659
|
-
if (
|
|
57660
|
-
referencedFragments.push(
|
|
57661
|
-
} else if (
|
|
57662
|
-
referencedFragments.push(...findRequiredFragments(
|
|
57870
|
+
for (const selection of selectionSet.selections) {
|
|
57871
|
+
if (selection.kind === import_graphql.Kind.FRAGMENT_SPREAD) {
|
|
57872
|
+
referencedFragments.push(selection.name.value);
|
|
57873
|
+
} else if (selection.selectionSet) {
|
|
57874
|
+
referencedFragments.push(...findRequiredFragments(selection.selectionSet));
|
|
57663
57875
|
}
|
|
57664
57876
|
}
|
|
57665
57877
|
return referencedFragments;
|
|
@@ -57692,7 +57904,7 @@ function flattenFragments(filepath, operation, fragments) {
|
|
|
57692
57904
|
// src/codegen/transforms/fragmentVariables.ts
|
|
57693
57905
|
var GraphqlKinds2 = graphql3.Kind;
|
|
57694
57906
|
async function fragmentVariables(config2, documents) {
|
|
57695
|
-
const fragments =
|
|
57907
|
+
const fragments = collectDefinitions(config2, documents);
|
|
57696
57908
|
const generatedFragments = {};
|
|
57697
57909
|
const visitedFragments = /* @__PURE__ */ new Set();
|
|
57698
57910
|
for (const doc2 of documents) {
|
|
@@ -57752,9 +57964,17 @@ function inlineFragmentArgs({
|
|
|
57752
57964
|
).reduce((acc, arg) => ({ ...acc, [arg.name]: arg }), {});
|
|
57753
57965
|
const result = graphql3.visit(document, {
|
|
57754
57966
|
FragmentSpread(node) {
|
|
57967
|
+
if (!fragmentDefinitions[node.name.value]) {
|
|
57968
|
+
throw new Error("Could not find definition for fragment" + node.name.value);
|
|
57969
|
+
}
|
|
57755
57970
|
const { definition } = fragmentDefinitions[node.name.value];
|
|
57756
57971
|
let { args, hash } = collectWithArguments(config2, filepath, node, scope);
|
|
57757
57972
|
const newFragmentName = `${node.name.value}${hash}`;
|
|
57973
|
+
config2.registerFragmentVariablesHash({
|
|
57974
|
+
hash: newFragmentName,
|
|
57975
|
+
fragment: node.name.value,
|
|
57976
|
+
args
|
|
57977
|
+
});
|
|
57758
57978
|
if (!visitedFragments.has(newFragmentName)) {
|
|
57759
57979
|
visitedFragments.add(newFragmentName);
|
|
57760
57980
|
const defaultArguments = collectDefaultArgumentValues(config2, filepath, definition);
|
|
@@ -58153,7 +58373,7 @@ function operationObject({
|
|
|
58153
58373
|
listName,
|
|
58154
58374
|
operationKind,
|
|
58155
58375
|
type,
|
|
58156
|
-
selection
|
|
58376
|
+
selection,
|
|
58157
58377
|
filepath
|
|
58158
58378
|
}) {
|
|
58159
58379
|
let parentID;
|
|
@@ -58161,7 +58381,7 @@ function operationObject({
|
|
|
58161
58381
|
let position = config2.internalListPosition;
|
|
58162
58382
|
let allLists = config2.defaultListTarget ?? void 0;
|
|
58163
58383
|
let operationWhen;
|
|
58164
|
-
const internalDirectives =
|
|
58384
|
+
const internalDirectives = selection.directives?.filter(
|
|
58165
58385
|
(directive) => config2.isInternalDirective(directive.name.value)
|
|
58166
58386
|
);
|
|
58167
58387
|
if (internalDirectives && internalDirectives.length > 0) {
|
|
@@ -58397,7 +58617,7 @@ async function paginate(config2, documents) {
|
|
|
58397
58617
|
let fragmentName = "";
|
|
58398
58618
|
let refetchQueryName = "";
|
|
58399
58619
|
let nodeQuery = false;
|
|
58400
|
-
let
|
|
58620
|
+
let fragment2 = "";
|
|
58401
58621
|
let paginateMode = config2.defaultPaginateMode;
|
|
58402
58622
|
doc.document = graphql8.visit(doc.document, {
|
|
58403
58623
|
OperationDefinition(node) {
|
|
@@ -58440,7 +58660,7 @@ async function paginate(config2, documents) {
|
|
|
58440
58660
|
};
|
|
58441
58661
|
},
|
|
58442
58662
|
FragmentDefinition(node) {
|
|
58443
|
-
|
|
58663
|
+
fragment2 = node.typeCondition.name.value;
|
|
58444
58664
|
fragmentName = node.name.value;
|
|
58445
58665
|
refetchQueryName = config2.paginationQueryName(fragmentName);
|
|
58446
58666
|
nodeQuery = node.typeCondition.name.value !== config2.schema.getQueryType()?.name;
|
|
@@ -58487,17 +58707,17 @@ async function paginate(config2, documents) {
|
|
|
58487
58707
|
}
|
|
58488
58708
|
});
|
|
58489
58709
|
let targetType = config2.schema.getQueryType()?.name || "";
|
|
58490
|
-
if (
|
|
58710
|
+
if (fragment2) {
|
|
58491
58711
|
const nodeInterface = config2.schema.getType("Node");
|
|
58492
58712
|
if (nodeInterface) {
|
|
58493
58713
|
const { objects, interfaces } = config2.schema.getImplementations(nodeInterface);
|
|
58494
|
-
if (objects.find((obj) => obj.name ===
|
|
58714
|
+
if (objects.find((obj) => obj.name === fragment2) || interfaces.find((int) => int.name === fragment2)) {
|
|
58495
58715
|
targetType = "Node";
|
|
58496
58716
|
} else {
|
|
58497
|
-
targetType =
|
|
58717
|
+
targetType = fragment2;
|
|
58498
58718
|
}
|
|
58499
58719
|
} else {
|
|
58500
|
-
targetType =
|
|
58720
|
+
targetType = fragment2;
|
|
58501
58721
|
}
|
|
58502
58722
|
}
|
|
58503
58723
|
const pageSize = flags.first.defaultValue ?? flags.last.defaultValue ?? flags.limit.defaultValue;
|
|
@@ -58519,7 +58739,7 @@ async function paginate(config2, documents) {
|
|
|
58519
58739
|
start,
|
|
58520
58740
|
mode: paginateMode
|
|
58521
58741
|
};
|
|
58522
|
-
if (!
|
|
58742
|
+
if (!fragment2) {
|
|
58523
58743
|
continue;
|
|
58524
58744
|
}
|
|
58525
58745
|
const paginationArgs = Object.entries(flags).filter(([_, { enabled }]) => enabled).map(([key, value]) => ({ name: key, ...value }));
|
|
@@ -58540,15 +58760,22 @@ async function paginate(config2, documents) {
|
|
|
58540
58760
|
["arguments"]: paginationArgs.map(
|
|
58541
58761
|
({ name }) => variableAsArgument(name)
|
|
58542
58762
|
)
|
|
58763
|
+
},
|
|
58764
|
+
{
|
|
58765
|
+
kind: graphql8.Kind.DIRECTIVE,
|
|
58766
|
+
name: {
|
|
58767
|
+
kind: "Name",
|
|
58768
|
+
value: config2.maskDisableDirective
|
|
58769
|
+
}
|
|
58543
58770
|
}
|
|
58544
58771
|
]
|
|
58545
58772
|
}
|
|
58546
58773
|
];
|
|
58547
|
-
const keys = config2.keyFieldsForType(!nodeQuery ? config2.schema.getQueryType()?.name || "" :
|
|
58548
|
-
if (
|
|
58774
|
+
const keys = config2.keyFieldsForType(!nodeQuery ? config2.schema.getQueryType()?.name || "" : fragment2).flatMap((key) => {
|
|
58775
|
+
if (fragment2 === config2.schema.getQueryType()?.name) {
|
|
58549
58776
|
return [];
|
|
58550
58777
|
}
|
|
58551
|
-
const fragmentType = config2.schema.getType(
|
|
58778
|
+
const fragmentType = config2.schema.getType(fragment2);
|
|
58552
58779
|
const { type, wrappers } = unwrapType(
|
|
58553
58780
|
config2,
|
|
58554
58781
|
fragmentType.getFields()[key].type
|
|
@@ -58560,7 +58787,7 @@ async function paginate(config2, documents) {
|
|
|
58560
58787
|
}
|
|
58561
58788
|
];
|
|
58562
58789
|
});
|
|
58563
|
-
const typeConfig = config2.typeConfig?.[
|
|
58790
|
+
const typeConfig = config2.typeConfig?.[fragment2];
|
|
58564
58791
|
const queryDoc = {
|
|
58565
58792
|
kind: graphql8.Kind.DOCUMENT,
|
|
58566
58793
|
definitions: [
|
|
@@ -58902,7 +59129,7 @@ async function addListFragments(config2, documents) {
|
|
|
58902
59129
|
);
|
|
58903
59130
|
const targetField = ancestors[ancestors.length - 1];
|
|
58904
59131
|
const targetFieldDefinition = parentType.getFields()[targetField.name.value];
|
|
58905
|
-
const { selection
|
|
59132
|
+
const { selection, type, connection } = connectionSelection(
|
|
58906
59133
|
config2,
|
|
58907
59134
|
targetFieldDefinition,
|
|
58908
59135
|
parentTypeFromAncestors(
|
|
@@ -58913,7 +59140,7 @@ async function addListFragments(config2, documents) {
|
|
|
58913
59140
|
ancestors[ancestors.length - 1].selectionSet
|
|
58914
59141
|
);
|
|
58915
59142
|
lists[nameArg.value.value] = {
|
|
58916
|
-
selection
|
|
59143
|
+
selection,
|
|
58917
59144
|
type,
|
|
58918
59145
|
filename: doc.filename
|
|
58919
59146
|
};
|
|
@@ -58991,14 +59218,14 @@ async function addListFragments(config2, documents) {
|
|
|
58991
59218
|
const generatedDoc = {
|
|
58992
59219
|
kind: graphql9.Kind.DOCUMENT,
|
|
58993
59220
|
definitions: Object.entries(lists).flatMap(
|
|
58994
|
-
([name, { selection
|
|
59221
|
+
([name, { selection, type }]) => {
|
|
58995
59222
|
const schemaType = config2.schema.getType(type.name);
|
|
58996
|
-
if (!
|
|
59223
|
+
if (!selection) {
|
|
58997
59224
|
throw new HoudiniError({ message: "Lists must have a selection" });
|
|
58998
59225
|
}
|
|
58999
59226
|
const fragmentSelection = {
|
|
59000
59227
|
kind: graphql9.Kind.SELECTION_SET,
|
|
59001
|
-
selections: [...
|
|
59228
|
+
selections: [...selection.selections]
|
|
59002
59229
|
};
|
|
59003
59230
|
if (schemaType && fragmentSelection && !fragmentSelection?.selections.find(
|
|
59004
59231
|
(field) => field.kind === "Field" && config2.keyFieldsForType(type.name).includes(field.name.value)
|
|
@@ -59090,7 +59317,7 @@ async function addListFragments(config2, documents) {
|
|
|
59090
59317
|
artifact: null
|
|
59091
59318
|
});
|
|
59092
59319
|
}
|
|
59093
|
-
function connectionSelection(config2, field, type,
|
|
59320
|
+
function connectionSelection(config2, field, type, selection) {
|
|
59094
59321
|
const fieldArgs = field.args.reduce(
|
|
59095
59322
|
(args, arg) => ({
|
|
59096
59323
|
...args,
|
|
@@ -59099,34 +59326,34 @@ function connectionSelection(config2, field, type, selection2) {
|
|
|
59099
59326
|
{}
|
|
59100
59327
|
);
|
|
59101
59328
|
if (fieldArgs["limit"]) {
|
|
59102
|
-
return { selection
|
|
59329
|
+
return { selection, type, connection: false, error: null };
|
|
59103
59330
|
}
|
|
59104
59331
|
const forwardPagination = fieldArgs["first"] === "Int" && ["Cursor", "String"].includes(fieldArgs["after"]);
|
|
59105
59332
|
const backwardsPagination = fieldArgs["last"] === "Int" && ["Cursor", "String"].includes(fieldArgs["before"]);
|
|
59106
59333
|
if (!forwardPagination && !backwardsPagination) {
|
|
59107
|
-
return { selection
|
|
59334
|
+
return { selection, type, connection: false, error: missingPaginationArgMessage(config2) };
|
|
59108
59335
|
}
|
|
59109
|
-
const edgesField =
|
|
59110
|
-
(
|
|
59336
|
+
const edgesField = selection?.selections.find(
|
|
59337
|
+
(selection2) => selection2.kind === "Field" && selection2.name.value === "edges"
|
|
59111
59338
|
);
|
|
59112
59339
|
if (!edgesField) {
|
|
59113
|
-
return { selection
|
|
59340
|
+
return { selection, type, connection: false, error: missingEdgeSelectionMessage(config2) };
|
|
59114
59341
|
}
|
|
59115
59342
|
const nodeSelection = edgesField.selectionSet?.selections.find(
|
|
59116
|
-
(
|
|
59343
|
+
(selection2) => selection2.kind === "Field" && selection2.name.value === "node"
|
|
59117
59344
|
);
|
|
59118
59345
|
if (!nodeSelection.selectionSet) {
|
|
59119
|
-
return { selection
|
|
59346
|
+
return { selection, type, connection: false, error: missingNodeSelectionMessage(config2) };
|
|
59120
59347
|
}
|
|
59121
59348
|
const edgeField = unwrapType(config2, field.type).type.getFields()["edges"];
|
|
59122
59349
|
const { wrappers, type: edgeFieldType } = unwrapType(config2, edgeField.type);
|
|
59123
59350
|
const list = wrappers[wrappers.length - 2] === "List" /* List */;
|
|
59124
59351
|
if (!list) {
|
|
59125
|
-
return { selection
|
|
59352
|
+
return { selection, type, connection: false, error: edgeInvalidTypeMessage(config2) };
|
|
59126
59353
|
}
|
|
59127
59354
|
const nodeField = edgeFieldType.getFields()["node"];
|
|
59128
59355
|
if (!nodeField) {
|
|
59129
|
-
return { selection
|
|
59356
|
+
return { selection, type, connection: false, error: nodeNotDefinedMessage(config2) };
|
|
59130
59357
|
}
|
|
59131
59358
|
return {
|
|
59132
59359
|
selection: nodeSelection.selectionSet,
|
|
@@ -59205,59 +59432,45 @@ function fieldKey(config2, field) {
|
|
|
59205
59432
|
}
|
|
59206
59433
|
|
|
59207
59434
|
// src/codegen/generators/artifacts/selection.ts
|
|
59208
|
-
function
|
|
59435
|
+
function selection_default(args) {
|
|
59436
|
+
const typeMap = {};
|
|
59437
|
+
const abstractTypes = [];
|
|
59438
|
+
return mergeSelection({
|
|
59439
|
+
object: prepareSelection({ ...args, typeMap, abstractTypes }),
|
|
59440
|
+
filepath: args.filepath,
|
|
59441
|
+
typeMap,
|
|
59442
|
+
abstractTypes
|
|
59443
|
+
});
|
|
59444
|
+
}
|
|
59445
|
+
function prepareSelection({
|
|
59209
59446
|
config: config2,
|
|
59210
59447
|
filepath,
|
|
59211
59448
|
rootType,
|
|
59212
59449
|
selections,
|
|
59213
59450
|
operations,
|
|
59214
59451
|
path: path2 = [],
|
|
59215
|
-
includeFragments,
|
|
59216
59452
|
document,
|
|
59217
|
-
inConnection
|
|
59453
|
+
inConnection,
|
|
59454
|
+
typeMap,
|
|
59455
|
+
abstractTypes
|
|
59218
59456
|
}) {
|
|
59219
59457
|
let object = {};
|
|
59220
|
-
const typeMap = {};
|
|
59221
|
-
const abstractTypes = [];
|
|
59222
59458
|
for (const field of selections) {
|
|
59223
|
-
if (field.kind === "
|
|
59224
|
-
const fragmentDefinition = document.document.definitions.find(
|
|
59225
|
-
(defn) => defn.kind === "FragmentDefinition" && defn.name.value === field.name.value
|
|
59226
|
-
);
|
|
59227
|
-
if (!fragmentDefinition) {
|
|
59228
|
-
throw new HoudiniError({
|
|
59229
|
-
filepath,
|
|
59230
|
-
message: "selection: could not find definition for fragment " + field.name.value
|
|
59231
|
-
});
|
|
59232
|
-
}
|
|
59233
|
-
object = deepMerge(
|
|
59234
|
-
filepath,
|
|
59235
|
-
object,
|
|
59236
|
-
selection({
|
|
59237
|
-
config: config2,
|
|
59238
|
-
filepath,
|
|
59239
|
-
rootType: fragmentDefinition.typeCondition.name.value,
|
|
59240
|
-
operations,
|
|
59241
|
-
selections: fragmentDefinition.selectionSet.selections,
|
|
59242
|
-
path: path2,
|
|
59243
|
-
includeFragments,
|
|
59244
|
-
document
|
|
59245
|
-
})
|
|
59246
|
-
);
|
|
59247
|
-
} else if (field.kind === "InlineFragment") {
|
|
59459
|
+
if (field.kind === "InlineFragment") {
|
|
59248
59460
|
if (!field.typeCondition || field.typeCondition.name.value === rootType) {
|
|
59249
59461
|
object.fields = deepMerge(
|
|
59250
59462
|
filepath,
|
|
59251
59463
|
object.fields || {},
|
|
59252
|
-
|
|
59464
|
+
prepareSelection({
|
|
59253
59465
|
config: config2,
|
|
59254
59466
|
filepath,
|
|
59255
59467
|
rootType: field.typeCondition?.name.value || rootType,
|
|
59256
59468
|
operations,
|
|
59257
59469
|
selections: field.selectionSet.selections,
|
|
59258
59470
|
path: path2,
|
|
59259
|
-
|
|
59260
|
-
|
|
59471
|
+
document,
|
|
59472
|
+
typeMap,
|
|
59473
|
+
abstractTypes
|
|
59261
59474
|
}).fields || {}
|
|
59262
59475
|
);
|
|
59263
59476
|
} else {
|
|
@@ -59295,15 +59508,16 @@ function selection({
|
|
|
59295
59508
|
}
|
|
59296
59509
|
object.abstractFields.fields = {
|
|
59297
59510
|
...object.abstractFields.fields,
|
|
59298
|
-
[field.typeCondition.name.value]:
|
|
59511
|
+
[field.typeCondition.name.value]: prepareSelection({
|
|
59299
59512
|
config: config2,
|
|
59300
59513
|
filepath,
|
|
59301
59514
|
rootType: field.typeCondition?.name.value || rootType,
|
|
59302
59515
|
operations,
|
|
59303
59516
|
selections: field.selectionSet.selections,
|
|
59304
59517
|
path: path2,
|
|
59305
|
-
|
|
59306
|
-
|
|
59518
|
+
document,
|
|
59519
|
+
typeMap,
|
|
59520
|
+
abstractTypes
|
|
59307
59521
|
}).fields
|
|
59308
59522
|
};
|
|
59309
59523
|
}
|
|
@@ -59324,10 +59538,14 @@ function selection({
|
|
|
59324
59538
|
}
|
|
59325
59539
|
const typeName = fieldType.toString();
|
|
59326
59540
|
const pathSoFar = path2.concat(attributeName);
|
|
59327
|
-
const
|
|
59541
|
+
const keys = config2.keyFieldsForType(rootType);
|
|
59542
|
+
let fieldObj = {
|
|
59328
59543
|
type: typeName,
|
|
59329
59544
|
keyRaw: fieldKey(config2, field)
|
|
59330
59545
|
};
|
|
59546
|
+
if (keys.includes(field.name.value)) {
|
|
59547
|
+
fieldObj.visible = true;
|
|
59548
|
+
}
|
|
59331
59549
|
if (nullable) {
|
|
59332
59550
|
fieldObj.nullable = true;
|
|
59333
59551
|
}
|
|
@@ -59375,16 +59593,17 @@ function selection({
|
|
|
59375
59593
|
}
|
|
59376
59594
|
if (field.selectionSet) {
|
|
59377
59595
|
const connectionState = paginated && document.refetch?.method === "cursor" || continueConnection;
|
|
59378
|
-
fieldObj.selection =
|
|
59596
|
+
fieldObj.selection = prepareSelection({
|
|
59379
59597
|
config: config2,
|
|
59380
59598
|
filepath,
|
|
59381
59599
|
rootType: typeName,
|
|
59382
59600
|
selections: field.selectionSet.selections,
|
|
59383
59601
|
operations,
|
|
59384
59602
|
path: pathSoFar,
|
|
59385
|
-
includeFragments,
|
|
59386
59603
|
document,
|
|
59387
|
-
inConnection: connectionState
|
|
59604
|
+
inConnection: connectionState,
|
|
59605
|
+
typeMap,
|
|
59606
|
+
abstractTypes
|
|
59388
59607
|
});
|
|
59389
59608
|
}
|
|
59390
59609
|
if (field.arguments?.length && fieldObj.list) {
|
|
@@ -59399,12 +59618,29 @@ function selection({
|
|
|
59399
59618
|
if (graphql11.isInterfaceType(fieldType) || graphql11.isUnionType(fieldType)) {
|
|
59400
59619
|
fieldObj.abstract = true;
|
|
59401
59620
|
}
|
|
59621
|
+
if (object.fields?.[attributeName]) {
|
|
59622
|
+
fieldObj = deepMerge(filepath, object.fields[attributeName], fieldObj);
|
|
59623
|
+
}
|
|
59402
59624
|
object.fields = {
|
|
59403
59625
|
...object.fields,
|
|
59404
59626
|
[attributeName]: fieldObj
|
|
59405
59627
|
};
|
|
59628
|
+
} else if (field.kind === "FragmentSpread") {
|
|
59629
|
+
const { fragment: fragment2, args } = config2.getFragmentVariablesHash(field.name.value);
|
|
59630
|
+
object.fragments = {
|
|
59631
|
+
...object.fragments,
|
|
59632
|
+
[fragment2]: args ?? {}
|
|
59633
|
+
};
|
|
59406
59634
|
}
|
|
59407
59635
|
}
|
|
59636
|
+
return object;
|
|
59637
|
+
}
|
|
59638
|
+
function mergeSelection({
|
|
59639
|
+
filepath,
|
|
59640
|
+
object,
|
|
59641
|
+
typeMap,
|
|
59642
|
+
abstractTypes
|
|
59643
|
+
}) {
|
|
59408
59644
|
if (Object.keys(object.fields || {}).length > 0 && object.abstractFields && Object.keys(object.abstractFields.fields).length > 0) {
|
|
59409
59645
|
for (const [typeName, possibles] of Object.entries(typeMap)) {
|
|
59410
59646
|
let overlap = false;
|
|
@@ -59412,8 +59648,8 @@ function selection({
|
|
|
59412
59648
|
if (object.abstractFields.fields[typeName]) {
|
|
59413
59649
|
object.abstractFields.fields[typeName] = deepMerge(
|
|
59414
59650
|
filepath,
|
|
59415
|
-
object.abstractFields.fields[typeName]
|
|
59416
|
-
object.abstractFields.fields[possible]
|
|
59651
|
+
object.abstractFields.fields[typeName] ?? {},
|
|
59652
|
+
object.abstractFields.fields[possible] ?? {}
|
|
59417
59653
|
);
|
|
59418
59654
|
overlap = true;
|
|
59419
59655
|
}
|
|
@@ -59444,6 +59680,30 @@ function selection({
|
|
|
59444
59680
|
}
|
|
59445
59681
|
}
|
|
59446
59682
|
}
|
|
59683
|
+
for (const [key, value] of Object.entries(object.fields ?? {})) {
|
|
59684
|
+
const selection = value.selection;
|
|
59685
|
+
if (selection) {
|
|
59686
|
+
mergeSelection({
|
|
59687
|
+
filepath,
|
|
59688
|
+
typeMap,
|
|
59689
|
+
abstractTypes,
|
|
59690
|
+
object: selection
|
|
59691
|
+
});
|
|
59692
|
+
}
|
|
59693
|
+
}
|
|
59694
|
+
for (const [type, selection] of Object.entries(object.abstractFields?.fields ?? {})) {
|
|
59695
|
+
for (const [key, value] of Object.entries(selection ?? {})) {
|
|
59696
|
+
const selection2 = value.selection;
|
|
59697
|
+
if (selection2) {
|
|
59698
|
+
mergeSelection({
|
|
59699
|
+
filepath,
|
|
59700
|
+
typeMap,
|
|
59701
|
+
abstractTypes,
|
|
59702
|
+
object: selection2
|
|
59703
|
+
});
|
|
59704
|
+
}
|
|
59705
|
+
}
|
|
59706
|
+
}
|
|
59447
59707
|
return object;
|
|
59448
59708
|
}
|
|
59449
59709
|
|
|
@@ -59508,7 +59768,12 @@ function artifactGenerator(stats) {
|
|
|
59508
59768
|
writeIndexFile(config2, docs)
|
|
59509
59769
|
].concat(
|
|
59510
59770
|
docs.map(async (doc) => {
|
|
59511
|
-
const {
|
|
59771
|
+
const {
|
|
59772
|
+
document,
|
|
59773
|
+
name,
|
|
59774
|
+
generateArtifact,
|
|
59775
|
+
originalParsed
|
|
59776
|
+
} = doc;
|
|
59512
59777
|
if (!generateArtifact) {
|
|
59513
59778
|
return;
|
|
59514
59779
|
}
|
|
@@ -59547,6 +59812,16 @@ function artifactGenerator(stats) {
|
|
|
59547
59812
|
);
|
|
59548
59813
|
let rootType = "";
|
|
59549
59814
|
let selectionSet;
|
|
59815
|
+
let originalSelectionSet = null;
|
|
59816
|
+
const fragmentDefinitions = doc.document.definitions.filter(
|
|
59817
|
+
(definition) => definition.kind === "FragmentDefinition"
|
|
59818
|
+
).reduce(
|
|
59819
|
+
(prev, definition) => ({
|
|
59820
|
+
...prev,
|
|
59821
|
+
[definition.name.value]: definition
|
|
59822
|
+
}),
|
|
59823
|
+
{}
|
|
59824
|
+
);
|
|
59550
59825
|
if (docKind !== ArtifactKind.Fragment) {
|
|
59551
59826
|
const operation = operations[0];
|
|
59552
59827
|
if (operation.operation === "query") {
|
|
@@ -59563,9 +59838,12 @@ function artifactGenerator(stats) {
|
|
|
59563
59838
|
});
|
|
59564
59839
|
}
|
|
59565
59840
|
selectionSet = operation.selectionSet;
|
|
59841
|
+
if (originalParsed.definitions[0].kind === "OperationDefinition") {
|
|
59842
|
+
originalSelectionSet = originalParsed.definitions[0].selectionSet;
|
|
59843
|
+
}
|
|
59566
59844
|
} else {
|
|
59567
59845
|
const matchingFragment = fragments.find(
|
|
59568
|
-
(
|
|
59846
|
+
(fragment2) => fragment2.name.value === name
|
|
59569
59847
|
);
|
|
59570
59848
|
if (!matchingFragment) {
|
|
59571
59849
|
throw new HoudiniError({
|
|
@@ -59575,6 +59853,12 @@ function artifactGenerator(stats) {
|
|
|
59575
59853
|
}
|
|
59576
59854
|
rootType = matchingFragment.typeCondition.name.value;
|
|
59577
59855
|
selectionSet = matchingFragment.selectionSet;
|
|
59856
|
+
if (originalParsed.definitions[0].kind === "FragmentDefinition") {
|
|
59857
|
+
originalSelectionSet = originalParsed.definitions[0].selectionSet;
|
|
59858
|
+
}
|
|
59859
|
+
}
|
|
59860
|
+
if (!originalSelectionSet) {
|
|
59861
|
+
throw new Error("Not original selection set!");
|
|
59578
59862
|
}
|
|
59579
59863
|
let inputs = operations[0]?.variableDefinitions;
|
|
59580
59864
|
let directive = fragments[0]?.directives?.find(
|
|
@@ -59583,21 +59867,18 @@ function artifactGenerator(stats) {
|
|
|
59583
59867
|
if (docKind === ArtifactKind.Fragment && directive) {
|
|
59584
59868
|
inputs = fragmentArgumentsDefinitions(config2, doc.filename, fragments[0]);
|
|
59585
59869
|
}
|
|
59586
|
-
const
|
|
59870
|
+
const mask = selection_default({
|
|
59587
59871
|
config: config2,
|
|
59588
59872
|
filepath: doc.filename,
|
|
59589
|
-
|
|
59590
|
-
|
|
59591
|
-
|
|
59592
|
-
|
|
59593
|
-
|
|
59594
|
-
|
|
59595
|
-
|
|
59596
|
-
|
|
59597
|
-
|
|
59598
|
-
),
|
|
59599
|
-
ignoreMaskDisable: docKind === "HoudiniQuery",
|
|
59600
|
-
applyFragments: docKind !== "HoudiniFragment"
|
|
59873
|
+
rootType,
|
|
59874
|
+
operations: {},
|
|
59875
|
+
document: doc,
|
|
59876
|
+
selections: flattenSelections({
|
|
59877
|
+
config: config2,
|
|
59878
|
+
filepath: doc.filename,
|
|
59879
|
+
selections: selectionSet.selections,
|
|
59880
|
+
fragmentDefinitions
|
|
59881
|
+
})
|
|
59601
59882
|
});
|
|
59602
59883
|
let artifact = {
|
|
59603
59884
|
name,
|
|
@@ -59606,21 +59887,29 @@ function artifactGenerator(stats) {
|
|
|
59606
59887
|
refetch: doc.refetch,
|
|
59607
59888
|
raw: rawString,
|
|
59608
59889
|
rootType,
|
|
59609
|
-
selection:
|
|
59890
|
+
selection: selection_default({
|
|
59610
59891
|
config: config2,
|
|
59611
59892
|
filepath: doc.filename,
|
|
59612
59893
|
rootType,
|
|
59613
|
-
selections:
|
|
59894
|
+
selections: flattenSelections({
|
|
59895
|
+
config: config2,
|
|
59896
|
+
filepath: doc.filename,
|
|
59897
|
+
selections: selectionSet.selections,
|
|
59898
|
+
fragmentDefinitions,
|
|
59899
|
+
ignoreMaskDisable: docKind !== "HoudiniFragment",
|
|
59900
|
+
keepFragmentSpreadNodes: true
|
|
59901
|
+
}),
|
|
59614
59902
|
operations: operationsByPath(
|
|
59615
59903
|
config2,
|
|
59616
59904
|
doc.filename,
|
|
59617
59905
|
operations[0],
|
|
59618
59906
|
filterTypes
|
|
59619
59907
|
),
|
|
59620
|
-
includeFragments: docKind !== "HoudiniFragment",
|
|
59621
59908
|
document: doc
|
|
59622
|
-
})
|
|
59909
|
+
}),
|
|
59910
|
+
pluginData: {}
|
|
59623
59911
|
};
|
|
59912
|
+
applyMask(config2, artifact.selection, mask);
|
|
59624
59913
|
artifact.pluginData = {};
|
|
59625
59914
|
for (const plugin2 of config2.plugins) {
|
|
59626
59915
|
if (!plugin2.artifactData) {
|
|
@@ -59697,6 +59986,49 @@ function artifactGenerator(stats) {
|
|
|
59697
59986
|
stats.deleted = await cleanupFiles(config2.artifactDirectory, listOfArtifacts);
|
|
59698
59987
|
};
|
|
59699
59988
|
}
|
|
59989
|
+
function applyMask(config2, target, mask) {
|
|
59990
|
+
for (const [fieldName, value] of Object.entries(mask.fields ?? {})) {
|
|
59991
|
+
const targetSelection = target.fields?.[fieldName];
|
|
59992
|
+
if (!targetSelection || !mask.fields) {
|
|
59993
|
+
continue;
|
|
59994
|
+
}
|
|
59995
|
+
targetSelection.visible = true;
|
|
59996
|
+
if (targetSelection.selection && value.selection) {
|
|
59997
|
+
applyMask(config2, targetSelection.selection, value.selection);
|
|
59998
|
+
}
|
|
59999
|
+
}
|
|
60000
|
+
for (const [type, selection] of Object.entries(mask.abstractFields?.fields ?? {})) {
|
|
60001
|
+
if (!selection) {
|
|
60002
|
+
continue;
|
|
60003
|
+
}
|
|
60004
|
+
if (target.abstractFields?.fields[type]) {
|
|
60005
|
+
applyMask(config2, { fields: target.abstractFields.fields[type] }, { fields: selection });
|
|
60006
|
+
}
|
|
60007
|
+
const targetType = config2.schema.getType(type);
|
|
60008
|
+
if (!targetType) {
|
|
60009
|
+
continue;
|
|
60010
|
+
}
|
|
60011
|
+
if (graphql12.isAbstractType(targetType)) {
|
|
60012
|
+
for (const possible of config2.schema.getPossibleTypes(targetType)) {
|
|
60013
|
+
if (target.abstractFields?.fields[possible.name]) {
|
|
60014
|
+
applyMask(
|
|
60015
|
+
config2,
|
|
60016
|
+
{ fields: target.abstractFields.fields[possible.name] },
|
|
60017
|
+
{ fields: selection }
|
|
60018
|
+
);
|
|
60019
|
+
}
|
|
60020
|
+
}
|
|
60021
|
+
}
|
|
60022
|
+
const mappedType = target.abstractFields?.typeMap[type];
|
|
60023
|
+
if (target.abstractFields && mappedType && target.abstractFields.fields[mappedType]) {
|
|
60024
|
+
applyMask(
|
|
60025
|
+
config2,
|
|
60026
|
+
{ fields: target.abstractFields.fields[mappedType] },
|
|
60027
|
+
{ fields: selection }
|
|
60028
|
+
);
|
|
60029
|
+
}
|
|
60030
|
+
}
|
|
60031
|
+
}
|
|
59700
60032
|
|
|
59701
60033
|
// src/codegen/generators/runtime/graphqlFunction.ts
|
|
59702
60034
|
var recast6 = __toESM(require_main2(), 1);
|
|
@@ -60022,7 +60354,7 @@ function addReferencedInputTypes(config2, filepath, body, visitedTypes, missingS
|
|
|
60022
60354
|
var graphql16 = __toESM(require_graphql2(), 1);
|
|
60023
60355
|
var recast10 = __toESM(require_main2(), 1);
|
|
60024
60356
|
var AST10 = recast10.types.builders;
|
|
60025
|
-
var
|
|
60357
|
+
var fragmentKey2 = " $fragments";
|
|
60026
60358
|
function inlineType({
|
|
60027
60359
|
config: config2,
|
|
60028
60360
|
filepath,
|
|
@@ -60062,24 +60394,24 @@ function inlineType({
|
|
|
60062
60394
|
const rootObj = type;
|
|
60063
60395
|
const inlineFragments = {};
|
|
60064
60396
|
const selectedFields = [];
|
|
60065
|
-
for (const
|
|
60066
|
-
if (
|
|
60067
|
-
const fragmentType = config2.schema.getType(
|
|
60397
|
+
for (const selection of selections) {
|
|
60398
|
+
if (selection.kind === "InlineFragment" && selection.typeCondition) {
|
|
60399
|
+
const fragmentType = config2.schema.getType(selection.typeCondition.name.value);
|
|
60068
60400
|
if (!graphql16.isInterfaceType(type) && !graphql16.isUnionType(type)) {
|
|
60069
|
-
selectedFields.push(...
|
|
60401
|
+
selectedFields.push(...selection.selectionSet.selections);
|
|
60070
60402
|
continue;
|
|
60071
60403
|
}
|
|
60072
60404
|
if (!graphql16.isInterfaceType(fragmentType) && !graphql16.isUnionType(fragmentType)) {
|
|
60073
60405
|
if (!inlineFragments[fragmentType.name]) {
|
|
60074
60406
|
inlineFragments[fragmentType.name] = [];
|
|
60075
60407
|
}
|
|
60076
|
-
inlineFragments[fragmentType.name].push(...
|
|
60408
|
+
inlineFragments[fragmentType.name].push(...selection.selectionSet.selections);
|
|
60077
60409
|
continue;
|
|
60078
60410
|
}
|
|
60079
60411
|
const possibleParents = config2.schema.getPossibleTypes(type).map((t) => t.name);
|
|
60080
60412
|
const freeSelections = [];
|
|
60081
60413
|
const typeSpecificSelections = {};
|
|
60082
|
-
for (const node of
|
|
60414
|
+
for (const node of selection.selectionSet.selections) {
|
|
60083
60415
|
if (node.kind !== "InlineFragment") {
|
|
60084
60416
|
freeSelections.push(node);
|
|
60085
60417
|
} else if (node.typeCondition) {
|
|
@@ -60102,23 +60434,30 @@ function inlineType({
|
|
|
60102
60434
|
);
|
|
60103
60435
|
}
|
|
60104
60436
|
}
|
|
60105
|
-
} else if (
|
|
60106
|
-
selectedFields.push(...
|
|
60437
|
+
} else if (selection.kind === "InlineFragment" && !selection.typeCondition) {
|
|
60438
|
+
selectedFields.push(...selection.selectionSet.selections);
|
|
60107
60439
|
} else {
|
|
60108
|
-
selectedFields.push(
|
|
60440
|
+
selectedFields.push(selection);
|
|
60109
60441
|
}
|
|
60110
60442
|
}
|
|
60443
|
+
const fields = Object.values(
|
|
60444
|
+
selectedFields.filter((field) => field.kind === "Field").reduce(
|
|
60445
|
+
(sel, field) => ({
|
|
60446
|
+
...sel,
|
|
60447
|
+
[field.alias?.value ?? field.name.value]: field
|
|
60448
|
+
}),
|
|
60449
|
+
{}
|
|
60450
|
+
)
|
|
60451
|
+
);
|
|
60111
60452
|
result = AST10.tsTypeLiteral([
|
|
60112
|
-
...(
|
|
60113
|
-
|
|
60114
|
-
|
|
60115
|
-
const { field } = selectionTypeInfo(config2.schema, filepath, rootObj, selection2);
|
|
60116
|
-
const attributeName = selection2.alias?.value || selection2.name.value;
|
|
60453
|
+
...fields.map((selection) => {
|
|
60454
|
+
const { field } = selectionTypeInfo(config2.schema, filepath, rootObj, selection);
|
|
60455
|
+
const attributeName = selection.alias?.value || selection.name.value;
|
|
60117
60456
|
let attributeType = inlineType({
|
|
60118
60457
|
config: config2,
|
|
60119
60458
|
filepath,
|
|
60120
60459
|
rootType: field.type,
|
|
60121
|
-
selections:
|
|
60460
|
+
selections: selection.selectionSet?.selections,
|
|
60122
60461
|
root: false,
|
|
60123
60462
|
allowReadonly,
|
|
60124
60463
|
visitedTypes,
|
|
@@ -60127,7 +60466,7 @@ function inlineType({
|
|
|
60127
60466
|
includeFragments,
|
|
60128
60467
|
allOptional
|
|
60129
60468
|
});
|
|
60130
|
-
const hasIncludeOrSkipDirective =
|
|
60469
|
+
const hasIncludeOrSkipDirective = selection.directives && selection.directives.filter(
|
|
60131
60470
|
(directive) => directive.name.value === "include" || directive.name.value === "skip"
|
|
60132
60471
|
).length > 0;
|
|
60133
60472
|
if (hasIncludeOrSkipDirective) {
|
|
@@ -60151,15 +60490,13 @@ function inlineType({
|
|
|
60151
60490
|
result.members.push(
|
|
60152
60491
|
readonlyProperty(
|
|
60153
60492
|
AST10.tsPropertySignature(
|
|
60154
|
-
AST10.
|
|
60493
|
+
AST10.stringLiteral(fragmentKey2),
|
|
60155
60494
|
AST10.tsTypeAnnotation(
|
|
60156
60495
|
AST10.tsTypeLiteral(
|
|
60157
60496
|
(fragmentSpreads || []).map(
|
|
60158
60497
|
(fragmentSpread) => AST10.tsPropertySignature(
|
|
60159
60498
|
AST10.identifier(fragmentSpread.name.value),
|
|
60160
|
-
AST10.tsTypeAnnotation(
|
|
60161
|
-
AST10.tsLiteralType(AST10.booleanLiteral(true))
|
|
60162
|
-
)
|
|
60499
|
+
AST10.tsTypeAnnotation(AST10.tsTypeLiteral([]))
|
|
60163
60500
|
)
|
|
60164
60501
|
)
|
|
60165
60502
|
)
|
|
@@ -60169,7 +60506,7 @@ function inlineType({
|
|
|
60169
60506
|
)
|
|
60170
60507
|
);
|
|
60171
60508
|
}
|
|
60172
|
-
const inlineFragmentSelections = Object.entries(inlineFragments).flatMap(([typeName,
|
|
60509
|
+
const inlineFragmentSelections = Object.entries(inlineFragments).flatMap(([typeName, fragment2]) => {
|
|
60173
60510
|
const fragmentRootType = config2.schema.getType(typeName);
|
|
60174
60511
|
if (!fragmentRootType) {
|
|
60175
60512
|
return [];
|
|
@@ -60178,7 +60515,7 @@ function inlineType({
|
|
|
60178
60515
|
config: config2,
|
|
60179
60516
|
filepath,
|
|
60180
60517
|
rootType: fragmentRootType,
|
|
60181
|
-
selections:
|
|
60518
|
+
selections: fragment2,
|
|
60182
60519
|
allowReadonly,
|
|
60183
60520
|
visitedTypes,
|
|
60184
60521
|
root,
|
|
@@ -60250,10 +60587,10 @@ function inlineType({
|
|
|
60250
60587
|
}
|
|
60251
60588
|
return result;
|
|
60252
60589
|
}
|
|
60253
|
-
function selectionTypeInfo(schema, filepath, rootType,
|
|
60254
|
-
const selectionName =
|
|
60590
|
+
function selectionTypeInfo(schema, filepath, rootType, selection) {
|
|
60591
|
+
const selectionName = selection.name.value;
|
|
60255
60592
|
let fields = {};
|
|
60256
|
-
if (
|
|
60593
|
+
if (selection.kind === "Field" && selection.name.value === "__typename") {
|
|
60257
60594
|
return {
|
|
60258
60595
|
field: {
|
|
60259
60596
|
name: "__typename",
|
|
@@ -60324,7 +60661,7 @@ async function generateDocumentTypes(config2, docs) {
|
|
|
60324
60661
|
filepath: filename,
|
|
60325
60662
|
selections: definition.selectionSet.selections,
|
|
60326
60663
|
fragmentDefinitions,
|
|
60327
|
-
|
|
60664
|
+
keepFragmentSpreadNodes: true
|
|
60328
60665
|
});
|
|
60329
60666
|
if (definition?.kind === "OperationDefinition") {
|
|
60330
60667
|
await generateOperationTypeDefs(
|
|
@@ -60548,39 +60885,26 @@ async function generateFragmentTypeDefs(config2, filepath, body, selections, def
|
|
|
60548
60885
|
if (!type) {
|
|
60549
60886
|
throw new Error("Should not get here");
|
|
60550
60887
|
}
|
|
60551
|
-
let extraExports = [];
|
|
60552
60888
|
let directive = definition.directives?.find(
|
|
60553
60889
|
(directive2) => directive2.name.value === config2.argumentsDirective
|
|
60554
60890
|
);
|
|
60555
|
-
|
|
60556
|
-
|
|
60557
|
-
|
|
60558
|
-
AST11.
|
|
60559
|
-
AST11.identifier(
|
|
60560
|
-
AST11.
|
|
60561
|
-
(
|
|
60562
|
-
|
|
60563
|
-
|
|
60564
|
-
|
|
60565
|
-
|
|
60566
|
-
|
|
60567
|
-
|
|
60568
|
-
missingScalars,
|
|
60569
|
-
definition2,
|
|
60570
|
-
body
|
|
60571
|
-
)
|
|
60572
|
-
),
|
|
60573
|
-
definition2.type.kind !== "NonNullType"
|
|
60574
|
-
);
|
|
60575
|
-
}
|
|
60576
|
-
)
|
|
60577
|
-
)
|
|
60578
|
-
)
|
|
60579
|
-
)
|
|
60580
|
-
);
|
|
60581
|
-
}
|
|
60891
|
+
let inputValue = !directive ? AST11.tsTypeLiteral([]) : AST11.tsTypeLiteral(
|
|
60892
|
+
(fragmentArgumentsDefinitions(config2, filepath, definition) || []).map(
|
|
60893
|
+
(definition2) => {
|
|
60894
|
+
return AST11.tsPropertySignature(
|
|
60895
|
+
AST11.identifier(definition2.variable.name.value),
|
|
60896
|
+
AST11.tsTypeAnnotation(
|
|
60897
|
+
tsTypeReference(config2, missingScalars, definition2, body)
|
|
60898
|
+
),
|
|
60899
|
+
definition2.type.kind !== "NonNullType"
|
|
60900
|
+
);
|
|
60901
|
+
}
|
|
60902
|
+
)
|
|
60903
|
+
);
|
|
60582
60904
|
body.push(
|
|
60583
|
-
|
|
60905
|
+
AST11.exportNamedDeclaration(
|
|
60906
|
+
AST11.tsTypeAliasDeclaration(AST11.identifier(inputTypeName), inputValue)
|
|
60907
|
+
),
|
|
60584
60908
|
AST11.exportNamedDeclaration(
|
|
60585
60909
|
AST11.tsTypeAliasDeclaration(
|
|
60586
60910
|
AST11.identifier(propTypeName),
|
|
@@ -60596,14 +60920,12 @@ async function generateFragmentTypeDefs(config2, filepath, body, selections, def
|
|
|
60596
60920
|
),
|
|
60597
60921
|
readonlyProperty(
|
|
60598
60922
|
AST11.tsPropertySignature(
|
|
60599
|
-
AST11.stringLiteral(
|
|
60923
|
+
AST11.stringLiteral(fragmentKey2),
|
|
60600
60924
|
AST11.tsTypeAnnotation(
|
|
60601
60925
|
AST11.tsTypeLiteral([
|
|
60602
60926
|
AST11.tsPropertySignature(
|
|
60603
60927
|
AST11.stringLiteral(propTypeName),
|
|
60604
|
-
AST11.tsTypeAnnotation(
|
|
60605
|
-
AST11.tsLiteralType(AST11.booleanLiteral(true))
|
|
60606
|
-
)
|
|
60928
|
+
AST11.tsTypeAnnotation(AST11.tsAnyKeyword())
|
|
60607
60929
|
)
|
|
60608
60930
|
])
|
|
60609
60931
|
)
|
|
@@ -61315,6 +61637,13 @@ async function addID(config2, documents) {
|
|
|
61315
61637
|
return;
|
|
61316
61638
|
}
|
|
61317
61639
|
return addKeysToSelection(config2, node, fragmentType);
|
|
61640
|
+
},
|
|
61641
|
+
FragmentDefinition(node) {
|
|
61642
|
+
const fragmentType = config2.schema.getType(node.typeCondition.name.value);
|
|
61643
|
+
if (!fragmentType) {
|
|
61644
|
+
return;
|
|
61645
|
+
}
|
|
61646
|
+
return addKeysToSelection(config2, node, fragmentType);
|
|
61318
61647
|
}
|
|
61319
61648
|
});
|
|
61320
61649
|
}
|
|
@@ -61333,7 +61662,7 @@ function addKeysToSelection(config2, node, fieldType) {
|
|
|
61333
61662
|
const selections = [...node.selectionSet.selections];
|
|
61334
61663
|
for (const keyField of keyFields) {
|
|
61335
61664
|
if (node.selectionSet.selections.find(
|
|
61336
|
-
(
|
|
61665
|
+
(selection) => selection.kind === "Field" && !selection.alias && selection.name.value === keyField
|
|
61337
61666
|
)) {
|
|
61338
61667
|
continue;
|
|
61339
61668
|
}
|
|
@@ -62624,7 +62953,7 @@ function pipelineTest(config2, documents, shouldPass, testBody) {
|
|
|
62624
62953
|
} catch (e) {
|
|
62625
62954
|
if (shouldPass) {
|
|
62626
62955
|
console.error(e);
|
|
62627
|
-
throw "pipeline failed when it should have passed";
|
|
62956
|
+
throw "pipeline failed when it should have passed. " + e;
|
|
62628
62957
|
}
|
|
62629
62958
|
error = e;
|
|
62630
62959
|
}
|