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
|
@@ -3363,7 +3363,7 @@ var require_definition = __commonJS({
|
|
|
3363
3363
|
exports.assertLeafType = assertLeafType;
|
|
3364
3364
|
exports.isCompositeType = isCompositeType;
|
|
3365
3365
|
exports.assertCompositeType = assertCompositeType;
|
|
3366
|
-
exports.isAbstractType =
|
|
3366
|
+
exports.isAbstractType = isAbstractType4;
|
|
3367
3367
|
exports.assertAbstractType = assertAbstractType;
|
|
3368
3368
|
exports.GraphQLList = GraphQLList2;
|
|
3369
3369
|
exports.GraphQLNonNull = GraphQLNonNull2;
|
|
@@ -3534,11 +3534,11 @@ var require_definition = __commonJS({
|
|
|
3534
3534
|
}
|
|
3535
3535
|
return type;
|
|
3536
3536
|
}
|
|
3537
|
-
function
|
|
3537
|
+
function isAbstractType4(type) {
|
|
3538
3538
|
return isInterfaceType6(type) || isUnionType7(type);
|
|
3539
3539
|
}
|
|
3540
3540
|
function assertAbstractType(type) {
|
|
3541
|
-
if (!
|
|
3541
|
+
if (!isAbstractType4(type)) {
|
|
3542
3542
|
throw new Error("Expected ".concat((0, _inspect.default)(type), " to be a GraphQL abstract type."));
|
|
3543
3543
|
}
|
|
3544
3544
|
return type;
|
|
@@ -6802,8 +6802,8 @@ var require_KnownFragmentNamesRule = __commonJS({
|
|
|
6802
6802
|
return {
|
|
6803
6803
|
FragmentSpread: function FragmentSpread(node) {
|
|
6804
6804
|
var fragmentName = node.name.value;
|
|
6805
|
-
var
|
|
6806
|
-
if (!
|
|
6805
|
+
var fragment2 = context.getFragment(fragmentName);
|
|
6806
|
+
if (!fragment2) {
|
|
6807
6807
|
context.reportError(new _GraphQLError.GraphQLError('Unknown fragment "'.concat(fragmentName, '".'), node.name));
|
|
6808
6808
|
}
|
|
6809
6809
|
}
|
|
@@ -6839,8 +6839,8 @@ var require_NoUnusedFragmentsRule = __commonJS({
|
|
|
6839
6839
|
for (var _i2 = 0; _i2 < operationDefs.length; _i2++) {
|
|
6840
6840
|
var operation = operationDefs[_i2];
|
|
6841
6841
|
for (var _i4 = 0, _context$getRecursive2 = context.getRecursivelyReferencedFragments(operation); _i4 < _context$getRecursive2.length; _i4++) {
|
|
6842
|
-
var
|
|
6843
|
-
fragmentNameUsed[
|
|
6842
|
+
var fragment2 = _context$getRecursive2[_i4];
|
|
6843
|
+
fragmentNameUsed[fragment2.name.value] = true;
|
|
6844
6844
|
}
|
|
6845
6845
|
}
|
|
6846
6846
|
for (var _i6 = 0; _i6 < fragmentDefs.length; _i6++) {
|
|
@@ -6930,13 +6930,13 @@ var require_NoFragmentCyclesRule = __commonJS({
|
|
|
6930
6930
|
return false;
|
|
6931
6931
|
}
|
|
6932
6932
|
};
|
|
6933
|
-
function detectCycleRecursive(
|
|
6934
|
-
if (visitedFrags[
|
|
6933
|
+
function detectCycleRecursive(fragment2) {
|
|
6934
|
+
if (visitedFrags[fragment2.name.value]) {
|
|
6935
6935
|
return;
|
|
6936
6936
|
}
|
|
6937
|
-
var fragmentName =
|
|
6937
|
+
var fragmentName = fragment2.name.value;
|
|
6938
6938
|
visitedFrags[fragmentName] = true;
|
|
6939
|
-
var spreadNodes = context.getFragmentSpreads(
|
|
6939
|
+
var spreadNodes = context.getFragmentSpreads(fragment2.selectionSet);
|
|
6940
6940
|
if (spreadNodes.length === 0) {
|
|
6941
6941
|
return;
|
|
6942
6942
|
}
|
|
@@ -7757,11 +7757,11 @@ var require_OverlappingFieldsCanBeMergedRule = __commonJS({
|
|
|
7757
7757
|
return conflicts;
|
|
7758
7758
|
}
|
|
7759
7759
|
function collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, fieldMap, fragmentName) {
|
|
7760
|
-
var
|
|
7761
|
-
if (!
|
|
7760
|
+
var fragment2 = context.getFragment(fragmentName);
|
|
7761
|
+
if (!fragment2) {
|
|
7762
7762
|
return;
|
|
7763
7763
|
}
|
|
7764
|
-
var _getReferencedFieldsA = getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames,
|
|
7764
|
+
var _getReferencedFieldsA = getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragment2), fieldMap2 = _getReferencedFieldsA[0], fragmentNames2 = _getReferencedFieldsA[1];
|
|
7765
7765
|
if (fieldMap === fieldMap2) {
|
|
7766
7766
|
return;
|
|
7767
7767
|
}
|
|
@@ -7932,38 +7932,38 @@ var require_OverlappingFieldsCanBeMergedRule = __commonJS({
|
|
|
7932
7932
|
}
|
|
7933
7933
|
return cached;
|
|
7934
7934
|
}
|
|
7935
|
-
function getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames,
|
|
7936
|
-
var cached = cachedFieldsAndFragmentNames.get(
|
|
7935
|
+
function getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragment2) {
|
|
7936
|
+
var cached = cachedFieldsAndFragmentNames.get(fragment2.selectionSet);
|
|
7937
7937
|
if (cached) {
|
|
7938
7938
|
return cached;
|
|
7939
7939
|
}
|
|
7940
|
-
var fragmentType = (0, _typeFromAST.typeFromAST)(context.getSchema(),
|
|
7941
|
-
return getFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragmentType,
|
|
7940
|
+
var fragmentType = (0, _typeFromAST.typeFromAST)(context.getSchema(), fragment2.typeCondition);
|
|
7941
|
+
return getFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragmentType, fragment2.selectionSet);
|
|
7942
7942
|
}
|
|
7943
7943
|
function _collectFieldsAndFragmentNames(context, parentType, selectionSet, nodeAndDefs, fragmentNames) {
|
|
7944
7944
|
for (var _i9 = 0, _selectionSet$selecti2 = selectionSet.selections; _i9 < _selectionSet$selecti2.length; _i9++) {
|
|
7945
|
-
var
|
|
7946
|
-
switch (
|
|
7945
|
+
var selection = _selectionSet$selecti2[_i9];
|
|
7946
|
+
switch (selection.kind) {
|
|
7947
7947
|
case _kinds.Kind.FIELD: {
|
|
7948
|
-
var fieldName =
|
|
7948
|
+
var fieldName = selection.name.value;
|
|
7949
7949
|
var fieldDef = void 0;
|
|
7950
7950
|
if ((0, _definition.isObjectType)(parentType) || (0, _definition.isInterfaceType)(parentType)) {
|
|
7951
7951
|
fieldDef = parentType.getFields()[fieldName];
|
|
7952
7952
|
}
|
|
7953
|
-
var responseName =
|
|
7953
|
+
var responseName = selection.alias ? selection.alias.value : fieldName;
|
|
7954
7954
|
if (!nodeAndDefs[responseName]) {
|
|
7955
7955
|
nodeAndDefs[responseName] = [];
|
|
7956
7956
|
}
|
|
7957
|
-
nodeAndDefs[responseName].push([parentType,
|
|
7957
|
+
nodeAndDefs[responseName].push([parentType, selection, fieldDef]);
|
|
7958
7958
|
break;
|
|
7959
7959
|
}
|
|
7960
7960
|
case _kinds.Kind.FRAGMENT_SPREAD:
|
|
7961
|
-
fragmentNames[
|
|
7961
|
+
fragmentNames[selection.name.value] = true;
|
|
7962
7962
|
break;
|
|
7963
7963
|
case _kinds.Kind.INLINE_FRAGMENT: {
|
|
7964
|
-
var typeCondition =
|
|
7964
|
+
var typeCondition = selection.typeCondition;
|
|
7965
7965
|
var inlineFragmentType = typeCondition ? (0, _typeFromAST.typeFromAST)(context.getSchema(), typeCondition) : parentType;
|
|
7966
|
-
_collectFieldsAndFragmentNames(context, inlineFragmentType,
|
|
7966
|
+
_collectFieldsAndFragmentNames(context, inlineFragmentType, selection.selectionSet, nodeAndDefs, fragmentNames);
|
|
7967
7967
|
break;
|
|
7968
7968
|
}
|
|
7969
7969
|
}
|
|
@@ -8499,11 +8499,11 @@ var require_ValidationContext = __commonJS({
|
|
|
8499
8499
|
while (setsToVisit.length !== 0) {
|
|
8500
8500
|
var set = setsToVisit.pop();
|
|
8501
8501
|
for (var _i2 = 0, _set$selections2 = set.selections; _i2 < _set$selections2.length; _i2++) {
|
|
8502
|
-
var
|
|
8503
|
-
if (
|
|
8504
|
-
spreads.push(
|
|
8505
|
-
} else if (
|
|
8506
|
-
setsToVisit.push(
|
|
8502
|
+
var selection = _set$selections2[_i2];
|
|
8503
|
+
if (selection.kind === _kinds.Kind.FRAGMENT_SPREAD) {
|
|
8504
|
+
spreads.push(selection);
|
|
8505
|
+
} else if (selection.selectionSet) {
|
|
8506
|
+
setsToVisit.push(selection.selectionSet);
|
|
8507
8507
|
}
|
|
8508
8508
|
}
|
|
8509
8509
|
}
|
|
@@ -8524,10 +8524,10 @@ var require_ValidationContext = __commonJS({
|
|
|
8524
8524
|
var fragName = spread.name.value;
|
|
8525
8525
|
if (collectedNames[fragName] !== true) {
|
|
8526
8526
|
collectedNames[fragName] = true;
|
|
8527
|
-
var
|
|
8528
|
-
if (
|
|
8529
|
-
fragments.push(
|
|
8530
|
-
nodesToVisit.push(
|
|
8527
|
+
var fragment2 = this.getFragment(fragName);
|
|
8528
|
+
if (fragment2) {
|
|
8529
|
+
fragments.push(fragment2);
|
|
8530
|
+
nodesToVisit.push(fragment2.selectionSet);
|
|
8531
8531
|
}
|
|
8532
8532
|
}
|
|
8533
8533
|
}
|
|
@@ -9440,37 +9440,37 @@ var require_execute = __commonJS({
|
|
|
9440
9440
|
}
|
|
9441
9441
|
function collectFields(exeContext, runtimeType, selectionSet, fields, visitedFragmentNames) {
|
|
9442
9442
|
for (var _i6 = 0, _selectionSet$selecti2 = selectionSet.selections; _i6 < _selectionSet$selecti2.length; _i6++) {
|
|
9443
|
-
var
|
|
9444
|
-
switch (
|
|
9443
|
+
var selection = _selectionSet$selecti2[_i6];
|
|
9444
|
+
switch (selection.kind) {
|
|
9445
9445
|
case _kinds.Kind.FIELD: {
|
|
9446
|
-
if (!shouldIncludeNode(exeContext,
|
|
9446
|
+
if (!shouldIncludeNode(exeContext, selection)) {
|
|
9447
9447
|
continue;
|
|
9448
9448
|
}
|
|
9449
|
-
var name = getFieldEntryKey(
|
|
9449
|
+
var name = getFieldEntryKey(selection);
|
|
9450
9450
|
if (!fields[name]) {
|
|
9451
9451
|
fields[name] = [];
|
|
9452
9452
|
}
|
|
9453
|
-
fields[name].push(
|
|
9453
|
+
fields[name].push(selection);
|
|
9454
9454
|
break;
|
|
9455
9455
|
}
|
|
9456
9456
|
case _kinds.Kind.INLINE_FRAGMENT: {
|
|
9457
|
-
if (!shouldIncludeNode(exeContext,
|
|
9457
|
+
if (!shouldIncludeNode(exeContext, selection) || !doesFragmentConditionMatch(exeContext, selection, runtimeType)) {
|
|
9458
9458
|
continue;
|
|
9459
9459
|
}
|
|
9460
|
-
collectFields(exeContext, runtimeType,
|
|
9460
|
+
collectFields(exeContext, runtimeType, selection.selectionSet, fields, visitedFragmentNames);
|
|
9461
9461
|
break;
|
|
9462
9462
|
}
|
|
9463
9463
|
case _kinds.Kind.FRAGMENT_SPREAD: {
|
|
9464
|
-
var fragName =
|
|
9465
|
-
if (visitedFragmentNames[fragName] || !shouldIncludeNode(exeContext,
|
|
9464
|
+
var fragName = selection.name.value;
|
|
9465
|
+
if (visitedFragmentNames[fragName] || !shouldIncludeNode(exeContext, selection)) {
|
|
9466
9466
|
continue;
|
|
9467
9467
|
}
|
|
9468
9468
|
visitedFragmentNames[fragName] = true;
|
|
9469
|
-
var
|
|
9470
|
-
if (!
|
|
9469
|
+
var fragment2 = exeContext.fragments[fragName];
|
|
9470
|
+
if (!fragment2 || !doesFragmentConditionMatch(exeContext, fragment2, runtimeType)) {
|
|
9471
9471
|
continue;
|
|
9472
9472
|
}
|
|
9473
|
-
collectFields(exeContext, runtimeType,
|
|
9473
|
+
collectFields(exeContext, runtimeType, fragment2.selectionSet, fields, visitedFragmentNames);
|
|
9474
9474
|
break;
|
|
9475
9475
|
}
|
|
9476
9476
|
}
|
|
@@ -9488,8 +9488,8 @@ var require_execute = __commonJS({
|
|
|
9488
9488
|
}
|
|
9489
9489
|
return true;
|
|
9490
9490
|
}
|
|
9491
|
-
function doesFragmentConditionMatch(exeContext,
|
|
9492
|
-
var typeConditionNode =
|
|
9491
|
+
function doesFragmentConditionMatch(exeContext, fragment2, type) {
|
|
9492
|
+
var typeConditionNode = fragment2.typeCondition;
|
|
9493
9493
|
if (!typeConditionNode) {
|
|
9494
9494
|
return true;
|
|
9495
9495
|
}
|
|
@@ -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 {
|
|
@@ -56827,11 +56946,17 @@ function deepMerge(filepath, ...targets) {
|
|
|
56827
56946
|
if (targets.length === 1) {
|
|
56828
56947
|
return targets[0];
|
|
56829
56948
|
} else if (targets.length === 2) {
|
|
56830
|
-
return (0, import_deepmerge.default)(targets[0], targets[1]
|
|
56949
|
+
return (0, import_deepmerge.default)(targets[0], targets[1], {
|
|
56950
|
+
arrayMerge: (source, update) => [...new Set(source.concat(update))]
|
|
56951
|
+
});
|
|
56831
56952
|
}
|
|
56832
56953
|
return deepMerge(filepath, targets[0], deepMerge(filepath, ...targets.slice(1)));
|
|
56833
56954
|
} catch (e) {
|
|
56834
|
-
throw new HoudiniError({
|
|
56955
|
+
throw new HoudiniError({
|
|
56956
|
+
filepath,
|
|
56957
|
+
message: "could not merge: " + targets,
|
|
56958
|
+
description: e.message
|
|
56959
|
+
});
|
|
56835
56960
|
}
|
|
56836
56961
|
}
|
|
56837
56962
|
|
|
@@ -57059,16 +57184,16 @@ function flattenSelections({
|
|
|
57059
57184
|
filepath,
|
|
57060
57185
|
selections,
|
|
57061
57186
|
fragmentDefinitions,
|
|
57062
|
-
|
|
57063
|
-
|
|
57187
|
+
ignoreMaskDisable,
|
|
57188
|
+
keepFragmentSpreadNodes
|
|
57064
57189
|
}) {
|
|
57065
57190
|
const fields = new FieldCollection({
|
|
57066
57191
|
config: config2,
|
|
57067
57192
|
filepath,
|
|
57068
57193
|
selections,
|
|
57069
57194
|
fragmentDefinitions,
|
|
57070
|
-
|
|
57071
|
-
|
|
57195
|
+
ignoreMaskDisable: !!ignoreMaskDisable,
|
|
57196
|
+
keepFragmentSpreadNodes: !!keepFragmentSpreadNodes
|
|
57072
57197
|
});
|
|
57073
57198
|
return fields.toSelectionSet();
|
|
57074
57199
|
}
|
|
@@ -57079,57 +57204,60 @@ var FieldCollection = class {
|
|
|
57079
57204
|
fields;
|
|
57080
57205
|
inlineFragments;
|
|
57081
57206
|
fragmentSpreads;
|
|
57082
|
-
applyFragments;
|
|
57083
57207
|
ignoreMaskDisable;
|
|
57208
|
+
keepFragmentSpreadNodes;
|
|
57084
57209
|
constructor(args) {
|
|
57085
57210
|
this.config = args.config;
|
|
57086
57211
|
this.fragmentDefinitions = args.fragmentDefinitions;
|
|
57087
|
-
this.applyFragments = args.applyFragments;
|
|
57088
57212
|
this.ignoreMaskDisable = args.ignoreMaskDisable;
|
|
57213
|
+
this.keepFragmentSpreadNodes = args.keepFragmentSpreadNodes;
|
|
57089
57214
|
this.fields = {};
|
|
57090
57215
|
this.inlineFragments = {};
|
|
57091
57216
|
this.fragmentSpreads = {};
|
|
57092
57217
|
this.filepath = args.filepath;
|
|
57093
|
-
for (const
|
|
57094
|
-
this.add(
|
|
57218
|
+
for (const selection of args.selections) {
|
|
57219
|
+
this.add(selection);
|
|
57095
57220
|
}
|
|
57096
57221
|
}
|
|
57097
57222
|
get size() {
|
|
57098
57223
|
return Object.keys(this.fields).length + Object.keys(this.inlineFragments).length + Object.keys(this.fragmentSpreads).length;
|
|
57099
57224
|
}
|
|
57100
|
-
add(
|
|
57101
|
-
if (
|
|
57102
|
-
const key =
|
|
57225
|
+
add(selection) {
|
|
57226
|
+
if (selection.kind === "Field") {
|
|
57227
|
+
const key = selection.alias?.value || selection.name.value;
|
|
57103
57228
|
if (!this.fields[key]) {
|
|
57104
57229
|
this.fields[key] = {
|
|
57105
|
-
astNode:
|
|
57230
|
+
astNode: selection,
|
|
57106
57231
|
selection: this.empty()
|
|
57107
57232
|
};
|
|
57108
57233
|
}
|
|
57109
|
-
for (const subselect of
|
|
57234
|
+
for (const subselect of selection.selectionSet?.selections || []) {
|
|
57110
57235
|
this.fields[key].selection.add(subselect);
|
|
57111
57236
|
}
|
|
57237
|
+
this.fields[key].selection.fragmentSpreads = {
|
|
57238
|
+
...this.collectFragmentSpreads(selection.selectionSet?.selections ?? []),
|
|
57239
|
+
...this.fields[key].selection.fragmentSpreads
|
|
57240
|
+
};
|
|
57112
57241
|
return;
|
|
57113
57242
|
}
|
|
57114
|
-
if (
|
|
57115
|
-
for (const subselect of
|
|
57243
|
+
if (selection.kind === "InlineFragment" && !selection.typeCondition) {
|
|
57244
|
+
for (const subselect of selection.selectionSet.selections) {
|
|
57116
57245
|
this.add(subselect);
|
|
57117
57246
|
}
|
|
57118
57247
|
}
|
|
57119
|
-
if (
|
|
57120
|
-
this.walkInlineFragment(
|
|
57248
|
+
if (selection.kind === "InlineFragment" && selection.typeCondition) {
|
|
57249
|
+
this.walkInlineFragment(selection);
|
|
57121
57250
|
return;
|
|
57122
57251
|
}
|
|
57123
|
-
if (
|
|
57124
|
-
this.fragmentSpreads[selection2.name.value] = selection2;
|
|
57252
|
+
if (selection.kind === "FragmentSpread") {
|
|
57125
57253
|
let includeFragments = this.config.defaultFragmentMasking === "disable";
|
|
57126
|
-
const maskEnableDirective =
|
|
57254
|
+
const maskEnableDirective = selection.directives?.find(
|
|
57127
57255
|
({ name }) => name.value === this.config.maskEnableDirective
|
|
57128
57256
|
);
|
|
57129
57257
|
if (maskEnableDirective) {
|
|
57130
57258
|
includeFragments = false;
|
|
57131
57259
|
}
|
|
57132
|
-
const maskDisableDirective =
|
|
57260
|
+
const maskDisableDirective = selection.directives?.find(
|
|
57133
57261
|
({ name }) => name.value === this.config.maskDisableDirective
|
|
57134
57262
|
);
|
|
57135
57263
|
if (maskDisableDirective) {
|
|
@@ -57138,14 +57266,17 @@ var FieldCollection = class {
|
|
|
57138
57266
|
if (this.ignoreMaskDisable) {
|
|
57139
57267
|
includeFragments = true;
|
|
57140
57268
|
}
|
|
57141
|
-
if (
|
|
57269
|
+
if (this.keepFragmentSpreadNodes) {
|
|
57270
|
+
this.fragmentSpreads[selection.name.value] = selection;
|
|
57271
|
+
}
|
|
57272
|
+
if (!includeFragments) {
|
|
57142
57273
|
return;
|
|
57143
57274
|
}
|
|
57144
|
-
const definition = this.fragmentDefinitions[
|
|
57275
|
+
const definition = this.fragmentDefinitions[selection.name.value];
|
|
57145
57276
|
if (!definition) {
|
|
57146
57277
|
throw new HoudiniError({
|
|
57147
57278
|
filepath: this.filepath,
|
|
57148
|
-
message: "Could not find referenced fragment definition: " +
|
|
57279
|
+
message: "Could not find referenced fragment definition: " + selection.name.value + "\n" + JSON.stringify(Object.keys(this.fragmentDefinitions), null, 4)
|
|
57149
57280
|
});
|
|
57150
57281
|
}
|
|
57151
57282
|
this.add({
|
|
@@ -57164,37 +57295,67 @@ var FieldCollection = class {
|
|
|
57164
57295
|
});
|
|
57165
57296
|
}
|
|
57166
57297
|
}
|
|
57298
|
+
collectFragmentSpreads(selections, result = {}) {
|
|
57299
|
+
for (const selection of selections) {
|
|
57300
|
+
if (selection.kind === "Field") {
|
|
57301
|
+
continue;
|
|
57302
|
+
}
|
|
57303
|
+
if (selection.kind === "InlineFragment") {
|
|
57304
|
+
this.collectFragmentSpreads(selection.selectionSet.selections, result);
|
|
57305
|
+
continue;
|
|
57306
|
+
}
|
|
57307
|
+
if (selection.kind === "FragmentSpread") {
|
|
57308
|
+
result[selection.name.value] = selection;
|
|
57309
|
+
continue;
|
|
57310
|
+
}
|
|
57311
|
+
}
|
|
57312
|
+
return result;
|
|
57313
|
+
}
|
|
57167
57314
|
toSelectionSet() {
|
|
57168
|
-
return Object.values(this.inlineFragments).flatMap((
|
|
57169
|
-
if (
|
|
57315
|
+
return Object.values(this.inlineFragments).flatMap((fragment2) => {
|
|
57316
|
+
if (fragment2.selection.size === 0) {
|
|
57170
57317
|
return [];
|
|
57171
57318
|
}
|
|
57172
|
-
|
|
57173
|
-
...
|
|
57319
|
+
fragment2.astNode = {
|
|
57320
|
+
...fragment2.astNode,
|
|
57174
57321
|
selectionSet: {
|
|
57175
|
-
...
|
|
57176
|
-
selections:
|
|
57322
|
+
...fragment2.astNode.selectionSet,
|
|
57323
|
+
selections: fragment2.selection.toSelectionSet()
|
|
57177
57324
|
}
|
|
57178
57325
|
};
|
|
57179
|
-
return [
|
|
57326
|
+
return [fragment2.astNode];
|
|
57180
57327
|
}).concat(
|
|
57181
57328
|
Object.values(this.fields).map((field) => {
|
|
57182
|
-
|
|
57183
|
-
field.astNode
|
|
57184
|
-
|
|
57185
|
-
|
|
57329
|
+
return {
|
|
57330
|
+
...field.astNode,
|
|
57331
|
+
selectionSet: field.astNode.selectionSet ? {
|
|
57332
|
+
kind: "SelectionSet",
|
|
57333
|
+
selections: field.selection.toSelectionSet()
|
|
57334
|
+
} : void 0
|
|
57335
|
+
};
|
|
57336
|
+
})
|
|
57337
|
+
).concat(
|
|
57338
|
+
Object.values(this.fragmentSpreads).map((spread) => {
|
|
57339
|
+
return {
|
|
57340
|
+
kind: "FragmentSpread",
|
|
57341
|
+
name: {
|
|
57342
|
+
kind: "Name",
|
|
57343
|
+
value: spread.name.value
|
|
57344
|
+
},
|
|
57345
|
+
directives: spread.directives
|
|
57346
|
+
};
|
|
57186
57347
|
})
|
|
57187
|
-
)
|
|
57348
|
+
);
|
|
57188
57349
|
}
|
|
57189
|
-
walkInlineFragment(
|
|
57190
|
-
const key =
|
|
57350
|
+
walkInlineFragment(selection) {
|
|
57351
|
+
const key = selection.typeCondition.name.value;
|
|
57191
57352
|
if (!this.inlineFragments[key]) {
|
|
57192
57353
|
this.inlineFragments[key] = {
|
|
57193
|
-
astNode:
|
|
57354
|
+
astNode: selection,
|
|
57194
57355
|
selection: this.empty()
|
|
57195
57356
|
};
|
|
57196
57357
|
}
|
|
57197
|
-
for (const subselect of
|
|
57358
|
+
for (const subselect of selection.selectionSet.selections || []) {
|
|
57198
57359
|
if (subselect.kind !== "InlineFragment" || !subselect.typeCondition) {
|
|
57199
57360
|
this.inlineFragments[key].selection.add(subselect);
|
|
57200
57361
|
continue;
|
|
@@ -57208,8 +57369,8 @@ var FieldCollection = class {
|
|
|
57208
57369
|
fragmentDefinitions: this.fragmentDefinitions,
|
|
57209
57370
|
selections: [],
|
|
57210
57371
|
filepath: this.filepath,
|
|
57211
|
-
|
|
57212
|
-
|
|
57372
|
+
ignoreMaskDisable: this.ignoreMaskDisable,
|
|
57373
|
+
keepFragmentSpreadNodes: this.keepFragmentSpreadNodes
|
|
57213
57374
|
});
|
|
57214
57375
|
}
|
|
57215
57376
|
};
|
|
@@ -57287,13 +57448,13 @@ function murmurHash(str) {
|
|
|
57287
57448
|
// src/codegen/transforms/fragmentVariables.ts
|
|
57288
57449
|
var graphql4 = __toESM(require_graphql2(), 1);
|
|
57289
57450
|
|
|
57290
|
-
// src/codegen/transforms/
|
|
57451
|
+
// src/codegen/transforms/collectDefinitions.ts
|
|
57291
57452
|
var import_graphql = __toESM(require_graphql2(), 1);
|
|
57292
57453
|
async function includeFragmentDefinitions(config2, documents) {
|
|
57293
|
-
const fragments =
|
|
57454
|
+
const fragments = collectDefinitions(config2, documents);
|
|
57294
57455
|
for (const [index, { name, document, filename }] of documents.entries()) {
|
|
57295
57456
|
const operation = document.definitions.find(
|
|
57296
|
-
(
|
|
57457
|
+
(def) => def.kind === import_graphql.Kind.OPERATION_DEFINITION || def.kind === "FragmentDefinition"
|
|
57297
57458
|
);
|
|
57298
57459
|
if (!operation) {
|
|
57299
57460
|
continue;
|
|
@@ -57312,7 +57473,7 @@ async function includeFragmentDefinitions(config2, documents) {
|
|
|
57312
57473
|
};
|
|
57313
57474
|
}
|
|
57314
57475
|
}
|
|
57315
|
-
function
|
|
57476
|
+
function collectDefinitions(config2, docs) {
|
|
57316
57477
|
return docs.reduce((acc, doc) => {
|
|
57317
57478
|
const definitions = doc.document.definitions.reduce(
|
|
57318
57479
|
(prev, definition) => definition.kind !== "FragmentDefinition" ? prev : {
|
|
@@ -57336,11 +57497,11 @@ function findRequiredFragments(selectionSet) {
|
|
|
57336
57497
|
return [];
|
|
57337
57498
|
}
|
|
57338
57499
|
const referencedFragments = [];
|
|
57339
|
-
for (const
|
|
57340
|
-
if (
|
|
57341
|
-
referencedFragments.push(
|
|
57342
|
-
} else if (
|
|
57343
|
-
referencedFragments.push(...findRequiredFragments(
|
|
57500
|
+
for (const selection of selectionSet.selections) {
|
|
57501
|
+
if (selection.kind === import_graphql.Kind.FRAGMENT_SPREAD) {
|
|
57502
|
+
referencedFragments.push(selection.name.value);
|
|
57503
|
+
} else if (selection.selectionSet) {
|
|
57504
|
+
referencedFragments.push(...findRequiredFragments(selection.selectionSet));
|
|
57344
57505
|
}
|
|
57345
57506
|
}
|
|
57346
57507
|
return referencedFragments;
|
|
@@ -57373,7 +57534,7 @@ function flattenFragments(filepath, operation, fragments) {
|
|
|
57373
57534
|
// src/codegen/transforms/fragmentVariables.ts
|
|
57374
57535
|
var GraphqlKinds2 = graphql4.Kind;
|
|
57375
57536
|
async function fragmentVariables(config2, documents) {
|
|
57376
|
-
const fragments =
|
|
57537
|
+
const fragments = collectDefinitions(config2, documents);
|
|
57377
57538
|
const generatedFragments = {};
|
|
57378
57539
|
const visitedFragments = /* @__PURE__ */ new Set();
|
|
57379
57540
|
for (const doc2 of documents) {
|
|
@@ -57433,9 +57594,17 @@ function inlineFragmentArgs({
|
|
|
57433
57594
|
).reduce((acc, arg) => ({ ...acc, [arg.name]: arg }), {});
|
|
57434
57595
|
const result = graphql4.visit(document, {
|
|
57435
57596
|
FragmentSpread(node) {
|
|
57597
|
+
if (!fragmentDefinitions[node.name.value]) {
|
|
57598
|
+
throw new Error("Could not find definition for fragment" + node.name.value);
|
|
57599
|
+
}
|
|
57436
57600
|
const { definition } = fragmentDefinitions[node.name.value];
|
|
57437
57601
|
let { args, hash } = collectWithArguments(config2, filepath, node, scope);
|
|
57438
57602
|
const newFragmentName = `${node.name.value}${hash}`;
|
|
57603
|
+
config2.registerFragmentVariablesHash({
|
|
57604
|
+
hash: newFragmentName,
|
|
57605
|
+
fragment: node.name.value,
|
|
57606
|
+
args
|
|
57607
|
+
});
|
|
57439
57608
|
if (!visitedFragments.has(newFragmentName)) {
|
|
57440
57609
|
visitedFragments.add(newFragmentName);
|
|
57441
57610
|
const defaultArguments = collectDefaultArgumentValues(config2, filepath, definition);
|
|
@@ -57834,7 +58003,7 @@ function operationObject({
|
|
|
57834
58003
|
listName,
|
|
57835
58004
|
operationKind,
|
|
57836
58005
|
type,
|
|
57837
|
-
selection
|
|
58006
|
+
selection,
|
|
57838
58007
|
filepath
|
|
57839
58008
|
}) {
|
|
57840
58009
|
let parentID;
|
|
@@ -57842,7 +58011,7 @@ function operationObject({
|
|
|
57842
58011
|
let position = config2.internalListPosition;
|
|
57843
58012
|
let allLists = config2.defaultListTarget ?? void 0;
|
|
57844
58013
|
let operationWhen;
|
|
57845
|
-
const internalDirectives =
|
|
58014
|
+
const internalDirectives = selection.directives?.filter(
|
|
57846
58015
|
(directive) => config2.isInternalDirective(directive.name.value)
|
|
57847
58016
|
);
|
|
57848
58017
|
if (internalDirectives && internalDirectives.length > 0) {
|
|
@@ -58078,7 +58247,7 @@ async function paginate(config2, documents) {
|
|
|
58078
58247
|
let fragmentName = "";
|
|
58079
58248
|
let refetchQueryName = "";
|
|
58080
58249
|
let nodeQuery = false;
|
|
58081
|
-
let
|
|
58250
|
+
let fragment2 = "";
|
|
58082
58251
|
let paginateMode = config2.defaultPaginateMode;
|
|
58083
58252
|
doc.document = graphql9.visit(doc.document, {
|
|
58084
58253
|
OperationDefinition(node) {
|
|
@@ -58121,7 +58290,7 @@ async function paginate(config2, documents) {
|
|
|
58121
58290
|
};
|
|
58122
58291
|
},
|
|
58123
58292
|
FragmentDefinition(node) {
|
|
58124
|
-
|
|
58293
|
+
fragment2 = node.typeCondition.name.value;
|
|
58125
58294
|
fragmentName = node.name.value;
|
|
58126
58295
|
refetchQueryName = config2.paginationQueryName(fragmentName);
|
|
58127
58296
|
nodeQuery = node.typeCondition.name.value !== config2.schema.getQueryType()?.name;
|
|
@@ -58168,17 +58337,17 @@ async function paginate(config2, documents) {
|
|
|
58168
58337
|
}
|
|
58169
58338
|
});
|
|
58170
58339
|
let targetType = config2.schema.getQueryType()?.name || "";
|
|
58171
|
-
if (
|
|
58340
|
+
if (fragment2) {
|
|
58172
58341
|
const nodeInterface = config2.schema.getType("Node");
|
|
58173
58342
|
if (nodeInterface) {
|
|
58174
58343
|
const { objects, interfaces } = config2.schema.getImplementations(nodeInterface);
|
|
58175
|
-
if (objects.find((obj) => obj.name ===
|
|
58344
|
+
if (objects.find((obj) => obj.name === fragment2) || interfaces.find((int) => int.name === fragment2)) {
|
|
58176
58345
|
targetType = "Node";
|
|
58177
58346
|
} else {
|
|
58178
|
-
targetType =
|
|
58347
|
+
targetType = fragment2;
|
|
58179
58348
|
}
|
|
58180
58349
|
} else {
|
|
58181
|
-
targetType =
|
|
58350
|
+
targetType = fragment2;
|
|
58182
58351
|
}
|
|
58183
58352
|
}
|
|
58184
58353
|
const pageSize = flags.first.defaultValue ?? flags.last.defaultValue ?? flags.limit.defaultValue;
|
|
@@ -58200,7 +58369,7 @@ async function paginate(config2, documents) {
|
|
|
58200
58369
|
start,
|
|
58201
58370
|
mode: paginateMode
|
|
58202
58371
|
};
|
|
58203
|
-
if (!
|
|
58372
|
+
if (!fragment2) {
|
|
58204
58373
|
continue;
|
|
58205
58374
|
}
|
|
58206
58375
|
const paginationArgs = Object.entries(flags).filter(([_, { enabled }]) => enabled).map(([key, value]) => ({ name: key, ...value }));
|
|
@@ -58221,15 +58390,22 @@ async function paginate(config2, documents) {
|
|
|
58221
58390
|
["arguments"]: paginationArgs.map(
|
|
58222
58391
|
({ name }) => variableAsArgument(name)
|
|
58223
58392
|
)
|
|
58393
|
+
},
|
|
58394
|
+
{
|
|
58395
|
+
kind: graphql9.Kind.DIRECTIVE,
|
|
58396
|
+
name: {
|
|
58397
|
+
kind: "Name",
|
|
58398
|
+
value: config2.maskDisableDirective
|
|
58399
|
+
}
|
|
58224
58400
|
}
|
|
58225
58401
|
]
|
|
58226
58402
|
}
|
|
58227
58403
|
];
|
|
58228
|
-
const keys = config2.keyFieldsForType(!nodeQuery ? config2.schema.getQueryType()?.name || "" :
|
|
58229
|
-
if (
|
|
58404
|
+
const keys = config2.keyFieldsForType(!nodeQuery ? config2.schema.getQueryType()?.name || "" : fragment2).flatMap((key) => {
|
|
58405
|
+
if (fragment2 === config2.schema.getQueryType()?.name) {
|
|
58230
58406
|
return [];
|
|
58231
58407
|
}
|
|
58232
|
-
const fragmentType = config2.schema.getType(
|
|
58408
|
+
const fragmentType = config2.schema.getType(fragment2);
|
|
58233
58409
|
const { type, wrappers } = unwrapType(
|
|
58234
58410
|
config2,
|
|
58235
58411
|
fragmentType.getFields()[key].type
|
|
@@ -58241,7 +58417,7 @@ async function paginate(config2, documents) {
|
|
|
58241
58417
|
}
|
|
58242
58418
|
];
|
|
58243
58419
|
});
|
|
58244
|
-
const typeConfig = config2.typeConfig?.[
|
|
58420
|
+
const typeConfig = config2.typeConfig?.[fragment2];
|
|
58245
58421
|
const queryDoc = {
|
|
58246
58422
|
kind: graphql9.Kind.DOCUMENT,
|
|
58247
58423
|
definitions: [
|
|
@@ -58583,7 +58759,7 @@ async function addListFragments(config2, documents) {
|
|
|
58583
58759
|
);
|
|
58584
58760
|
const targetField = ancestors[ancestors.length - 1];
|
|
58585
58761
|
const targetFieldDefinition = parentType.getFields()[targetField.name.value];
|
|
58586
|
-
const { selection
|
|
58762
|
+
const { selection, type, connection } = connectionSelection(
|
|
58587
58763
|
config2,
|
|
58588
58764
|
targetFieldDefinition,
|
|
58589
58765
|
parentTypeFromAncestors(
|
|
@@ -58594,7 +58770,7 @@ async function addListFragments(config2, documents) {
|
|
|
58594
58770
|
ancestors[ancestors.length - 1].selectionSet
|
|
58595
58771
|
);
|
|
58596
58772
|
lists[nameArg.value.value] = {
|
|
58597
|
-
selection
|
|
58773
|
+
selection,
|
|
58598
58774
|
type,
|
|
58599
58775
|
filename: doc.filename
|
|
58600
58776
|
};
|
|
@@ -58672,14 +58848,14 @@ async function addListFragments(config2, documents) {
|
|
|
58672
58848
|
const generatedDoc = {
|
|
58673
58849
|
kind: graphql10.Kind.DOCUMENT,
|
|
58674
58850
|
definitions: Object.entries(lists).flatMap(
|
|
58675
|
-
([name, { selection
|
|
58851
|
+
([name, { selection, type }]) => {
|
|
58676
58852
|
const schemaType = config2.schema.getType(type.name);
|
|
58677
|
-
if (!
|
|
58853
|
+
if (!selection) {
|
|
58678
58854
|
throw new HoudiniError({ message: "Lists must have a selection" });
|
|
58679
58855
|
}
|
|
58680
58856
|
const fragmentSelection = {
|
|
58681
58857
|
kind: graphql10.Kind.SELECTION_SET,
|
|
58682
|
-
selections: [...
|
|
58858
|
+
selections: [...selection.selections]
|
|
58683
58859
|
};
|
|
58684
58860
|
if (schemaType && fragmentSelection && !fragmentSelection?.selections.find(
|
|
58685
58861
|
(field) => field.kind === "Field" && config2.keyFieldsForType(type.name).includes(field.name.value)
|
|
@@ -58771,7 +58947,7 @@ async function addListFragments(config2, documents) {
|
|
|
58771
58947
|
artifact: null
|
|
58772
58948
|
});
|
|
58773
58949
|
}
|
|
58774
|
-
function connectionSelection(config2, field, type,
|
|
58950
|
+
function connectionSelection(config2, field, type, selection) {
|
|
58775
58951
|
const fieldArgs = field.args.reduce(
|
|
58776
58952
|
(args, arg) => ({
|
|
58777
58953
|
...args,
|
|
@@ -58780,34 +58956,34 @@ function connectionSelection(config2, field, type, selection2) {
|
|
|
58780
58956
|
{}
|
|
58781
58957
|
);
|
|
58782
58958
|
if (fieldArgs["limit"]) {
|
|
58783
|
-
return { selection
|
|
58959
|
+
return { selection, type, connection: false, error: null };
|
|
58784
58960
|
}
|
|
58785
58961
|
const forwardPagination = fieldArgs["first"] === "Int" && ["Cursor", "String"].includes(fieldArgs["after"]);
|
|
58786
58962
|
const backwardsPagination = fieldArgs["last"] === "Int" && ["Cursor", "String"].includes(fieldArgs["before"]);
|
|
58787
58963
|
if (!forwardPagination && !backwardsPagination) {
|
|
58788
|
-
return { selection
|
|
58964
|
+
return { selection, type, connection: false, error: missingPaginationArgMessage(config2) };
|
|
58789
58965
|
}
|
|
58790
|
-
const edgesField =
|
|
58791
|
-
(
|
|
58966
|
+
const edgesField = selection?.selections.find(
|
|
58967
|
+
(selection2) => selection2.kind === "Field" && selection2.name.value === "edges"
|
|
58792
58968
|
);
|
|
58793
58969
|
if (!edgesField) {
|
|
58794
|
-
return { selection
|
|
58970
|
+
return { selection, type, connection: false, error: missingEdgeSelectionMessage(config2) };
|
|
58795
58971
|
}
|
|
58796
58972
|
const nodeSelection = edgesField.selectionSet?.selections.find(
|
|
58797
|
-
(
|
|
58973
|
+
(selection2) => selection2.kind === "Field" && selection2.name.value === "node"
|
|
58798
58974
|
);
|
|
58799
58975
|
if (!nodeSelection.selectionSet) {
|
|
58800
|
-
return { selection
|
|
58976
|
+
return { selection, type, connection: false, error: missingNodeSelectionMessage(config2) };
|
|
58801
58977
|
}
|
|
58802
58978
|
const edgeField = unwrapType(config2, field.type).type.getFields()["edges"];
|
|
58803
58979
|
const { wrappers, type: edgeFieldType } = unwrapType(config2, edgeField.type);
|
|
58804
58980
|
const list = wrappers[wrappers.length - 2] === "List" /* List */;
|
|
58805
58981
|
if (!list) {
|
|
58806
|
-
return { selection
|
|
58982
|
+
return { selection, type, connection: false, error: edgeInvalidTypeMessage(config2) };
|
|
58807
58983
|
}
|
|
58808
58984
|
const nodeField = edgeFieldType.getFields()["node"];
|
|
58809
58985
|
if (!nodeField) {
|
|
58810
|
-
return { selection
|
|
58986
|
+
return { selection, type, connection: false, error: nodeNotDefinedMessage(config2) };
|
|
58811
58987
|
}
|
|
58812
58988
|
return {
|
|
58813
58989
|
selection: nodeSelection.selectionSet,
|
|
@@ -58886,59 +59062,45 @@ function fieldKey(config2, field) {
|
|
|
58886
59062
|
}
|
|
58887
59063
|
|
|
58888
59064
|
// src/codegen/generators/artifacts/selection.ts
|
|
58889
|
-
function
|
|
59065
|
+
function selection_default(args) {
|
|
59066
|
+
const typeMap = {};
|
|
59067
|
+
const abstractTypes = [];
|
|
59068
|
+
return mergeSelection({
|
|
59069
|
+
object: prepareSelection({ ...args, typeMap, abstractTypes }),
|
|
59070
|
+
filepath: args.filepath,
|
|
59071
|
+
typeMap,
|
|
59072
|
+
abstractTypes
|
|
59073
|
+
});
|
|
59074
|
+
}
|
|
59075
|
+
function prepareSelection({
|
|
58890
59076
|
config: config2,
|
|
58891
59077
|
filepath,
|
|
58892
59078
|
rootType,
|
|
58893
59079
|
selections,
|
|
58894
59080
|
operations,
|
|
58895
59081
|
path: path2 = [],
|
|
58896
|
-
includeFragments,
|
|
58897
59082
|
document,
|
|
58898
|
-
inConnection
|
|
59083
|
+
inConnection,
|
|
59084
|
+
typeMap,
|
|
59085
|
+
abstractTypes
|
|
58899
59086
|
}) {
|
|
58900
59087
|
let object = {};
|
|
58901
|
-
const typeMap = {};
|
|
58902
|
-
const abstractTypes = [];
|
|
58903
59088
|
for (const field of selections) {
|
|
58904
|
-
if (field.kind === "
|
|
58905
|
-
const fragmentDefinition = document.document.definitions.find(
|
|
58906
|
-
(defn) => defn.kind === "FragmentDefinition" && defn.name.value === field.name.value
|
|
58907
|
-
);
|
|
58908
|
-
if (!fragmentDefinition) {
|
|
58909
|
-
throw new HoudiniError({
|
|
58910
|
-
filepath,
|
|
58911
|
-
message: "selection: could not find definition for fragment " + field.name.value
|
|
58912
|
-
});
|
|
58913
|
-
}
|
|
58914
|
-
object = deepMerge(
|
|
58915
|
-
filepath,
|
|
58916
|
-
object,
|
|
58917
|
-
selection({
|
|
58918
|
-
config: config2,
|
|
58919
|
-
filepath,
|
|
58920
|
-
rootType: fragmentDefinition.typeCondition.name.value,
|
|
58921
|
-
operations,
|
|
58922
|
-
selections: fragmentDefinition.selectionSet.selections,
|
|
58923
|
-
path: path2,
|
|
58924
|
-
includeFragments,
|
|
58925
|
-
document
|
|
58926
|
-
})
|
|
58927
|
-
);
|
|
58928
|
-
} else if (field.kind === "InlineFragment") {
|
|
59089
|
+
if (field.kind === "InlineFragment") {
|
|
58929
59090
|
if (!field.typeCondition || field.typeCondition.name.value === rootType) {
|
|
58930
59091
|
object.fields = deepMerge(
|
|
58931
59092
|
filepath,
|
|
58932
59093
|
object.fields || {},
|
|
58933
|
-
|
|
59094
|
+
prepareSelection({
|
|
58934
59095
|
config: config2,
|
|
58935
59096
|
filepath,
|
|
58936
59097
|
rootType: field.typeCondition?.name.value || rootType,
|
|
58937
59098
|
operations,
|
|
58938
59099
|
selections: field.selectionSet.selections,
|
|
58939
59100
|
path: path2,
|
|
58940
|
-
|
|
58941
|
-
|
|
59101
|
+
document,
|
|
59102
|
+
typeMap,
|
|
59103
|
+
abstractTypes
|
|
58942
59104
|
}).fields || {}
|
|
58943
59105
|
);
|
|
58944
59106
|
} else {
|
|
@@ -58976,15 +59138,16 @@ function selection({
|
|
|
58976
59138
|
}
|
|
58977
59139
|
object.abstractFields.fields = {
|
|
58978
59140
|
...object.abstractFields.fields,
|
|
58979
|
-
[field.typeCondition.name.value]:
|
|
59141
|
+
[field.typeCondition.name.value]: prepareSelection({
|
|
58980
59142
|
config: config2,
|
|
58981
59143
|
filepath,
|
|
58982
59144
|
rootType: field.typeCondition?.name.value || rootType,
|
|
58983
59145
|
operations,
|
|
58984
59146
|
selections: field.selectionSet.selections,
|
|
58985
59147
|
path: path2,
|
|
58986
|
-
|
|
58987
|
-
|
|
59148
|
+
document,
|
|
59149
|
+
typeMap,
|
|
59150
|
+
abstractTypes
|
|
58988
59151
|
}).fields
|
|
58989
59152
|
};
|
|
58990
59153
|
}
|
|
@@ -59005,10 +59168,14 @@ function selection({
|
|
|
59005
59168
|
}
|
|
59006
59169
|
const typeName = fieldType.toString();
|
|
59007
59170
|
const pathSoFar = path2.concat(attributeName);
|
|
59008
|
-
const
|
|
59171
|
+
const keys = config2.keyFieldsForType(rootType);
|
|
59172
|
+
let fieldObj = {
|
|
59009
59173
|
type: typeName,
|
|
59010
59174
|
keyRaw: fieldKey(config2, field)
|
|
59011
59175
|
};
|
|
59176
|
+
if (keys.includes(field.name.value)) {
|
|
59177
|
+
fieldObj.visible = true;
|
|
59178
|
+
}
|
|
59012
59179
|
if (nullable) {
|
|
59013
59180
|
fieldObj.nullable = true;
|
|
59014
59181
|
}
|
|
@@ -59056,16 +59223,17 @@ function selection({
|
|
|
59056
59223
|
}
|
|
59057
59224
|
if (field.selectionSet) {
|
|
59058
59225
|
const connectionState = paginated && document.refetch?.method === "cursor" || continueConnection;
|
|
59059
|
-
fieldObj.selection =
|
|
59226
|
+
fieldObj.selection = prepareSelection({
|
|
59060
59227
|
config: config2,
|
|
59061
59228
|
filepath,
|
|
59062
59229
|
rootType: typeName,
|
|
59063
59230
|
selections: field.selectionSet.selections,
|
|
59064
59231
|
operations,
|
|
59065
59232
|
path: pathSoFar,
|
|
59066
|
-
includeFragments,
|
|
59067
59233
|
document,
|
|
59068
|
-
inConnection: connectionState
|
|
59234
|
+
inConnection: connectionState,
|
|
59235
|
+
typeMap,
|
|
59236
|
+
abstractTypes
|
|
59069
59237
|
});
|
|
59070
59238
|
}
|
|
59071
59239
|
if (field.arguments?.length && fieldObj.list) {
|
|
@@ -59080,12 +59248,29 @@ function selection({
|
|
|
59080
59248
|
if (graphql12.isInterfaceType(fieldType) || graphql12.isUnionType(fieldType)) {
|
|
59081
59249
|
fieldObj.abstract = true;
|
|
59082
59250
|
}
|
|
59251
|
+
if (object.fields?.[attributeName]) {
|
|
59252
|
+
fieldObj = deepMerge(filepath, object.fields[attributeName], fieldObj);
|
|
59253
|
+
}
|
|
59083
59254
|
object.fields = {
|
|
59084
59255
|
...object.fields,
|
|
59085
59256
|
[attributeName]: fieldObj
|
|
59086
59257
|
};
|
|
59258
|
+
} else if (field.kind === "FragmentSpread") {
|
|
59259
|
+
const { fragment: fragment2, args } = config2.getFragmentVariablesHash(field.name.value);
|
|
59260
|
+
object.fragments = {
|
|
59261
|
+
...object.fragments,
|
|
59262
|
+
[fragment2]: args ?? {}
|
|
59263
|
+
};
|
|
59087
59264
|
}
|
|
59088
59265
|
}
|
|
59266
|
+
return object;
|
|
59267
|
+
}
|
|
59268
|
+
function mergeSelection({
|
|
59269
|
+
filepath,
|
|
59270
|
+
object,
|
|
59271
|
+
typeMap,
|
|
59272
|
+
abstractTypes
|
|
59273
|
+
}) {
|
|
59089
59274
|
if (Object.keys(object.fields || {}).length > 0 && object.abstractFields && Object.keys(object.abstractFields.fields).length > 0) {
|
|
59090
59275
|
for (const [typeName, possibles] of Object.entries(typeMap)) {
|
|
59091
59276
|
let overlap = false;
|
|
@@ -59093,8 +59278,8 @@ function selection({
|
|
|
59093
59278
|
if (object.abstractFields.fields[typeName]) {
|
|
59094
59279
|
object.abstractFields.fields[typeName] = deepMerge(
|
|
59095
59280
|
filepath,
|
|
59096
|
-
object.abstractFields.fields[typeName]
|
|
59097
|
-
object.abstractFields.fields[possible]
|
|
59281
|
+
object.abstractFields.fields[typeName] ?? {},
|
|
59282
|
+
object.abstractFields.fields[possible] ?? {}
|
|
59098
59283
|
);
|
|
59099
59284
|
overlap = true;
|
|
59100
59285
|
}
|
|
@@ -59125,6 +59310,30 @@ function selection({
|
|
|
59125
59310
|
}
|
|
59126
59311
|
}
|
|
59127
59312
|
}
|
|
59313
|
+
for (const [key, value] of Object.entries(object.fields ?? {})) {
|
|
59314
|
+
const selection = value.selection;
|
|
59315
|
+
if (selection) {
|
|
59316
|
+
mergeSelection({
|
|
59317
|
+
filepath,
|
|
59318
|
+
typeMap,
|
|
59319
|
+
abstractTypes,
|
|
59320
|
+
object: selection
|
|
59321
|
+
});
|
|
59322
|
+
}
|
|
59323
|
+
}
|
|
59324
|
+
for (const [type, selection] of Object.entries(object.abstractFields?.fields ?? {})) {
|
|
59325
|
+
for (const [key, value] of Object.entries(selection ?? {})) {
|
|
59326
|
+
const selection2 = value.selection;
|
|
59327
|
+
if (selection2) {
|
|
59328
|
+
mergeSelection({
|
|
59329
|
+
filepath,
|
|
59330
|
+
typeMap,
|
|
59331
|
+
abstractTypes,
|
|
59332
|
+
object: selection2
|
|
59333
|
+
});
|
|
59334
|
+
}
|
|
59335
|
+
}
|
|
59336
|
+
}
|
|
59128
59337
|
return object;
|
|
59129
59338
|
}
|
|
59130
59339
|
|
|
@@ -59189,7 +59398,12 @@ function artifactGenerator(stats) {
|
|
|
59189
59398
|
writeIndexFile(config2, docs)
|
|
59190
59399
|
].concat(
|
|
59191
59400
|
docs.map(async (doc) => {
|
|
59192
|
-
const {
|
|
59401
|
+
const {
|
|
59402
|
+
document,
|
|
59403
|
+
name,
|
|
59404
|
+
generateArtifact,
|
|
59405
|
+
originalParsed
|
|
59406
|
+
} = doc;
|
|
59193
59407
|
if (!generateArtifact) {
|
|
59194
59408
|
return;
|
|
59195
59409
|
}
|
|
@@ -59228,6 +59442,16 @@ function artifactGenerator(stats) {
|
|
|
59228
59442
|
);
|
|
59229
59443
|
let rootType = "";
|
|
59230
59444
|
let selectionSet;
|
|
59445
|
+
let originalSelectionSet = null;
|
|
59446
|
+
const fragmentDefinitions = doc.document.definitions.filter(
|
|
59447
|
+
(definition) => definition.kind === "FragmentDefinition"
|
|
59448
|
+
).reduce(
|
|
59449
|
+
(prev, definition) => ({
|
|
59450
|
+
...prev,
|
|
59451
|
+
[definition.name.value]: definition
|
|
59452
|
+
}),
|
|
59453
|
+
{}
|
|
59454
|
+
);
|
|
59231
59455
|
if (docKind !== ArtifactKind.Fragment) {
|
|
59232
59456
|
const operation = operations[0];
|
|
59233
59457
|
if (operation.operation === "query") {
|
|
@@ -59244,9 +59468,12 @@ function artifactGenerator(stats) {
|
|
|
59244
59468
|
});
|
|
59245
59469
|
}
|
|
59246
59470
|
selectionSet = operation.selectionSet;
|
|
59471
|
+
if (originalParsed.definitions[0].kind === "OperationDefinition") {
|
|
59472
|
+
originalSelectionSet = originalParsed.definitions[0].selectionSet;
|
|
59473
|
+
}
|
|
59247
59474
|
} else {
|
|
59248
59475
|
const matchingFragment = fragments.find(
|
|
59249
|
-
(
|
|
59476
|
+
(fragment2) => fragment2.name.value === name
|
|
59250
59477
|
);
|
|
59251
59478
|
if (!matchingFragment) {
|
|
59252
59479
|
throw new HoudiniError({
|
|
@@ -59256,6 +59483,12 @@ function artifactGenerator(stats) {
|
|
|
59256
59483
|
}
|
|
59257
59484
|
rootType = matchingFragment.typeCondition.name.value;
|
|
59258
59485
|
selectionSet = matchingFragment.selectionSet;
|
|
59486
|
+
if (originalParsed.definitions[0].kind === "FragmentDefinition") {
|
|
59487
|
+
originalSelectionSet = originalParsed.definitions[0].selectionSet;
|
|
59488
|
+
}
|
|
59489
|
+
}
|
|
59490
|
+
if (!originalSelectionSet) {
|
|
59491
|
+
throw new Error("Not original selection set!");
|
|
59259
59492
|
}
|
|
59260
59493
|
let inputs = operations[0]?.variableDefinitions;
|
|
59261
59494
|
let directive = fragments[0]?.directives?.find(
|
|
@@ -59264,21 +59497,18 @@ function artifactGenerator(stats) {
|
|
|
59264
59497
|
if (docKind === ArtifactKind.Fragment && directive) {
|
|
59265
59498
|
inputs = fragmentArgumentsDefinitions(config2, doc.filename, fragments[0]);
|
|
59266
59499
|
}
|
|
59267
|
-
const
|
|
59500
|
+
const mask = selection_default({
|
|
59268
59501
|
config: config2,
|
|
59269
59502
|
filepath: doc.filename,
|
|
59270
|
-
|
|
59271
|
-
|
|
59272
|
-
|
|
59273
|
-
|
|
59274
|
-
|
|
59275
|
-
|
|
59276
|
-
|
|
59277
|
-
|
|
59278
|
-
|
|
59279
|
-
),
|
|
59280
|
-
ignoreMaskDisable: docKind === "HoudiniQuery",
|
|
59281
|
-
applyFragments: docKind !== "HoudiniFragment"
|
|
59503
|
+
rootType,
|
|
59504
|
+
operations: {},
|
|
59505
|
+
document: doc,
|
|
59506
|
+
selections: flattenSelections({
|
|
59507
|
+
config: config2,
|
|
59508
|
+
filepath: doc.filename,
|
|
59509
|
+
selections: selectionSet.selections,
|
|
59510
|
+
fragmentDefinitions
|
|
59511
|
+
})
|
|
59282
59512
|
});
|
|
59283
59513
|
let artifact = {
|
|
59284
59514
|
name,
|
|
@@ -59287,21 +59517,29 @@ function artifactGenerator(stats) {
|
|
|
59287
59517
|
refetch: doc.refetch,
|
|
59288
59518
|
raw: rawString,
|
|
59289
59519
|
rootType,
|
|
59290
|
-
selection:
|
|
59520
|
+
selection: selection_default({
|
|
59291
59521
|
config: config2,
|
|
59292
59522
|
filepath: doc.filename,
|
|
59293
59523
|
rootType,
|
|
59294
|
-
selections:
|
|
59524
|
+
selections: flattenSelections({
|
|
59525
|
+
config: config2,
|
|
59526
|
+
filepath: doc.filename,
|
|
59527
|
+
selections: selectionSet.selections,
|
|
59528
|
+
fragmentDefinitions,
|
|
59529
|
+
ignoreMaskDisable: docKind !== "HoudiniFragment",
|
|
59530
|
+
keepFragmentSpreadNodes: true
|
|
59531
|
+
}),
|
|
59295
59532
|
operations: operationsByPath(
|
|
59296
59533
|
config2,
|
|
59297
59534
|
doc.filename,
|
|
59298
59535
|
operations[0],
|
|
59299
59536
|
filterTypes
|
|
59300
59537
|
),
|
|
59301
|
-
includeFragments: docKind !== "HoudiniFragment",
|
|
59302
59538
|
document: doc
|
|
59303
|
-
})
|
|
59539
|
+
}),
|
|
59540
|
+
pluginData: {}
|
|
59304
59541
|
};
|
|
59542
|
+
applyMask(config2, artifact.selection, mask);
|
|
59305
59543
|
artifact.pluginData = {};
|
|
59306
59544
|
for (const plugin2 of config2.plugins) {
|
|
59307
59545
|
if (!plugin2.artifactData) {
|
|
@@ -59378,6 +59616,49 @@ function artifactGenerator(stats) {
|
|
|
59378
59616
|
stats.deleted = await cleanupFiles(config2.artifactDirectory, listOfArtifacts);
|
|
59379
59617
|
};
|
|
59380
59618
|
}
|
|
59619
|
+
function applyMask(config2, target, mask) {
|
|
59620
|
+
for (const [fieldName, value] of Object.entries(mask.fields ?? {})) {
|
|
59621
|
+
const targetSelection = target.fields?.[fieldName];
|
|
59622
|
+
if (!targetSelection || !mask.fields) {
|
|
59623
|
+
continue;
|
|
59624
|
+
}
|
|
59625
|
+
targetSelection.visible = true;
|
|
59626
|
+
if (targetSelection.selection && value.selection) {
|
|
59627
|
+
applyMask(config2, targetSelection.selection, value.selection);
|
|
59628
|
+
}
|
|
59629
|
+
}
|
|
59630
|
+
for (const [type, selection] of Object.entries(mask.abstractFields?.fields ?? {})) {
|
|
59631
|
+
if (!selection) {
|
|
59632
|
+
continue;
|
|
59633
|
+
}
|
|
59634
|
+
if (target.abstractFields?.fields[type]) {
|
|
59635
|
+
applyMask(config2, { fields: target.abstractFields.fields[type] }, { fields: selection });
|
|
59636
|
+
}
|
|
59637
|
+
const targetType = config2.schema.getType(type);
|
|
59638
|
+
if (!targetType) {
|
|
59639
|
+
continue;
|
|
59640
|
+
}
|
|
59641
|
+
if (graphql13.isAbstractType(targetType)) {
|
|
59642
|
+
for (const possible of config2.schema.getPossibleTypes(targetType)) {
|
|
59643
|
+
if (target.abstractFields?.fields[possible.name]) {
|
|
59644
|
+
applyMask(
|
|
59645
|
+
config2,
|
|
59646
|
+
{ fields: target.abstractFields.fields[possible.name] },
|
|
59647
|
+
{ fields: selection }
|
|
59648
|
+
);
|
|
59649
|
+
}
|
|
59650
|
+
}
|
|
59651
|
+
}
|
|
59652
|
+
const mappedType = target.abstractFields?.typeMap[type];
|
|
59653
|
+
if (target.abstractFields && mappedType && target.abstractFields.fields[mappedType]) {
|
|
59654
|
+
applyMask(
|
|
59655
|
+
config2,
|
|
59656
|
+
{ fields: target.abstractFields.fields[mappedType] },
|
|
59657
|
+
{ fields: selection }
|
|
59658
|
+
);
|
|
59659
|
+
}
|
|
59660
|
+
}
|
|
59661
|
+
}
|
|
59381
59662
|
|
|
59382
59663
|
// src/codegen/generators/runtime/graphqlFunction.ts
|
|
59383
59664
|
var recast6 = __toESM(require_main2(), 1);
|
|
@@ -59703,7 +59984,7 @@ function addReferencedInputTypes(config2, filepath, body, visitedTypes, missingS
|
|
|
59703
59984
|
var graphql17 = __toESM(require_graphql2(), 1);
|
|
59704
59985
|
var recast10 = __toESM(require_main2(), 1);
|
|
59705
59986
|
var AST10 = recast10.types.builders;
|
|
59706
|
-
var
|
|
59987
|
+
var fragmentKey2 = " $fragments";
|
|
59707
59988
|
function inlineType({
|
|
59708
59989
|
config: config2,
|
|
59709
59990
|
filepath,
|
|
@@ -59743,24 +60024,24 @@ function inlineType({
|
|
|
59743
60024
|
const rootObj = type;
|
|
59744
60025
|
const inlineFragments = {};
|
|
59745
60026
|
const selectedFields = [];
|
|
59746
|
-
for (const
|
|
59747
|
-
if (
|
|
59748
|
-
const fragmentType = config2.schema.getType(
|
|
60027
|
+
for (const selection of selections) {
|
|
60028
|
+
if (selection.kind === "InlineFragment" && selection.typeCondition) {
|
|
60029
|
+
const fragmentType = config2.schema.getType(selection.typeCondition.name.value);
|
|
59749
60030
|
if (!graphql17.isInterfaceType(type) && !graphql17.isUnionType(type)) {
|
|
59750
|
-
selectedFields.push(...
|
|
60031
|
+
selectedFields.push(...selection.selectionSet.selections);
|
|
59751
60032
|
continue;
|
|
59752
60033
|
}
|
|
59753
60034
|
if (!graphql17.isInterfaceType(fragmentType) && !graphql17.isUnionType(fragmentType)) {
|
|
59754
60035
|
if (!inlineFragments[fragmentType.name]) {
|
|
59755
60036
|
inlineFragments[fragmentType.name] = [];
|
|
59756
60037
|
}
|
|
59757
|
-
inlineFragments[fragmentType.name].push(...
|
|
60038
|
+
inlineFragments[fragmentType.name].push(...selection.selectionSet.selections);
|
|
59758
60039
|
continue;
|
|
59759
60040
|
}
|
|
59760
60041
|
const possibleParents = config2.schema.getPossibleTypes(type).map((t) => t.name);
|
|
59761
60042
|
const freeSelections = [];
|
|
59762
60043
|
const typeSpecificSelections = {};
|
|
59763
|
-
for (const node of
|
|
60044
|
+
for (const node of selection.selectionSet.selections) {
|
|
59764
60045
|
if (node.kind !== "InlineFragment") {
|
|
59765
60046
|
freeSelections.push(node);
|
|
59766
60047
|
} else if (node.typeCondition) {
|
|
@@ -59783,23 +60064,30 @@ function inlineType({
|
|
|
59783
60064
|
);
|
|
59784
60065
|
}
|
|
59785
60066
|
}
|
|
59786
|
-
} else if (
|
|
59787
|
-
selectedFields.push(...
|
|
60067
|
+
} else if (selection.kind === "InlineFragment" && !selection.typeCondition) {
|
|
60068
|
+
selectedFields.push(...selection.selectionSet.selections);
|
|
59788
60069
|
} else {
|
|
59789
|
-
selectedFields.push(
|
|
60070
|
+
selectedFields.push(selection);
|
|
59790
60071
|
}
|
|
59791
60072
|
}
|
|
60073
|
+
const fields = Object.values(
|
|
60074
|
+
selectedFields.filter((field) => field.kind === "Field").reduce(
|
|
60075
|
+
(sel, field) => ({
|
|
60076
|
+
...sel,
|
|
60077
|
+
[field.alias?.value ?? field.name.value]: field
|
|
60078
|
+
}),
|
|
60079
|
+
{}
|
|
60080
|
+
)
|
|
60081
|
+
);
|
|
59792
60082
|
result = AST10.tsTypeLiteral([
|
|
59793
|
-
...(
|
|
59794
|
-
|
|
59795
|
-
|
|
59796
|
-
const { field } = selectionTypeInfo(config2.schema, filepath, rootObj, selection2);
|
|
59797
|
-
const attributeName = selection2.alias?.value || selection2.name.value;
|
|
60083
|
+
...fields.map((selection) => {
|
|
60084
|
+
const { field } = selectionTypeInfo(config2.schema, filepath, rootObj, selection);
|
|
60085
|
+
const attributeName = selection.alias?.value || selection.name.value;
|
|
59798
60086
|
let attributeType = inlineType({
|
|
59799
60087
|
config: config2,
|
|
59800
60088
|
filepath,
|
|
59801
60089
|
rootType: field.type,
|
|
59802
|
-
selections:
|
|
60090
|
+
selections: selection.selectionSet?.selections,
|
|
59803
60091
|
root: false,
|
|
59804
60092
|
allowReadonly,
|
|
59805
60093
|
visitedTypes,
|
|
@@ -59808,7 +60096,7 @@ function inlineType({
|
|
|
59808
60096
|
includeFragments,
|
|
59809
60097
|
allOptional
|
|
59810
60098
|
});
|
|
59811
|
-
const hasIncludeOrSkipDirective =
|
|
60099
|
+
const hasIncludeOrSkipDirective = selection.directives && selection.directives.filter(
|
|
59812
60100
|
(directive) => directive.name.value === "include" || directive.name.value === "skip"
|
|
59813
60101
|
).length > 0;
|
|
59814
60102
|
if (hasIncludeOrSkipDirective) {
|
|
@@ -59832,15 +60120,13 @@ function inlineType({
|
|
|
59832
60120
|
result.members.push(
|
|
59833
60121
|
readonlyProperty(
|
|
59834
60122
|
AST10.tsPropertySignature(
|
|
59835
|
-
AST10.
|
|
60123
|
+
AST10.stringLiteral(fragmentKey2),
|
|
59836
60124
|
AST10.tsTypeAnnotation(
|
|
59837
60125
|
AST10.tsTypeLiteral(
|
|
59838
60126
|
(fragmentSpreads || []).map(
|
|
59839
60127
|
(fragmentSpread) => AST10.tsPropertySignature(
|
|
59840
60128
|
AST10.identifier(fragmentSpread.name.value),
|
|
59841
|
-
AST10.tsTypeAnnotation(
|
|
59842
|
-
AST10.tsLiteralType(AST10.booleanLiteral(true))
|
|
59843
|
-
)
|
|
60129
|
+
AST10.tsTypeAnnotation(AST10.tsTypeLiteral([]))
|
|
59844
60130
|
)
|
|
59845
60131
|
)
|
|
59846
60132
|
)
|
|
@@ -59850,7 +60136,7 @@ function inlineType({
|
|
|
59850
60136
|
)
|
|
59851
60137
|
);
|
|
59852
60138
|
}
|
|
59853
|
-
const inlineFragmentSelections = Object.entries(inlineFragments).flatMap(([typeName,
|
|
60139
|
+
const inlineFragmentSelections = Object.entries(inlineFragments).flatMap(([typeName, fragment2]) => {
|
|
59854
60140
|
const fragmentRootType = config2.schema.getType(typeName);
|
|
59855
60141
|
if (!fragmentRootType) {
|
|
59856
60142
|
return [];
|
|
@@ -59859,7 +60145,7 @@ function inlineType({
|
|
|
59859
60145
|
config: config2,
|
|
59860
60146
|
filepath,
|
|
59861
60147
|
rootType: fragmentRootType,
|
|
59862
|
-
selections:
|
|
60148
|
+
selections: fragment2,
|
|
59863
60149
|
allowReadonly,
|
|
59864
60150
|
visitedTypes,
|
|
59865
60151
|
root,
|
|
@@ -59931,10 +60217,10 @@ function inlineType({
|
|
|
59931
60217
|
}
|
|
59932
60218
|
return result;
|
|
59933
60219
|
}
|
|
59934
|
-
function selectionTypeInfo(schema, filepath, rootType,
|
|
59935
|
-
const selectionName =
|
|
60220
|
+
function selectionTypeInfo(schema, filepath, rootType, selection) {
|
|
60221
|
+
const selectionName = selection.name.value;
|
|
59936
60222
|
let fields = {};
|
|
59937
|
-
if (
|
|
60223
|
+
if (selection.kind === "Field" && selection.name.value === "__typename") {
|
|
59938
60224
|
return {
|
|
59939
60225
|
field: {
|
|
59940
60226
|
name: "__typename",
|
|
@@ -60005,7 +60291,7 @@ async function generateDocumentTypes(config2, docs) {
|
|
|
60005
60291
|
filepath: filename,
|
|
60006
60292
|
selections: definition.selectionSet.selections,
|
|
60007
60293
|
fragmentDefinitions,
|
|
60008
|
-
|
|
60294
|
+
keepFragmentSpreadNodes: true
|
|
60009
60295
|
});
|
|
60010
60296
|
if (definition?.kind === "OperationDefinition") {
|
|
60011
60297
|
await generateOperationTypeDefs(
|
|
@@ -60229,39 +60515,26 @@ async function generateFragmentTypeDefs(config2, filepath, body, selections, def
|
|
|
60229
60515
|
if (!type) {
|
|
60230
60516
|
throw new Error("Should not get here");
|
|
60231
60517
|
}
|
|
60232
|
-
let extraExports = [];
|
|
60233
60518
|
let directive = definition.directives?.find(
|
|
60234
60519
|
(directive2) => directive2.name.value === config2.argumentsDirective
|
|
60235
60520
|
);
|
|
60236
|
-
|
|
60237
|
-
|
|
60238
|
-
|
|
60239
|
-
AST11.
|
|
60240
|
-
AST11.identifier(
|
|
60241
|
-
AST11.
|
|
60242
|
-
(
|
|
60243
|
-
|
|
60244
|
-
|
|
60245
|
-
|
|
60246
|
-
|
|
60247
|
-
|
|
60248
|
-
|
|
60249
|
-
missingScalars,
|
|
60250
|
-
definition2,
|
|
60251
|
-
body
|
|
60252
|
-
)
|
|
60253
|
-
),
|
|
60254
|
-
definition2.type.kind !== "NonNullType"
|
|
60255
|
-
);
|
|
60256
|
-
}
|
|
60257
|
-
)
|
|
60258
|
-
)
|
|
60259
|
-
)
|
|
60260
|
-
)
|
|
60261
|
-
);
|
|
60262
|
-
}
|
|
60521
|
+
let inputValue = !directive ? AST11.tsTypeLiteral([]) : AST11.tsTypeLiteral(
|
|
60522
|
+
(fragmentArgumentsDefinitions(config2, filepath, definition) || []).map(
|
|
60523
|
+
(definition2) => {
|
|
60524
|
+
return AST11.tsPropertySignature(
|
|
60525
|
+
AST11.identifier(definition2.variable.name.value),
|
|
60526
|
+
AST11.tsTypeAnnotation(
|
|
60527
|
+
tsTypeReference(config2, missingScalars, definition2, body)
|
|
60528
|
+
),
|
|
60529
|
+
definition2.type.kind !== "NonNullType"
|
|
60530
|
+
);
|
|
60531
|
+
}
|
|
60532
|
+
)
|
|
60533
|
+
);
|
|
60263
60534
|
body.push(
|
|
60264
|
-
|
|
60535
|
+
AST11.exportNamedDeclaration(
|
|
60536
|
+
AST11.tsTypeAliasDeclaration(AST11.identifier(inputTypeName), inputValue)
|
|
60537
|
+
),
|
|
60265
60538
|
AST11.exportNamedDeclaration(
|
|
60266
60539
|
AST11.tsTypeAliasDeclaration(
|
|
60267
60540
|
AST11.identifier(propTypeName),
|
|
@@ -60277,14 +60550,12 @@ async function generateFragmentTypeDefs(config2, filepath, body, selections, def
|
|
|
60277
60550
|
),
|
|
60278
60551
|
readonlyProperty(
|
|
60279
60552
|
AST11.tsPropertySignature(
|
|
60280
|
-
AST11.stringLiteral(
|
|
60553
|
+
AST11.stringLiteral(fragmentKey2),
|
|
60281
60554
|
AST11.tsTypeAnnotation(
|
|
60282
60555
|
AST11.tsTypeLiteral([
|
|
60283
60556
|
AST11.tsPropertySignature(
|
|
60284
60557
|
AST11.stringLiteral(propTypeName),
|
|
60285
|
-
AST11.tsTypeAnnotation(
|
|
60286
|
-
AST11.tsLiteralType(AST11.booleanLiteral(true))
|
|
60287
|
-
)
|
|
60558
|
+
AST11.tsTypeAnnotation(AST11.tsAnyKeyword())
|
|
60288
60559
|
)
|
|
60289
60560
|
])
|
|
60290
60561
|
)
|
|
@@ -60996,6 +61267,13 @@ async function addID(config2, documents) {
|
|
|
60996
61267
|
return;
|
|
60997
61268
|
}
|
|
60998
61269
|
return addKeysToSelection(config2, node, fragmentType);
|
|
61270
|
+
},
|
|
61271
|
+
FragmentDefinition(node) {
|
|
61272
|
+
const fragmentType = config2.schema.getType(node.typeCondition.name.value);
|
|
61273
|
+
if (!fragmentType) {
|
|
61274
|
+
return;
|
|
61275
|
+
}
|
|
61276
|
+
return addKeysToSelection(config2, node, fragmentType);
|
|
60999
61277
|
}
|
|
61000
61278
|
});
|
|
61001
61279
|
}
|
|
@@ -61014,7 +61292,7 @@ function addKeysToSelection(config2, node, fieldType) {
|
|
|
61014
61292
|
const selections = [...node.selectionSet.selections];
|
|
61015
61293
|
for (const keyField of keyFields) {
|
|
61016
61294
|
if (node.selectionSet.selections.find(
|
|
61017
|
-
(
|
|
61295
|
+
(selection) => selection.kind === "Field" && !selection.alias && selection.name.value === keyField
|
|
61018
61296
|
)) {
|
|
61019
61297
|
continue;
|
|
61020
61298
|
}
|