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-cjs/index.js
CHANGED
|
@@ -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
|
}
|
|
@@ -54213,14 +54213,14 @@ function deepEquals(objA, objB, map = /* @__PURE__ */ new WeakMap()) {
|
|
|
54213
54213
|
}
|
|
54214
54214
|
|
|
54215
54215
|
// src/runtime/lib/selection.ts
|
|
54216
|
-
function getFieldsForType(
|
|
54217
|
-
let targetSelection =
|
|
54218
|
-
if (
|
|
54219
|
-
const mappedType =
|
|
54216
|
+
function getFieldsForType(selection, __typename) {
|
|
54217
|
+
let targetSelection = selection.fields || {};
|
|
54218
|
+
if (selection.abstractFields && __typename) {
|
|
54219
|
+
const mappedType = selection.abstractFields.typeMap[__typename];
|
|
54220
54220
|
if (mappedType) {
|
|
54221
|
-
targetSelection =
|
|
54222
|
-
} else if (
|
|
54223
|
-
targetSelection =
|
|
54221
|
+
targetSelection = selection.abstractFields.fields[mappedType];
|
|
54222
|
+
} else if (selection.abstractFields.fields[__typename]) {
|
|
54223
|
+
targetSelection = selection.abstractFields.fields[__typename];
|
|
54224
54224
|
}
|
|
54225
54225
|
}
|
|
54226
54226
|
return targetSelection;
|
|
@@ -54228,7 +54228,7 @@ function getFieldsForType(selection2, __typename) {
|
|
|
54228
54228
|
|
|
54229
54229
|
// src/runtime/lib/scalars.ts
|
|
54230
54230
|
async function marshalSelection({
|
|
54231
|
-
selection
|
|
54231
|
+
selection,
|
|
54232
54232
|
data
|
|
54233
54233
|
}) {
|
|
54234
54234
|
const config2 = getCurrentConfig();
|
|
@@ -54236,18 +54236,18 @@ async function marshalSelection({
|
|
|
54236
54236
|
return data;
|
|
54237
54237
|
}
|
|
54238
54238
|
if (Array.isArray(data)) {
|
|
54239
|
-
return await Promise.all(data.map((val) => marshalSelection({ selection
|
|
54239
|
+
return await Promise.all(data.map((val) => marshalSelection({ selection, data: val })));
|
|
54240
54240
|
}
|
|
54241
|
-
const targetSelection = getFieldsForType(
|
|
54241
|
+
const targetSelection = getFieldsForType(selection, data["__typename"]);
|
|
54242
54242
|
return Object.fromEntries(
|
|
54243
54243
|
await Promise.all(
|
|
54244
54244
|
Object.entries(data).map(async ([fieldName, value]) => {
|
|
54245
|
-
const { type, selection:
|
|
54245
|
+
const { type, selection: selection2 } = targetSelection[fieldName];
|
|
54246
54246
|
if (!type) {
|
|
54247
54247
|
return [fieldName, value];
|
|
54248
54248
|
}
|
|
54249
|
-
if (
|
|
54250
|
-
return [fieldName, await marshalSelection({ selection:
|
|
54249
|
+
if (selection2) {
|
|
54250
|
+
return [fieldName, await marshalSelection({ selection: selection2, data: value })];
|
|
54251
54251
|
}
|
|
54252
54252
|
if (config2.scalars?.[type]) {
|
|
54253
54253
|
const marshalFn = config2.scalars[type].marshal;
|
|
@@ -54298,6 +54298,7 @@ var DataSource = {
|
|
|
54298
54298
|
Network: "network",
|
|
54299
54299
|
Ssr: "ssr"
|
|
54300
54300
|
};
|
|
54301
|
+
var fragmentKey = " $fragments";
|
|
54301
54302
|
|
|
54302
54303
|
// src/runtime/lib/key.ts
|
|
54303
54304
|
var computeKey = ({ field, args }) => {
|
|
@@ -54784,7 +54785,7 @@ var List = class {
|
|
|
54784
54785
|
recordType,
|
|
54785
54786
|
key,
|
|
54786
54787
|
listType,
|
|
54787
|
-
selection
|
|
54788
|
+
selection,
|
|
54788
54789
|
when,
|
|
54789
54790
|
filters,
|
|
54790
54791
|
connection,
|
|
@@ -54796,7 +54797,7 @@ var List = class {
|
|
|
54796
54797
|
this.key = key;
|
|
54797
54798
|
this.type = listType;
|
|
54798
54799
|
this.cache = manager.cache;
|
|
54799
|
-
this.selection =
|
|
54800
|
+
this.selection = selection;
|
|
54800
54801
|
this._when = when;
|
|
54801
54802
|
this.filters = filters;
|
|
54802
54803
|
this.name = name;
|
|
@@ -54807,19 +54808,19 @@ var List = class {
|
|
|
54807
54808
|
when(when) {
|
|
54808
54809
|
return this.manager.lists.get(this.name).get(this.recordID).when(when);
|
|
54809
54810
|
}
|
|
54810
|
-
append(
|
|
54811
|
-
return this.addToList(
|
|
54811
|
+
append(selection, data, variables = {}) {
|
|
54812
|
+
return this.addToList(selection, data, variables, "last");
|
|
54812
54813
|
}
|
|
54813
|
-
prepend(
|
|
54814
|
-
return this.addToList(
|
|
54814
|
+
prepend(selection, data, variables = {}) {
|
|
54815
|
+
return this.addToList(selection, data, variables, "first");
|
|
54815
54816
|
}
|
|
54816
|
-
addToList(
|
|
54817
|
+
addToList(selection, data, variables = {}, where) {
|
|
54817
54818
|
const listType = this.listType(data);
|
|
54818
54819
|
const dataID = this.cache._internal_unstable.id(listType, data);
|
|
54819
54820
|
if (!this.validateWhen() || !dataID) {
|
|
54820
54821
|
return;
|
|
54821
54822
|
}
|
|
54822
|
-
let insertSelection =
|
|
54823
|
+
let insertSelection = selection;
|
|
54823
54824
|
let insertData = data;
|
|
54824
54825
|
if (this.connection) {
|
|
54825
54826
|
insertSelection = {
|
|
@@ -54839,9 +54840,9 @@ var List = class {
|
|
|
54839
54840
|
type: listType,
|
|
54840
54841
|
keyRaw: "node",
|
|
54841
54842
|
selection: {
|
|
54842
|
-
...
|
|
54843
|
+
...selection,
|
|
54843
54844
|
fields: {
|
|
54844
|
-
...
|
|
54845
|
+
...selection.fields,
|
|
54845
54846
|
__typename: {
|
|
54846
54847
|
keyRaw: "__typename",
|
|
54847
54848
|
type: "String"
|
|
@@ -54870,9 +54871,9 @@ var List = class {
|
|
|
54870
54871
|
type: listType,
|
|
54871
54872
|
updates: ["append", "prepend"],
|
|
54872
54873
|
selection: {
|
|
54873
|
-
...
|
|
54874
|
+
...selection,
|
|
54874
54875
|
fields: {
|
|
54875
|
-
...
|
|
54876
|
+
...selection.fields,
|
|
54876
54877
|
__typename: {
|
|
54877
54878
|
keyRaw: "__typename",
|
|
54878
54879
|
type: "String"
|
|
@@ -54947,7 +54948,8 @@ var List = class {
|
|
|
54947
54948
|
this.cache._internal_unstable.getSelection({
|
|
54948
54949
|
parent: spec.parentID || this.manager.rootID,
|
|
54949
54950
|
selection: spec.selection,
|
|
54950
|
-
variables: spec.variables?.() || {}
|
|
54951
|
+
variables: spec.variables?.() || {},
|
|
54952
|
+
ignoreMasking: false
|
|
54951
54953
|
}).data
|
|
54952
54954
|
);
|
|
54953
54955
|
}
|
|
@@ -54983,9 +54985,9 @@ var List = class {
|
|
|
54983
54985
|
}
|
|
54984
54986
|
return ok;
|
|
54985
54987
|
}
|
|
54986
|
-
toggleElement(
|
|
54988
|
+
toggleElement(selection, data, variables = {}, where) {
|
|
54987
54989
|
if (!this.remove(data, variables)) {
|
|
54988
|
-
this.addToList(
|
|
54990
|
+
this.addToList(selection, data, variables, where);
|
|
54989
54991
|
}
|
|
54990
54992
|
}
|
|
54991
54993
|
*[Symbol.iterator]() {
|
|
@@ -55560,14 +55562,24 @@ var InMemorySubscriptions = class {
|
|
|
55560
55562
|
add({
|
|
55561
55563
|
parent,
|
|
55562
55564
|
spec,
|
|
55563
|
-
selection
|
|
55565
|
+
selection,
|
|
55564
55566
|
variables,
|
|
55565
55567
|
parentType
|
|
55566
55568
|
}) {
|
|
55567
55569
|
const __typename = this.cache._internal_unstable.storage.get(parent, "__typename").value;
|
|
55568
|
-
let targetSelection = getFieldsForType(
|
|
55570
|
+
let targetSelection = getFieldsForType(selection, __typename);
|
|
55569
55571
|
for (const fieldSelection of Object.values(targetSelection || {})) {
|
|
55570
|
-
const {
|
|
55572
|
+
const {
|
|
55573
|
+
keyRaw,
|
|
55574
|
+
selection: innerSelection,
|
|
55575
|
+
type,
|
|
55576
|
+
list,
|
|
55577
|
+
filters,
|
|
55578
|
+
visible
|
|
55579
|
+
} = fieldSelection;
|
|
55580
|
+
if (!visible) {
|
|
55581
|
+
continue;
|
|
55582
|
+
}
|
|
55571
55583
|
const key = evaluateKey(keyRaw, variables);
|
|
55572
55584
|
let targetSelection2;
|
|
55573
55585
|
if (innerSelection) {
|
|
@@ -55615,10 +55627,10 @@ var InMemorySubscriptions = class {
|
|
|
55615
55627
|
addFieldSubscription({
|
|
55616
55628
|
id,
|
|
55617
55629
|
key,
|
|
55618
|
-
selection
|
|
55630
|
+
selection,
|
|
55619
55631
|
type
|
|
55620
55632
|
}) {
|
|
55621
|
-
const spec =
|
|
55633
|
+
const spec = selection[0];
|
|
55622
55634
|
if (!this.subscribers[id]) {
|
|
55623
55635
|
this.subscribers[id] = {};
|
|
55624
55636
|
}
|
|
@@ -55630,7 +55642,7 @@ var InMemorySubscriptions = class {
|
|
|
55630
55642
|
}
|
|
55631
55643
|
this.keyVersions[key].add(key);
|
|
55632
55644
|
if (!this.subscribers[id][key].map(([{ set }]) => set).includes(spec.set)) {
|
|
55633
|
-
this.subscribers[id][key].push([spec,
|
|
55645
|
+
this.subscribers[id][key].push([spec, selection[1]]);
|
|
55634
55646
|
}
|
|
55635
55647
|
if (!this.referenceCounts[id]) {
|
|
55636
55648
|
this.referenceCounts[id] = {};
|
|
@@ -55641,14 +55653,13 @@ var InMemorySubscriptions = class {
|
|
|
55641
55653
|
const counts = this.referenceCounts[id][key];
|
|
55642
55654
|
counts.set(spec.set, (counts.get(spec.set) || 0) + 1);
|
|
55643
55655
|
this.cache._internal_unstable.lifetimes.resetLifetime(id, key);
|
|
55644
|
-
const { selection: innerSelection } = selection2[1]?.[key] ?? {};
|
|
55645
55656
|
}
|
|
55646
55657
|
registerList({
|
|
55647
55658
|
list,
|
|
55648
55659
|
id,
|
|
55649
55660
|
key,
|
|
55650
55661
|
parentType,
|
|
55651
|
-
selection
|
|
55662
|
+
selection,
|
|
55652
55663
|
filters,
|
|
55653
55664
|
variables
|
|
55654
55665
|
}) {
|
|
@@ -55659,7 +55670,7 @@ var InMemorySubscriptions = class {
|
|
|
55659
55670
|
recordType: this.cache._internal_unstable.storage.get(id, "__typename")?.value || parentType,
|
|
55660
55671
|
listType: list.type,
|
|
55661
55672
|
key,
|
|
55662
|
-
selection
|
|
55673
|
+
selection,
|
|
55663
55674
|
filters: Object.entries(filters || {}).reduce((acc, [key2, { kind, value }]) => {
|
|
55664
55675
|
return {
|
|
55665
55676
|
...acc,
|
|
@@ -55675,14 +55686,14 @@ var InMemorySubscriptions = class {
|
|
|
55675
55686
|
parentType
|
|
55676
55687
|
}) {
|
|
55677
55688
|
for (const [spec, targetSelection] of subscribers) {
|
|
55678
|
-
for (const
|
|
55689
|
+
for (const selection of Object.values(targetSelection ?? {})) {
|
|
55679
55690
|
const {
|
|
55680
55691
|
type: linkedType,
|
|
55681
55692
|
keyRaw,
|
|
55682
55693
|
selection: innerSelection,
|
|
55683
55694
|
list,
|
|
55684
55695
|
filters
|
|
55685
|
-
} =
|
|
55696
|
+
} = selection;
|
|
55686
55697
|
const key = evaluateKey(keyRaw, variables);
|
|
55687
55698
|
const fieldSelection = innerSelection ? getFieldsForType(innerSelection, parentType) : void 0;
|
|
55688
55699
|
this.addFieldSubscription({
|
|
@@ -55702,7 +55713,7 @@ var InMemorySubscriptions = class {
|
|
|
55702
55713
|
parentType: parentType || spec.rootType
|
|
55703
55714
|
});
|
|
55704
55715
|
}
|
|
55705
|
-
const childSelection =
|
|
55716
|
+
const childSelection = selection.selection;
|
|
55706
55717
|
if (childSelection) {
|
|
55707
55718
|
const { value: link } = this.cache._internal_unstable.storage.get(parent, key);
|
|
55708
55719
|
const children = !Array.isArray(link) ? [link] : flatten(link);
|
|
@@ -55729,11 +55740,11 @@ var InMemorySubscriptions = class {
|
|
|
55729
55740
|
get(id, field) {
|
|
55730
55741
|
return this.subscribers[id]?.[field] || [];
|
|
55731
55742
|
}
|
|
55732
|
-
remove(id,
|
|
55743
|
+
remove(id, selection, targets, variables, visited = []) {
|
|
55733
55744
|
visited.push(id);
|
|
55734
55745
|
const linkedIDs = [];
|
|
55735
55746
|
const __typename = this.cache._internal_unstable.storage.get(id, "__typename").value;
|
|
55736
|
-
let targetSelection = getFieldsForType(
|
|
55747
|
+
let targetSelection = getFieldsForType(selection, __typename);
|
|
55737
55748
|
for (const fieldSelection of Object.values(targetSelection || {})) {
|
|
55738
55749
|
const key = evaluateKey(fieldSelection.keyRaw, variables);
|
|
55739
55750
|
this.removeSubscribers(id, key, targets);
|
|
@@ -55795,7 +55806,7 @@ var InMemorySubscriptions = class {
|
|
|
55795
55806
|
// src/runtime/cache/cache.ts
|
|
55796
55807
|
var Cache = class {
|
|
55797
55808
|
_internal_unstable;
|
|
55798
|
-
constructor(config2) {
|
|
55809
|
+
constructor({ disabled, ...config2 } = {}) {
|
|
55799
55810
|
this._internal_unstable = new CacheInternal({
|
|
55800
55811
|
cache: this,
|
|
55801
55812
|
storage: new InMemoryStorage(),
|
|
@@ -55803,9 +55814,10 @@ var Cache = class {
|
|
|
55803
55814
|
lists: new ListManager(this, rootID),
|
|
55804
55815
|
lifetimes: new GarbageCollector(this),
|
|
55805
55816
|
staleManager: new StaleManager(this),
|
|
55806
|
-
schema: new SchemaManager(this)
|
|
55817
|
+
schema: new SchemaManager(this),
|
|
55818
|
+
disabled: disabled ?? typeof globalThis.window === "undefined"
|
|
55807
55819
|
});
|
|
55808
|
-
if (config2) {
|
|
55820
|
+
if (Object.keys(config2).length > 0) {
|
|
55809
55821
|
this.setConfig(defaultConfigValues(config2));
|
|
55810
55822
|
}
|
|
55811
55823
|
}
|
|
@@ -55824,7 +55836,8 @@ var Cache = class {
|
|
|
55824
55836
|
this._internal_unstable.getSelection({
|
|
55825
55837
|
parent: spec.parentID || rootID,
|
|
55826
55838
|
selection: spec.selection,
|
|
55827
|
-
variables: spec.variables?.() || {}
|
|
55839
|
+
variables: spec.variables?.() || {},
|
|
55840
|
+
ignoreMasking: false
|
|
55828
55841
|
}).data
|
|
55829
55842
|
);
|
|
55830
55843
|
}
|
|
@@ -55899,16 +55912,13 @@ var Cache = class {
|
|
|
55899
55912
|
getFieldTime(id, field) {
|
|
55900
55913
|
return this._internal_unstable.staleManager.getFieldTime(id, field);
|
|
55901
55914
|
}
|
|
55915
|
+
config() {
|
|
55916
|
+
return this._internal_unstable.config;
|
|
55917
|
+
}
|
|
55902
55918
|
};
|
|
55903
55919
|
var CacheInternal = class {
|
|
55904
55920
|
_disabled = false;
|
|
55905
|
-
|
|
55906
|
-
plugins: {
|
|
55907
|
-
"houdini-svelte": {
|
|
55908
|
-
client: ""
|
|
55909
|
-
}
|
|
55910
|
-
}
|
|
55911
|
-
});
|
|
55921
|
+
_config;
|
|
55912
55922
|
storage;
|
|
55913
55923
|
subscriptions;
|
|
55914
55924
|
lists;
|
|
@@ -55923,7 +55933,9 @@ var CacheInternal = class {
|
|
|
55923
55933
|
cache,
|
|
55924
55934
|
lifetimes,
|
|
55925
55935
|
staleManager,
|
|
55926
|
-
schema
|
|
55936
|
+
schema,
|
|
55937
|
+
disabled,
|
|
55938
|
+
config: config2
|
|
55927
55939
|
}) {
|
|
55928
55940
|
this.storage = storage;
|
|
55929
55941
|
this.subscriptions = subscriptions;
|
|
@@ -55932,7 +55944,8 @@ var CacheInternal = class {
|
|
|
55932
55944
|
this.lifetimes = lifetimes;
|
|
55933
55945
|
this.staleManager = staleManager;
|
|
55934
55946
|
this.schema = schema;
|
|
55935
|
-
this.
|
|
55947
|
+
this._config = config2;
|
|
55948
|
+
this._disabled = disabled;
|
|
55936
55949
|
try {
|
|
55937
55950
|
if (process.env.HOUDINI_TEST === "true") {
|
|
55938
55951
|
this._disabled = false;
|
|
@@ -55940,12 +55953,15 @@ var CacheInternal = class {
|
|
|
55940
55953
|
} catch {
|
|
55941
55954
|
}
|
|
55942
55955
|
}
|
|
55956
|
+
get config() {
|
|
55957
|
+
return this._config ?? getCurrentConfig();
|
|
55958
|
+
}
|
|
55943
55959
|
setConfig(config2) {
|
|
55944
|
-
this.
|
|
55960
|
+
this._config = config2;
|
|
55945
55961
|
}
|
|
55946
55962
|
writeSelection({
|
|
55947
55963
|
data,
|
|
55948
|
-
selection
|
|
55964
|
+
selection,
|
|
55949
55965
|
variables = {},
|
|
55950
55966
|
parent = rootID,
|
|
55951
55967
|
applyUpdates,
|
|
@@ -55957,9 +55973,9 @@ var CacheInternal = class {
|
|
|
55957
55973
|
if (this._disabled) {
|
|
55958
55974
|
return [];
|
|
55959
55975
|
}
|
|
55960
|
-
let targetSelection = getFieldsForType(
|
|
55976
|
+
let targetSelection = getFieldsForType(selection, data["__typename"]);
|
|
55961
55977
|
for (const [field, value] of Object.entries(data)) {
|
|
55962
|
-
if (!
|
|
55978
|
+
if (!selection || !targetSelection[field]) {
|
|
55963
55979
|
continue;
|
|
55964
55980
|
}
|
|
55965
55981
|
let {
|
|
@@ -56215,25 +56231,40 @@ var CacheInternal = class {
|
|
|
56215
56231
|
return toNotify;
|
|
56216
56232
|
}
|
|
56217
56233
|
getSelection({
|
|
56218
|
-
selection
|
|
56234
|
+
selection,
|
|
56219
56235
|
parent = rootID,
|
|
56220
56236
|
variables,
|
|
56221
|
-
stepsFromConnection = null
|
|
56237
|
+
stepsFromConnection = null,
|
|
56238
|
+
ignoreMasking
|
|
56222
56239
|
}) {
|
|
56223
56240
|
if (parent === null) {
|
|
56224
56241
|
return { data: null, partial: false, stale: false, hasData: true };
|
|
56225
56242
|
}
|
|
56226
56243
|
const target = {};
|
|
56244
|
+
if (selection.fragments) {
|
|
56245
|
+
target[fragmentKey] = Object.fromEntries(
|
|
56246
|
+
Object.entries(selection.fragments).map(([key, value]) => [
|
|
56247
|
+
key,
|
|
56248
|
+
{
|
|
56249
|
+
parent,
|
|
56250
|
+
variables: evaluateFragmentVariables(value, variables ?? {})
|
|
56251
|
+
}
|
|
56252
|
+
])
|
|
56253
|
+
);
|
|
56254
|
+
}
|
|
56227
56255
|
let hasData = false;
|
|
56228
56256
|
let partial = false;
|
|
56229
56257
|
let cascadeNull = false;
|
|
56230
56258
|
let stale = false;
|
|
56231
56259
|
const typename = this.storage.get(parent, "__typename").value;
|
|
56232
|
-
let targetSelection = getFieldsForType(
|
|
56260
|
+
let targetSelection = getFieldsForType(selection, typename);
|
|
56233
56261
|
for (const [
|
|
56234
56262
|
attributeName,
|
|
56235
|
-
{ type, keyRaw, selection: fieldSelection, nullable, list }
|
|
56263
|
+
{ type, keyRaw, selection: fieldSelection, nullable, list, visible }
|
|
56236
56264
|
] of Object.entries(targetSelection)) {
|
|
56265
|
+
if (!visible && !ignoreMasking) {
|
|
56266
|
+
continue;
|
|
56267
|
+
}
|
|
56237
56268
|
const key = evaluateKey(keyRaw, variables);
|
|
56238
56269
|
const { value } = this.storage.get(parent, key);
|
|
56239
56270
|
const dt_field = this.staleManager.getFieldTime(parent, key);
|
|
@@ -56273,7 +56304,8 @@ var CacheInternal = class {
|
|
|
56273
56304
|
fields: fieldSelection,
|
|
56274
56305
|
variables,
|
|
56275
56306
|
linkedList: value,
|
|
56276
|
-
stepsFromConnection: nextStep
|
|
56307
|
+
stepsFromConnection: nextStep,
|
|
56308
|
+
ignoreMasking: !!ignoreMasking
|
|
56277
56309
|
});
|
|
56278
56310
|
target[attributeName] = listValue.data;
|
|
56279
56311
|
if (listValue.partial) {
|
|
@@ -56290,7 +56322,8 @@ var CacheInternal = class {
|
|
|
56290
56322
|
parent: value,
|
|
56291
56323
|
selection: fieldSelection,
|
|
56292
56324
|
variables,
|
|
56293
|
-
stepsFromConnection: nextStep
|
|
56325
|
+
stepsFromConnection: nextStep,
|
|
56326
|
+
ignoreMasking
|
|
56294
56327
|
});
|
|
56295
56328
|
target[attributeName] = objectFields.data;
|
|
56296
56329
|
if (objectFields.partial) {
|
|
@@ -56334,7 +56367,8 @@ var CacheInternal = class {
|
|
|
56334
56367
|
fields,
|
|
56335
56368
|
variables,
|
|
56336
56369
|
linkedList,
|
|
56337
|
-
stepsFromConnection
|
|
56370
|
+
stepsFromConnection,
|
|
56371
|
+
ignoreMasking
|
|
56338
56372
|
}) {
|
|
56339
56373
|
const result = [];
|
|
56340
56374
|
let partialData = false;
|
|
@@ -56346,7 +56380,8 @@ var CacheInternal = class {
|
|
|
56346
56380
|
fields,
|
|
56347
56381
|
variables,
|
|
56348
56382
|
linkedList: entry,
|
|
56349
|
-
stepsFromConnection
|
|
56383
|
+
stepsFromConnection,
|
|
56384
|
+
ignoreMasking
|
|
56350
56385
|
});
|
|
56351
56386
|
result.push(nestedValue.data);
|
|
56352
56387
|
if (nestedValue.partial) {
|
|
@@ -56367,7 +56402,8 @@ var CacheInternal = class {
|
|
|
56367
56402
|
parent: entry,
|
|
56368
56403
|
selection: fields,
|
|
56369
56404
|
variables,
|
|
56370
|
-
stepsFromConnection
|
|
56405
|
+
stepsFromConnection,
|
|
56406
|
+
ignoreMasking
|
|
56371
56407
|
});
|
|
56372
56408
|
result.push(data);
|
|
56373
56409
|
if (partial) {
|
|
@@ -56470,11 +56506,54 @@ var CacheInternal = class {
|
|
|
56470
56506
|
}
|
|
56471
56507
|
}
|
|
56472
56508
|
};
|
|
56509
|
+
function evaluateFragmentVariables(variables, args) {
|
|
56510
|
+
return Object.fromEntries(
|
|
56511
|
+
Object.entries(variables).map(([key, value]) => [key, fragmentVariableValue(value, args)])
|
|
56512
|
+
);
|
|
56513
|
+
}
|
|
56514
|
+
function fragmentVariableValue(value, args) {
|
|
56515
|
+
if (value.kind === "StringValue") {
|
|
56516
|
+
return value.value;
|
|
56517
|
+
}
|
|
56518
|
+
if (value.kind === "BooleanValue") {
|
|
56519
|
+
return value.value;
|
|
56520
|
+
}
|
|
56521
|
+
if (value.kind === "EnumValue") {
|
|
56522
|
+
return value.value;
|
|
56523
|
+
}
|
|
56524
|
+
if (value.kind === "FloatValue") {
|
|
56525
|
+
return parseFloat(value.value);
|
|
56526
|
+
}
|
|
56527
|
+
if (value.kind === "IntValue") {
|
|
56528
|
+
return parseInt(value.value, 10);
|
|
56529
|
+
}
|
|
56530
|
+
if (value.kind === "NullValue") {
|
|
56531
|
+
return null;
|
|
56532
|
+
}
|
|
56533
|
+
if (value.kind === "Variable") {
|
|
56534
|
+
return args[value.name.value];
|
|
56535
|
+
}
|
|
56536
|
+
if (value.kind === "ListValue") {
|
|
56537
|
+
return value.values.map((value2) => fragmentVariableValue(value2, args));
|
|
56538
|
+
}
|
|
56539
|
+
if (value.kind === "ObjectValue") {
|
|
56540
|
+
return value.fields.reduce(
|
|
56541
|
+
(obj, field) => ({
|
|
56542
|
+
...obj,
|
|
56543
|
+
[field.name.value]: fragmentVariableValue(field.value, args)
|
|
56544
|
+
}),
|
|
56545
|
+
{}
|
|
56546
|
+
);
|
|
56547
|
+
}
|
|
56548
|
+
}
|
|
56473
56549
|
var rootID = "_ROOT_";
|
|
56474
56550
|
|
|
56475
56551
|
// src/runtime/cache/index.ts
|
|
56476
56552
|
var cache_default = new Cache();
|
|
56477
56553
|
|
|
56554
|
+
// src/runtime/client/plugins/cache.ts
|
|
56555
|
+
var serverSide = typeof globalThis.window === "undefined";
|
|
56556
|
+
|
|
56478
56557
|
// src/runtime/client/utils/documentPlugins.ts
|
|
56479
56558
|
var documentPlugin = (kind, source) => {
|
|
56480
56559
|
return () => {
|
|
@@ -56510,7 +56589,6 @@ var documentPlugin = (kind, source) => {
|
|
|
56510
56589
|
var query = documentPlugin(ArtifactKind.Query, function() {
|
|
56511
56590
|
let subscriptionSpec = null;
|
|
56512
56591
|
let lastVariables = null;
|
|
56513
|
-
let artifactName = "";
|
|
56514
56592
|
return {
|
|
56515
56593
|
start(ctx, { next }) {
|
|
56516
56594
|
ctx.variables = {
|
|
@@ -56520,8 +56598,7 @@ var query = documentPlugin(ArtifactKind.Query, function() {
|
|
|
56520
56598
|
next(ctx);
|
|
56521
56599
|
},
|
|
56522
56600
|
end(ctx, { resolve: resolve2, marshalVariables, variablesChanged }) {
|
|
56523
|
-
if (variablesChanged(ctx)) {
|
|
56524
|
-
artifactName = ctx.artifact.name;
|
|
56601
|
+
if (variablesChanged(ctx) && !ctx.cacheParams?.disableSubscriptions) {
|
|
56525
56602
|
if (subscriptionSpec) {
|
|
56526
56603
|
cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.() || {});
|
|
56527
56604
|
}
|
|
@@ -56542,19 +56619,61 @@ var query = documentPlugin(ArtifactKind.Query, function() {
|
|
|
56542
56619
|
});
|
|
56543
56620
|
}
|
|
56544
56621
|
};
|
|
56545
|
-
cache_default.subscribe(subscriptionSpec, lastVariables
|
|
56622
|
+
cache_default.subscribe(subscriptionSpec, lastVariables);
|
|
56546
56623
|
}
|
|
56547
56624
|
resolve2(ctx);
|
|
56548
56625
|
},
|
|
56549
56626
|
cleanup() {
|
|
56550
56627
|
if (subscriptionSpec) {
|
|
56551
|
-
cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.()
|
|
56628
|
+
cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.());
|
|
56552
56629
|
lastVariables = null;
|
|
56553
56630
|
}
|
|
56554
56631
|
}
|
|
56555
56632
|
};
|
|
56556
56633
|
});
|
|
56557
56634
|
|
|
56635
|
+
// src/runtime/client/plugins/fragment.ts
|
|
56636
|
+
var fragment = documentPlugin(ArtifactKind.Fragment, function() {
|
|
56637
|
+
let subscriptionSpec = null;
|
|
56638
|
+
return {
|
|
56639
|
+
start(ctx, { next, resolve: resolve2, variablesChanged, marshalVariables }) {
|
|
56640
|
+
if (!ctx.stuff.parentID) {
|
|
56641
|
+
return next(ctx);
|
|
56642
|
+
}
|
|
56643
|
+
if (variablesChanged(ctx) && !ctx.cacheParams?.disableSubscriptions) {
|
|
56644
|
+
if (subscriptionSpec) {
|
|
56645
|
+
cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.() || {});
|
|
56646
|
+
}
|
|
56647
|
+
const variables = marshalVariables(ctx);
|
|
56648
|
+
subscriptionSpec = {
|
|
56649
|
+
rootType: ctx.artifact.rootType,
|
|
56650
|
+
selection: ctx.artifact.selection,
|
|
56651
|
+
variables: () => variables,
|
|
56652
|
+
parentID: ctx.stuff.parentID,
|
|
56653
|
+
set: (newValue) => {
|
|
56654
|
+
resolve2(ctx, {
|
|
56655
|
+
data: newValue,
|
|
56656
|
+
errors: null,
|
|
56657
|
+
fetching: false,
|
|
56658
|
+
partial: false,
|
|
56659
|
+
stale: false,
|
|
56660
|
+
source: DataSource.Cache,
|
|
56661
|
+
variables
|
|
56662
|
+
});
|
|
56663
|
+
}
|
|
56664
|
+
};
|
|
56665
|
+
cache_default.subscribe(subscriptionSpec, variables);
|
|
56666
|
+
}
|
|
56667
|
+
next(ctx);
|
|
56668
|
+
},
|
|
56669
|
+
cleanup() {
|
|
56670
|
+
if (subscriptionSpec) {
|
|
56671
|
+
cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.());
|
|
56672
|
+
}
|
|
56673
|
+
}
|
|
56674
|
+
};
|
|
56675
|
+
});
|
|
56676
|
+
|
|
56558
56677
|
// src/runtime/client/plugins/mutation.ts
|
|
56559
56678
|
var mutation = documentPlugin(ArtifactKind.Mutation, () => {
|
|
56560
56679
|
return {
|
|
@@ -56711,6 +56830,7 @@ var Config = class {
|
|
|
56711
56830
|
this.schemaPollInterval = watchSchema?.interval ?? 2e3;
|
|
56712
56831
|
this.schemaPollHeaders = watchSchema?.headers ?? {};
|
|
56713
56832
|
this.rootDir = join(this.projectRoot, "$houdini");
|
|
56833
|
+
this.#fragmentVariableMaps = {};
|
|
56714
56834
|
if (defaultKeys) {
|
|
56715
56835
|
this.defaultKeys = defaultKeys;
|
|
56716
56836
|
}
|
|
@@ -56860,7 +56980,7 @@ var Config = class {
|
|
|
56860
56980
|
return `$houdini/${this.artifactDirectoryName}/${name}`;
|
|
56861
56981
|
}
|
|
56862
56982
|
keyFieldsForType(type) {
|
|
56863
|
-
return keyFieldsForType(this.configFile, type);
|
|
56983
|
+
return this.schema.getQueryType()?.name === type ? [] : keyFieldsForType(this.configFile, type);
|
|
56864
56984
|
}
|
|
56865
56985
|
computeID(type, data) {
|
|
56866
56986
|
return computeID(this.configFile, type, data);
|
|
@@ -56879,7 +56999,7 @@ var Config = class {
|
|
|
56879
56999
|
({ kind }) => kind === graphql.Kind.FRAGMENT_DEFINITION
|
|
56880
57000
|
);
|
|
56881
57001
|
if (fragmentDefinitions.length) {
|
|
56882
|
-
return fragmentDefinitions.
|
|
57002
|
+
return fragmentDefinitions[0].name.value;
|
|
56883
57003
|
}
|
|
56884
57004
|
throw new Error("Could not generate artifact name for document: " + graphql.print(document));
|
|
56885
57005
|
}
|
|
@@ -57051,6 +57171,56 @@ var Config = class {
|
|
|
57051
57171
|
}, []) ?? [];
|
|
57052
57172
|
return !defaultDirectives.includes(name) && (internalDirectives.includes(name) || this.isDeleteDirective(name));
|
|
57053
57173
|
}
|
|
57174
|
+
#fragmentVariableMaps;
|
|
57175
|
+
registerFragmentVariablesHash({
|
|
57176
|
+
hash,
|
|
57177
|
+
args,
|
|
57178
|
+
fragment: fragment2
|
|
57179
|
+
}) {
|
|
57180
|
+
this.#fragmentVariableMaps[hash] = {
|
|
57181
|
+
args: this.#serializeValueMap(args),
|
|
57182
|
+
fragment: fragment2
|
|
57183
|
+
};
|
|
57184
|
+
}
|
|
57185
|
+
getFragmentVariablesHash(hash) {
|
|
57186
|
+
return this.#fragmentVariableMaps[hash] ?? {
|
|
57187
|
+
fragment: hash,
|
|
57188
|
+
args: {},
|
|
57189
|
+
hash
|
|
57190
|
+
};
|
|
57191
|
+
}
|
|
57192
|
+
#serializeValueMap(map) {
|
|
57193
|
+
if (!map) {
|
|
57194
|
+
return null;
|
|
57195
|
+
}
|
|
57196
|
+
return Object.fromEntries(
|
|
57197
|
+
Object.entries(map).map(([key, input]) => {
|
|
57198
|
+
const result = {
|
|
57199
|
+
kind: input.kind
|
|
57200
|
+
};
|
|
57201
|
+
if (typeof input === "object") {
|
|
57202
|
+
if ("value" in input) {
|
|
57203
|
+
result.value = input.value;
|
|
57204
|
+
}
|
|
57205
|
+
if ("values" in input) {
|
|
57206
|
+
result.values = input.values.map(
|
|
57207
|
+
(value) => this.#serializeValueMap({ foo: value }).foo
|
|
57208
|
+
);
|
|
57209
|
+
}
|
|
57210
|
+
if ("name" in input) {
|
|
57211
|
+
result.name = input.name;
|
|
57212
|
+
}
|
|
57213
|
+
if ("fields" in input) {
|
|
57214
|
+
result.fields = input.fields.map((field) => ({
|
|
57215
|
+
name: field.name,
|
|
57216
|
+
value: this.#serializeValueMap({ foo: field.value }).foo
|
|
57217
|
+
}));
|
|
57218
|
+
}
|
|
57219
|
+
}
|
|
57220
|
+
return [key, result];
|
|
57221
|
+
})
|
|
57222
|
+
);
|
|
57223
|
+
}
|
|
57054
57224
|
isListFragment(name) {
|
|
57055
57225
|
return name.endsWith(this.insertFragmentSuffix) || name.endsWith(this.removeFragmentSuffix) || name.endsWith(this.toggleFragmentSuffix);
|
|
57056
57226
|
}
|
|
@@ -57335,11 +57505,17 @@ function deepMerge(filepath, ...targets) {
|
|
|
57335
57505
|
if (targets.length === 1) {
|
|
57336
57506
|
return targets[0];
|
|
57337
57507
|
} else if (targets.length === 2) {
|
|
57338
|
-
return (0, import_deepmerge.default)(targets[0], targets[1]
|
|
57508
|
+
return (0, import_deepmerge.default)(targets[0], targets[1], {
|
|
57509
|
+
arrayMerge: (source, update) => [...new Set(source.concat(update))]
|
|
57510
|
+
});
|
|
57339
57511
|
}
|
|
57340
57512
|
return deepMerge(filepath, targets[0], deepMerge(filepath, ...targets.slice(1)));
|
|
57341
57513
|
} catch (e) {
|
|
57342
|
-
throw new HoudiniError({
|
|
57514
|
+
throw new HoudiniError({
|
|
57515
|
+
filepath,
|
|
57516
|
+
message: "could not merge: " + targets,
|
|
57517
|
+
description: e.message
|
|
57518
|
+
});
|
|
57343
57519
|
}
|
|
57344
57520
|
}
|
|
57345
57521
|
|
|
@@ -57383,16 +57559,16 @@ function flattenSelections({
|
|
|
57383
57559
|
filepath,
|
|
57384
57560
|
selections,
|
|
57385
57561
|
fragmentDefinitions,
|
|
57386
|
-
|
|
57387
|
-
|
|
57562
|
+
ignoreMaskDisable,
|
|
57563
|
+
keepFragmentSpreadNodes
|
|
57388
57564
|
}) {
|
|
57389
57565
|
const fields = new FieldCollection({
|
|
57390
57566
|
config: config2,
|
|
57391
57567
|
filepath,
|
|
57392
57568
|
selections,
|
|
57393
57569
|
fragmentDefinitions,
|
|
57394
|
-
|
|
57395
|
-
|
|
57570
|
+
ignoreMaskDisable: !!ignoreMaskDisable,
|
|
57571
|
+
keepFragmentSpreadNodes: !!keepFragmentSpreadNodes
|
|
57396
57572
|
});
|
|
57397
57573
|
return fields.toSelectionSet();
|
|
57398
57574
|
}
|
|
@@ -57403,57 +57579,60 @@ var FieldCollection = class {
|
|
|
57403
57579
|
fields;
|
|
57404
57580
|
inlineFragments;
|
|
57405
57581
|
fragmentSpreads;
|
|
57406
|
-
applyFragments;
|
|
57407
57582
|
ignoreMaskDisable;
|
|
57583
|
+
keepFragmentSpreadNodes;
|
|
57408
57584
|
constructor(args) {
|
|
57409
57585
|
this.config = args.config;
|
|
57410
57586
|
this.fragmentDefinitions = args.fragmentDefinitions;
|
|
57411
|
-
this.applyFragments = args.applyFragments;
|
|
57412
57587
|
this.ignoreMaskDisable = args.ignoreMaskDisable;
|
|
57588
|
+
this.keepFragmentSpreadNodes = args.keepFragmentSpreadNodes;
|
|
57413
57589
|
this.fields = {};
|
|
57414
57590
|
this.inlineFragments = {};
|
|
57415
57591
|
this.fragmentSpreads = {};
|
|
57416
57592
|
this.filepath = args.filepath;
|
|
57417
|
-
for (const
|
|
57418
|
-
this.add(
|
|
57593
|
+
for (const selection of args.selections) {
|
|
57594
|
+
this.add(selection);
|
|
57419
57595
|
}
|
|
57420
57596
|
}
|
|
57421
57597
|
get size() {
|
|
57422
57598
|
return Object.keys(this.fields).length + Object.keys(this.inlineFragments).length + Object.keys(this.fragmentSpreads).length;
|
|
57423
57599
|
}
|
|
57424
|
-
add(
|
|
57425
|
-
if (
|
|
57426
|
-
const key =
|
|
57600
|
+
add(selection) {
|
|
57601
|
+
if (selection.kind === "Field") {
|
|
57602
|
+
const key = selection.alias?.value || selection.name.value;
|
|
57427
57603
|
if (!this.fields[key]) {
|
|
57428
57604
|
this.fields[key] = {
|
|
57429
|
-
astNode:
|
|
57605
|
+
astNode: selection,
|
|
57430
57606
|
selection: this.empty()
|
|
57431
57607
|
};
|
|
57432
57608
|
}
|
|
57433
|
-
for (const subselect of
|
|
57609
|
+
for (const subselect of selection.selectionSet?.selections || []) {
|
|
57434
57610
|
this.fields[key].selection.add(subselect);
|
|
57435
57611
|
}
|
|
57612
|
+
this.fields[key].selection.fragmentSpreads = {
|
|
57613
|
+
...this.collectFragmentSpreads(selection.selectionSet?.selections ?? []),
|
|
57614
|
+
...this.fields[key].selection.fragmentSpreads
|
|
57615
|
+
};
|
|
57436
57616
|
return;
|
|
57437
57617
|
}
|
|
57438
|
-
if (
|
|
57439
|
-
for (const subselect of
|
|
57618
|
+
if (selection.kind === "InlineFragment" && !selection.typeCondition) {
|
|
57619
|
+
for (const subselect of selection.selectionSet.selections) {
|
|
57440
57620
|
this.add(subselect);
|
|
57441
57621
|
}
|
|
57442
57622
|
}
|
|
57443
|
-
if (
|
|
57444
|
-
this.walkInlineFragment(
|
|
57623
|
+
if (selection.kind === "InlineFragment" && selection.typeCondition) {
|
|
57624
|
+
this.walkInlineFragment(selection);
|
|
57445
57625
|
return;
|
|
57446
57626
|
}
|
|
57447
|
-
if (
|
|
57448
|
-
this.fragmentSpreads[selection2.name.value] = selection2;
|
|
57627
|
+
if (selection.kind === "FragmentSpread") {
|
|
57449
57628
|
let includeFragments = this.config.defaultFragmentMasking === "disable";
|
|
57450
|
-
const maskEnableDirective =
|
|
57629
|
+
const maskEnableDirective = selection.directives?.find(
|
|
57451
57630
|
({ name }) => name.value === this.config.maskEnableDirective
|
|
57452
57631
|
);
|
|
57453
57632
|
if (maskEnableDirective) {
|
|
57454
57633
|
includeFragments = false;
|
|
57455
57634
|
}
|
|
57456
|
-
const maskDisableDirective =
|
|
57635
|
+
const maskDisableDirective = selection.directives?.find(
|
|
57457
57636
|
({ name }) => name.value === this.config.maskDisableDirective
|
|
57458
57637
|
);
|
|
57459
57638
|
if (maskDisableDirective) {
|
|
@@ -57462,14 +57641,17 @@ var FieldCollection = class {
|
|
|
57462
57641
|
if (this.ignoreMaskDisable) {
|
|
57463
57642
|
includeFragments = true;
|
|
57464
57643
|
}
|
|
57465
|
-
if (
|
|
57644
|
+
if (this.keepFragmentSpreadNodes) {
|
|
57645
|
+
this.fragmentSpreads[selection.name.value] = selection;
|
|
57646
|
+
}
|
|
57647
|
+
if (!includeFragments) {
|
|
57466
57648
|
return;
|
|
57467
57649
|
}
|
|
57468
|
-
const definition = this.fragmentDefinitions[
|
|
57650
|
+
const definition = this.fragmentDefinitions[selection.name.value];
|
|
57469
57651
|
if (!definition) {
|
|
57470
57652
|
throw new HoudiniError({
|
|
57471
57653
|
filepath: this.filepath,
|
|
57472
|
-
message: "Could not find referenced fragment definition: " +
|
|
57654
|
+
message: "Could not find referenced fragment definition: " + selection.name.value + "\n" + JSON.stringify(Object.keys(this.fragmentDefinitions), null, 4)
|
|
57473
57655
|
});
|
|
57474
57656
|
}
|
|
57475
57657
|
this.add({
|
|
@@ -57488,37 +57670,67 @@ var FieldCollection = class {
|
|
|
57488
57670
|
});
|
|
57489
57671
|
}
|
|
57490
57672
|
}
|
|
57673
|
+
collectFragmentSpreads(selections, result = {}) {
|
|
57674
|
+
for (const selection of selections) {
|
|
57675
|
+
if (selection.kind === "Field") {
|
|
57676
|
+
continue;
|
|
57677
|
+
}
|
|
57678
|
+
if (selection.kind === "InlineFragment") {
|
|
57679
|
+
this.collectFragmentSpreads(selection.selectionSet.selections, result);
|
|
57680
|
+
continue;
|
|
57681
|
+
}
|
|
57682
|
+
if (selection.kind === "FragmentSpread") {
|
|
57683
|
+
result[selection.name.value] = selection;
|
|
57684
|
+
continue;
|
|
57685
|
+
}
|
|
57686
|
+
}
|
|
57687
|
+
return result;
|
|
57688
|
+
}
|
|
57491
57689
|
toSelectionSet() {
|
|
57492
|
-
return Object.values(this.inlineFragments).flatMap((
|
|
57493
|
-
if (
|
|
57690
|
+
return Object.values(this.inlineFragments).flatMap((fragment2) => {
|
|
57691
|
+
if (fragment2.selection.size === 0) {
|
|
57494
57692
|
return [];
|
|
57495
57693
|
}
|
|
57496
|
-
|
|
57497
|
-
...
|
|
57694
|
+
fragment2.astNode = {
|
|
57695
|
+
...fragment2.astNode,
|
|
57498
57696
|
selectionSet: {
|
|
57499
|
-
...
|
|
57500
|
-
selections:
|
|
57697
|
+
...fragment2.astNode.selectionSet,
|
|
57698
|
+
selections: fragment2.selection.toSelectionSet()
|
|
57501
57699
|
}
|
|
57502
57700
|
};
|
|
57503
|
-
return [
|
|
57701
|
+
return [fragment2.astNode];
|
|
57504
57702
|
}).concat(
|
|
57505
57703
|
Object.values(this.fields).map((field) => {
|
|
57506
|
-
|
|
57507
|
-
field.astNode
|
|
57508
|
-
|
|
57509
|
-
|
|
57704
|
+
return {
|
|
57705
|
+
...field.astNode,
|
|
57706
|
+
selectionSet: field.astNode.selectionSet ? {
|
|
57707
|
+
kind: "SelectionSet",
|
|
57708
|
+
selections: field.selection.toSelectionSet()
|
|
57709
|
+
} : void 0
|
|
57710
|
+
};
|
|
57711
|
+
})
|
|
57712
|
+
).concat(
|
|
57713
|
+
Object.values(this.fragmentSpreads).map((spread) => {
|
|
57714
|
+
return {
|
|
57715
|
+
kind: "FragmentSpread",
|
|
57716
|
+
name: {
|
|
57717
|
+
kind: "Name",
|
|
57718
|
+
value: spread.name.value
|
|
57719
|
+
},
|
|
57720
|
+
directives: spread.directives
|
|
57721
|
+
};
|
|
57510
57722
|
})
|
|
57511
|
-
)
|
|
57723
|
+
);
|
|
57512
57724
|
}
|
|
57513
|
-
walkInlineFragment(
|
|
57514
|
-
const key =
|
|
57725
|
+
walkInlineFragment(selection) {
|
|
57726
|
+
const key = selection.typeCondition.name.value;
|
|
57515
57727
|
if (!this.inlineFragments[key]) {
|
|
57516
57728
|
this.inlineFragments[key] = {
|
|
57517
|
-
astNode:
|
|
57729
|
+
astNode: selection,
|
|
57518
57730
|
selection: this.empty()
|
|
57519
57731
|
};
|
|
57520
57732
|
}
|
|
57521
|
-
for (const subselect of
|
|
57733
|
+
for (const subselect of selection.selectionSet.selections || []) {
|
|
57522
57734
|
if (subselect.kind !== "InlineFragment" || !subselect.typeCondition) {
|
|
57523
57735
|
this.inlineFragments[key].selection.add(subselect);
|
|
57524
57736
|
continue;
|
|
@@ -57532,8 +57744,8 @@ var FieldCollection = class {
|
|
|
57532
57744
|
fragmentDefinitions: this.fragmentDefinitions,
|
|
57533
57745
|
selections: [],
|
|
57534
57746
|
filepath: this.filepath,
|
|
57535
|
-
|
|
57536
|
-
|
|
57747
|
+
ignoreMaskDisable: this.ignoreMaskDisable,
|
|
57748
|
+
keepFragmentSpreadNodes: this.keepFragmentSpreadNodes
|
|
57537
57749
|
});
|
|
57538
57750
|
}
|
|
57539
57751
|
};
|
|
@@ -57611,13 +57823,13 @@ function murmurHash(str) {
|
|
|
57611
57823
|
// src/codegen/transforms/fragmentVariables.ts
|
|
57612
57824
|
var graphql3 = __toESM(require_graphql2(), 1);
|
|
57613
57825
|
|
|
57614
|
-
// src/codegen/transforms/
|
|
57826
|
+
// src/codegen/transforms/collectDefinitions.ts
|
|
57615
57827
|
var import_graphql = __toESM(require_graphql2(), 1);
|
|
57616
57828
|
async function includeFragmentDefinitions(config2, documents) {
|
|
57617
|
-
const fragments =
|
|
57829
|
+
const fragments = collectDefinitions(config2, documents);
|
|
57618
57830
|
for (const [index, { name, document, filename }] of documents.entries()) {
|
|
57619
57831
|
const operation = document.definitions.find(
|
|
57620
|
-
(
|
|
57832
|
+
(def) => def.kind === import_graphql.Kind.OPERATION_DEFINITION || def.kind === "FragmentDefinition"
|
|
57621
57833
|
);
|
|
57622
57834
|
if (!operation) {
|
|
57623
57835
|
continue;
|
|
@@ -57636,7 +57848,7 @@ async function includeFragmentDefinitions(config2, documents) {
|
|
|
57636
57848
|
};
|
|
57637
57849
|
}
|
|
57638
57850
|
}
|
|
57639
|
-
function
|
|
57851
|
+
function collectDefinitions(config2, docs) {
|
|
57640
57852
|
return docs.reduce((acc, doc) => {
|
|
57641
57853
|
const definitions = doc.document.definitions.reduce(
|
|
57642
57854
|
(prev, definition) => definition.kind !== "FragmentDefinition" ? prev : {
|
|
@@ -57660,11 +57872,11 @@ function findRequiredFragments(selectionSet) {
|
|
|
57660
57872
|
return [];
|
|
57661
57873
|
}
|
|
57662
57874
|
const referencedFragments = [];
|
|
57663
|
-
for (const
|
|
57664
|
-
if (
|
|
57665
|
-
referencedFragments.push(
|
|
57666
|
-
} else if (
|
|
57667
|
-
referencedFragments.push(...findRequiredFragments(
|
|
57875
|
+
for (const selection of selectionSet.selections) {
|
|
57876
|
+
if (selection.kind === import_graphql.Kind.FRAGMENT_SPREAD) {
|
|
57877
|
+
referencedFragments.push(selection.name.value);
|
|
57878
|
+
} else if (selection.selectionSet) {
|
|
57879
|
+
referencedFragments.push(...findRequiredFragments(selection.selectionSet));
|
|
57668
57880
|
}
|
|
57669
57881
|
}
|
|
57670
57882
|
return referencedFragments;
|
|
@@ -57697,7 +57909,7 @@ function flattenFragments(filepath, operation, fragments) {
|
|
|
57697
57909
|
// src/codegen/transforms/fragmentVariables.ts
|
|
57698
57910
|
var GraphqlKinds2 = graphql3.Kind;
|
|
57699
57911
|
async function fragmentVariables(config2, documents) {
|
|
57700
|
-
const fragments =
|
|
57912
|
+
const fragments = collectDefinitions(config2, documents);
|
|
57701
57913
|
const generatedFragments = {};
|
|
57702
57914
|
const visitedFragments = /* @__PURE__ */ new Set();
|
|
57703
57915
|
for (const doc2 of documents) {
|
|
@@ -57757,9 +57969,17 @@ function inlineFragmentArgs({
|
|
|
57757
57969
|
).reduce((acc, arg) => ({ ...acc, [arg.name]: arg }), {});
|
|
57758
57970
|
const result = graphql3.visit(document, {
|
|
57759
57971
|
FragmentSpread(node) {
|
|
57972
|
+
if (!fragmentDefinitions[node.name.value]) {
|
|
57973
|
+
throw new Error("Could not find definition for fragment" + node.name.value);
|
|
57974
|
+
}
|
|
57760
57975
|
const { definition } = fragmentDefinitions[node.name.value];
|
|
57761
57976
|
let { args, hash } = collectWithArguments(config2, filepath, node, scope);
|
|
57762
57977
|
const newFragmentName = `${node.name.value}${hash}`;
|
|
57978
|
+
config2.registerFragmentVariablesHash({
|
|
57979
|
+
hash: newFragmentName,
|
|
57980
|
+
fragment: node.name.value,
|
|
57981
|
+
args
|
|
57982
|
+
});
|
|
57763
57983
|
if (!visitedFragments.has(newFragmentName)) {
|
|
57764
57984
|
visitedFragments.add(newFragmentName);
|
|
57765
57985
|
const defaultArguments = collectDefaultArgumentValues(config2, filepath, definition);
|
|
@@ -58158,7 +58378,7 @@ function operationObject({
|
|
|
58158
58378
|
listName,
|
|
58159
58379
|
operationKind,
|
|
58160
58380
|
type,
|
|
58161
|
-
selection
|
|
58381
|
+
selection,
|
|
58162
58382
|
filepath
|
|
58163
58383
|
}) {
|
|
58164
58384
|
let parentID;
|
|
@@ -58166,7 +58386,7 @@ function operationObject({
|
|
|
58166
58386
|
let position = config2.internalListPosition;
|
|
58167
58387
|
let allLists = config2.defaultListTarget ?? void 0;
|
|
58168
58388
|
let operationWhen;
|
|
58169
|
-
const internalDirectives =
|
|
58389
|
+
const internalDirectives = selection.directives?.filter(
|
|
58170
58390
|
(directive) => config2.isInternalDirective(directive.name.value)
|
|
58171
58391
|
);
|
|
58172
58392
|
if (internalDirectives && internalDirectives.length > 0) {
|
|
@@ -58402,7 +58622,7 @@ async function paginate(config2, documents) {
|
|
|
58402
58622
|
let fragmentName = "";
|
|
58403
58623
|
let refetchQueryName = "";
|
|
58404
58624
|
let nodeQuery = false;
|
|
58405
|
-
let
|
|
58625
|
+
let fragment2 = "";
|
|
58406
58626
|
let paginateMode = config2.defaultPaginateMode;
|
|
58407
58627
|
doc.document = graphql8.visit(doc.document, {
|
|
58408
58628
|
OperationDefinition(node) {
|
|
@@ -58445,7 +58665,7 @@ async function paginate(config2, documents) {
|
|
|
58445
58665
|
};
|
|
58446
58666
|
},
|
|
58447
58667
|
FragmentDefinition(node) {
|
|
58448
|
-
|
|
58668
|
+
fragment2 = node.typeCondition.name.value;
|
|
58449
58669
|
fragmentName = node.name.value;
|
|
58450
58670
|
refetchQueryName = config2.paginationQueryName(fragmentName);
|
|
58451
58671
|
nodeQuery = node.typeCondition.name.value !== config2.schema.getQueryType()?.name;
|
|
@@ -58492,17 +58712,17 @@ async function paginate(config2, documents) {
|
|
|
58492
58712
|
}
|
|
58493
58713
|
});
|
|
58494
58714
|
let targetType = config2.schema.getQueryType()?.name || "";
|
|
58495
|
-
if (
|
|
58715
|
+
if (fragment2) {
|
|
58496
58716
|
const nodeInterface = config2.schema.getType("Node");
|
|
58497
58717
|
if (nodeInterface) {
|
|
58498
58718
|
const { objects, interfaces } = config2.schema.getImplementations(nodeInterface);
|
|
58499
|
-
if (objects.find((obj) => obj.name ===
|
|
58719
|
+
if (objects.find((obj) => obj.name === fragment2) || interfaces.find((int) => int.name === fragment2)) {
|
|
58500
58720
|
targetType = "Node";
|
|
58501
58721
|
} else {
|
|
58502
|
-
targetType =
|
|
58722
|
+
targetType = fragment2;
|
|
58503
58723
|
}
|
|
58504
58724
|
} else {
|
|
58505
|
-
targetType =
|
|
58725
|
+
targetType = fragment2;
|
|
58506
58726
|
}
|
|
58507
58727
|
}
|
|
58508
58728
|
const pageSize = flags.first.defaultValue ?? flags.last.defaultValue ?? flags.limit.defaultValue;
|
|
@@ -58524,7 +58744,7 @@ async function paginate(config2, documents) {
|
|
|
58524
58744
|
start,
|
|
58525
58745
|
mode: paginateMode
|
|
58526
58746
|
};
|
|
58527
|
-
if (!
|
|
58747
|
+
if (!fragment2) {
|
|
58528
58748
|
continue;
|
|
58529
58749
|
}
|
|
58530
58750
|
const paginationArgs = Object.entries(flags).filter(([_, { enabled }]) => enabled).map(([key, value]) => ({ name: key, ...value }));
|
|
@@ -58545,15 +58765,22 @@ async function paginate(config2, documents) {
|
|
|
58545
58765
|
["arguments"]: paginationArgs.map(
|
|
58546
58766
|
({ name }) => variableAsArgument(name)
|
|
58547
58767
|
)
|
|
58768
|
+
},
|
|
58769
|
+
{
|
|
58770
|
+
kind: graphql8.Kind.DIRECTIVE,
|
|
58771
|
+
name: {
|
|
58772
|
+
kind: "Name",
|
|
58773
|
+
value: config2.maskDisableDirective
|
|
58774
|
+
}
|
|
58548
58775
|
}
|
|
58549
58776
|
]
|
|
58550
58777
|
}
|
|
58551
58778
|
];
|
|
58552
|
-
const keys = config2.keyFieldsForType(!nodeQuery ? config2.schema.getQueryType()?.name || "" :
|
|
58553
|
-
if (
|
|
58779
|
+
const keys = config2.keyFieldsForType(!nodeQuery ? config2.schema.getQueryType()?.name || "" : fragment2).flatMap((key) => {
|
|
58780
|
+
if (fragment2 === config2.schema.getQueryType()?.name) {
|
|
58554
58781
|
return [];
|
|
58555
58782
|
}
|
|
58556
|
-
const fragmentType = config2.schema.getType(
|
|
58783
|
+
const fragmentType = config2.schema.getType(fragment2);
|
|
58557
58784
|
const { type, wrappers } = unwrapType(
|
|
58558
58785
|
config2,
|
|
58559
58786
|
fragmentType.getFields()[key].type
|
|
@@ -58565,7 +58792,7 @@ async function paginate(config2, documents) {
|
|
|
58565
58792
|
}
|
|
58566
58793
|
];
|
|
58567
58794
|
});
|
|
58568
|
-
const typeConfig = config2.typeConfig?.[
|
|
58795
|
+
const typeConfig = config2.typeConfig?.[fragment2];
|
|
58569
58796
|
const queryDoc = {
|
|
58570
58797
|
kind: graphql8.Kind.DOCUMENT,
|
|
58571
58798
|
definitions: [
|
|
@@ -58907,7 +59134,7 @@ async function addListFragments(config2, documents) {
|
|
|
58907
59134
|
);
|
|
58908
59135
|
const targetField = ancestors[ancestors.length - 1];
|
|
58909
59136
|
const targetFieldDefinition = parentType.getFields()[targetField.name.value];
|
|
58910
|
-
const { selection
|
|
59137
|
+
const { selection, type, connection } = connectionSelection(
|
|
58911
59138
|
config2,
|
|
58912
59139
|
targetFieldDefinition,
|
|
58913
59140
|
parentTypeFromAncestors(
|
|
@@ -58918,7 +59145,7 @@ async function addListFragments(config2, documents) {
|
|
|
58918
59145
|
ancestors[ancestors.length - 1].selectionSet
|
|
58919
59146
|
);
|
|
58920
59147
|
lists[nameArg.value.value] = {
|
|
58921
|
-
selection
|
|
59148
|
+
selection,
|
|
58922
59149
|
type,
|
|
58923
59150
|
filename: doc.filename
|
|
58924
59151
|
};
|
|
@@ -58996,14 +59223,14 @@ async function addListFragments(config2, documents) {
|
|
|
58996
59223
|
const generatedDoc = {
|
|
58997
59224
|
kind: graphql9.Kind.DOCUMENT,
|
|
58998
59225
|
definitions: Object.entries(lists).flatMap(
|
|
58999
|
-
([name, { selection
|
|
59226
|
+
([name, { selection, type }]) => {
|
|
59000
59227
|
const schemaType = config2.schema.getType(type.name);
|
|
59001
|
-
if (!
|
|
59228
|
+
if (!selection) {
|
|
59002
59229
|
throw new HoudiniError({ message: "Lists must have a selection" });
|
|
59003
59230
|
}
|
|
59004
59231
|
const fragmentSelection = {
|
|
59005
59232
|
kind: graphql9.Kind.SELECTION_SET,
|
|
59006
|
-
selections: [...
|
|
59233
|
+
selections: [...selection.selections]
|
|
59007
59234
|
};
|
|
59008
59235
|
if (schemaType && fragmentSelection && !fragmentSelection?.selections.find(
|
|
59009
59236
|
(field) => field.kind === "Field" && config2.keyFieldsForType(type.name).includes(field.name.value)
|
|
@@ -59095,7 +59322,7 @@ async function addListFragments(config2, documents) {
|
|
|
59095
59322
|
artifact: null
|
|
59096
59323
|
});
|
|
59097
59324
|
}
|
|
59098
|
-
function connectionSelection(config2, field, type,
|
|
59325
|
+
function connectionSelection(config2, field, type, selection) {
|
|
59099
59326
|
const fieldArgs = field.args.reduce(
|
|
59100
59327
|
(args, arg) => ({
|
|
59101
59328
|
...args,
|
|
@@ -59104,34 +59331,34 @@ function connectionSelection(config2, field, type, selection2) {
|
|
|
59104
59331
|
{}
|
|
59105
59332
|
);
|
|
59106
59333
|
if (fieldArgs["limit"]) {
|
|
59107
|
-
return { selection
|
|
59334
|
+
return { selection, type, connection: false, error: null };
|
|
59108
59335
|
}
|
|
59109
59336
|
const forwardPagination = fieldArgs["first"] === "Int" && ["Cursor", "String"].includes(fieldArgs["after"]);
|
|
59110
59337
|
const backwardsPagination = fieldArgs["last"] === "Int" && ["Cursor", "String"].includes(fieldArgs["before"]);
|
|
59111
59338
|
if (!forwardPagination && !backwardsPagination) {
|
|
59112
|
-
return { selection
|
|
59339
|
+
return { selection, type, connection: false, error: missingPaginationArgMessage(config2) };
|
|
59113
59340
|
}
|
|
59114
|
-
const edgesField =
|
|
59115
|
-
(
|
|
59341
|
+
const edgesField = selection?.selections.find(
|
|
59342
|
+
(selection2) => selection2.kind === "Field" && selection2.name.value === "edges"
|
|
59116
59343
|
);
|
|
59117
59344
|
if (!edgesField) {
|
|
59118
|
-
return { selection
|
|
59345
|
+
return { selection, type, connection: false, error: missingEdgeSelectionMessage(config2) };
|
|
59119
59346
|
}
|
|
59120
59347
|
const nodeSelection = edgesField.selectionSet?.selections.find(
|
|
59121
|
-
(
|
|
59348
|
+
(selection2) => selection2.kind === "Field" && selection2.name.value === "node"
|
|
59122
59349
|
);
|
|
59123
59350
|
if (!nodeSelection.selectionSet) {
|
|
59124
|
-
return { selection
|
|
59351
|
+
return { selection, type, connection: false, error: missingNodeSelectionMessage(config2) };
|
|
59125
59352
|
}
|
|
59126
59353
|
const edgeField = unwrapType(config2, field.type).type.getFields()["edges"];
|
|
59127
59354
|
const { wrappers, type: edgeFieldType } = unwrapType(config2, edgeField.type);
|
|
59128
59355
|
const list = wrappers[wrappers.length - 2] === "List" /* List */;
|
|
59129
59356
|
if (!list) {
|
|
59130
|
-
return { selection
|
|
59357
|
+
return { selection, type, connection: false, error: edgeInvalidTypeMessage(config2) };
|
|
59131
59358
|
}
|
|
59132
59359
|
const nodeField = edgeFieldType.getFields()["node"];
|
|
59133
59360
|
if (!nodeField) {
|
|
59134
|
-
return { selection
|
|
59361
|
+
return { selection, type, connection: false, error: nodeNotDefinedMessage(config2) };
|
|
59135
59362
|
}
|
|
59136
59363
|
return {
|
|
59137
59364
|
selection: nodeSelection.selectionSet,
|
|
@@ -59210,59 +59437,45 @@ function fieldKey(config2, field) {
|
|
|
59210
59437
|
}
|
|
59211
59438
|
|
|
59212
59439
|
// src/codegen/generators/artifacts/selection.ts
|
|
59213
|
-
function
|
|
59440
|
+
function selection_default(args) {
|
|
59441
|
+
const typeMap = {};
|
|
59442
|
+
const abstractTypes = [];
|
|
59443
|
+
return mergeSelection({
|
|
59444
|
+
object: prepareSelection({ ...args, typeMap, abstractTypes }),
|
|
59445
|
+
filepath: args.filepath,
|
|
59446
|
+
typeMap,
|
|
59447
|
+
abstractTypes
|
|
59448
|
+
});
|
|
59449
|
+
}
|
|
59450
|
+
function prepareSelection({
|
|
59214
59451
|
config: config2,
|
|
59215
59452
|
filepath,
|
|
59216
59453
|
rootType,
|
|
59217
59454
|
selections,
|
|
59218
59455
|
operations,
|
|
59219
59456
|
path: path2 = [],
|
|
59220
|
-
includeFragments,
|
|
59221
59457
|
document,
|
|
59222
|
-
inConnection
|
|
59458
|
+
inConnection,
|
|
59459
|
+
typeMap,
|
|
59460
|
+
abstractTypes
|
|
59223
59461
|
}) {
|
|
59224
59462
|
let object = {};
|
|
59225
|
-
const typeMap = {};
|
|
59226
|
-
const abstractTypes = [];
|
|
59227
59463
|
for (const field of selections) {
|
|
59228
|
-
if (field.kind === "
|
|
59229
|
-
const fragmentDefinition = document.document.definitions.find(
|
|
59230
|
-
(defn) => defn.kind === "FragmentDefinition" && defn.name.value === field.name.value
|
|
59231
|
-
);
|
|
59232
|
-
if (!fragmentDefinition) {
|
|
59233
|
-
throw new HoudiniError({
|
|
59234
|
-
filepath,
|
|
59235
|
-
message: "selection: could not find definition for fragment " + field.name.value
|
|
59236
|
-
});
|
|
59237
|
-
}
|
|
59238
|
-
object = deepMerge(
|
|
59239
|
-
filepath,
|
|
59240
|
-
object,
|
|
59241
|
-
selection({
|
|
59242
|
-
config: config2,
|
|
59243
|
-
filepath,
|
|
59244
|
-
rootType: fragmentDefinition.typeCondition.name.value,
|
|
59245
|
-
operations,
|
|
59246
|
-
selections: fragmentDefinition.selectionSet.selections,
|
|
59247
|
-
path: path2,
|
|
59248
|
-
includeFragments,
|
|
59249
|
-
document
|
|
59250
|
-
})
|
|
59251
|
-
);
|
|
59252
|
-
} else if (field.kind === "InlineFragment") {
|
|
59464
|
+
if (field.kind === "InlineFragment") {
|
|
59253
59465
|
if (!field.typeCondition || field.typeCondition.name.value === rootType) {
|
|
59254
59466
|
object.fields = deepMerge(
|
|
59255
59467
|
filepath,
|
|
59256
59468
|
object.fields || {},
|
|
59257
|
-
|
|
59469
|
+
prepareSelection({
|
|
59258
59470
|
config: config2,
|
|
59259
59471
|
filepath,
|
|
59260
59472
|
rootType: field.typeCondition?.name.value || rootType,
|
|
59261
59473
|
operations,
|
|
59262
59474
|
selections: field.selectionSet.selections,
|
|
59263
59475
|
path: path2,
|
|
59264
|
-
|
|
59265
|
-
|
|
59476
|
+
document,
|
|
59477
|
+
typeMap,
|
|
59478
|
+
abstractTypes
|
|
59266
59479
|
}).fields || {}
|
|
59267
59480
|
);
|
|
59268
59481
|
} else {
|
|
@@ -59300,15 +59513,16 @@ function selection({
|
|
|
59300
59513
|
}
|
|
59301
59514
|
object.abstractFields.fields = {
|
|
59302
59515
|
...object.abstractFields.fields,
|
|
59303
|
-
[field.typeCondition.name.value]:
|
|
59516
|
+
[field.typeCondition.name.value]: prepareSelection({
|
|
59304
59517
|
config: config2,
|
|
59305
59518
|
filepath,
|
|
59306
59519
|
rootType: field.typeCondition?.name.value || rootType,
|
|
59307
59520
|
operations,
|
|
59308
59521
|
selections: field.selectionSet.selections,
|
|
59309
59522
|
path: path2,
|
|
59310
|
-
|
|
59311
|
-
|
|
59523
|
+
document,
|
|
59524
|
+
typeMap,
|
|
59525
|
+
abstractTypes
|
|
59312
59526
|
}).fields
|
|
59313
59527
|
};
|
|
59314
59528
|
}
|
|
@@ -59329,10 +59543,14 @@ function selection({
|
|
|
59329
59543
|
}
|
|
59330
59544
|
const typeName = fieldType.toString();
|
|
59331
59545
|
const pathSoFar = path2.concat(attributeName);
|
|
59332
|
-
const
|
|
59546
|
+
const keys = config2.keyFieldsForType(rootType);
|
|
59547
|
+
let fieldObj = {
|
|
59333
59548
|
type: typeName,
|
|
59334
59549
|
keyRaw: fieldKey(config2, field)
|
|
59335
59550
|
};
|
|
59551
|
+
if (keys.includes(field.name.value)) {
|
|
59552
|
+
fieldObj.visible = true;
|
|
59553
|
+
}
|
|
59336
59554
|
if (nullable) {
|
|
59337
59555
|
fieldObj.nullable = true;
|
|
59338
59556
|
}
|
|
@@ -59380,16 +59598,17 @@ function selection({
|
|
|
59380
59598
|
}
|
|
59381
59599
|
if (field.selectionSet) {
|
|
59382
59600
|
const connectionState = paginated && document.refetch?.method === "cursor" || continueConnection;
|
|
59383
|
-
fieldObj.selection =
|
|
59601
|
+
fieldObj.selection = prepareSelection({
|
|
59384
59602
|
config: config2,
|
|
59385
59603
|
filepath,
|
|
59386
59604
|
rootType: typeName,
|
|
59387
59605
|
selections: field.selectionSet.selections,
|
|
59388
59606
|
operations,
|
|
59389
59607
|
path: pathSoFar,
|
|
59390
|
-
includeFragments,
|
|
59391
59608
|
document,
|
|
59392
|
-
inConnection: connectionState
|
|
59609
|
+
inConnection: connectionState,
|
|
59610
|
+
typeMap,
|
|
59611
|
+
abstractTypes
|
|
59393
59612
|
});
|
|
59394
59613
|
}
|
|
59395
59614
|
if (field.arguments?.length && fieldObj.list) {
|
|
@@ -59404,12 +59623,29 @@ function selection({
|
|
|
59404
59623
|
if (graphql11.isInterfaceType(fieldType) || graphql11.isUnionType(fieldType)) {
|
|
59405
59624
|
fieldObj.abstract = true;
|
|
59406
59625
|
}
|
|
59626
|
+
if (object.fields?.[attributeName]) {
|
|
59627
|
+
fieldObj = deepMerge(filepath, object.fields[attributeName], fieldObj);
|
|
59628
|
+
}
|
|
59407
59629
|
object.fields = {
|
|
59408
59630
|
...object.fields,
|
|
59409
59631
|
[attributeName]: fieldObj
|
|
59410
59632
|
};
|
|
59633
|
+
} else if (field.kind === "FragmentSpread") {
|
|
59634
|
+
const { fragment: fragment2, args } = config2.getFragmentVariablesHash(field.name.value);
|
|
59635
|
+
object.fragments = {
|
|
59636
|
+
...object.fragments,
|
|
59637
|
+
[fragment2]: args ?? {}
|
|
59638
|
+
};
|
|
59411
59639
|
}
|
|
59412
59640
|
}
|
|
59641
|
+
return object;
|
|
59642
|
+
}
|
|
59643
|
+
function mergeSelection({
|
|
59644
|
+
filepath,
|
|
59645
|
+
object,
|
|
59646
|
+
typeMap,
|
|
59647
|
+
abstractTypes
|
|
59648
|
+
}) {
|
|
59413
59649
|
if (Object.keys(object.fields || {}).length > 0 && object.abstractFields && Object.keys(object.abstractFields.fields).length > 0) {
|
|
59414
59650
|
for (const [typeName, possibles] of Object.entries(typeMap)) {
|
|
59415
59651
|
let overlap = false;
|
|
@@ -59417,8 +59653,8 @@ function selection({
|
|
|
59417
59653
|
if (object.abstractFields.fields[typeName]) {
|
|
59418
59654
|
object.abstractFields.fields[typeName] = deepMerge(
|
|
59419
59655
|
filepath,
|
|
59420
|
-
object.abstractFields.fields[typeName]
|
|
59421
|
-
object.abstractFields.fields[possible]
|
|
59656
|
+
object.abstractFields.fields[typeName] ?? {},
|
|
59657
|
+
object.abstractFields.fields[possible] ?? {}
|
|
59422
59658
|
);
|
|
59423
59659
|
overlap = true;
|
|
59424
59660
|
}
|
|
@@ -59449,6 +59685,30 @@ function selection({
|
|
|
59449
59685
|
}
|
|
59450
59686
|
}
|
|
59451
59687
|
}
|
|
59688
|
+
for (const [key, value] of Object.entries(object.fields ?? {})) {
|
|
59689
|
+
const selection = value.selection;
|
|
59690
|
+
if (selection) {
|
|
59691
|
+
mergeSelection({
|
|
59692
|
+
filepath,
|
|
59693
|
+
typeMap,
|
|
59694
|
+
abstractTypes,
|
|
59695
|
+
object: selection
|
|
59696
|
+
});
|
|
59697
|
+
}
|
|
59698
|
+
}
|
|
59699
|
+
for (const [type, selection] of Object.entries(object.abstractFields?.fields ?? {})) {
|
|
59700
|
+
for (const [key, value] of Object.entries(selection ?? {})) {
|
|
59701
|
+
const selection2 = value.selection;
|
|
59702
|
+
if (selection2) {
|
|
59703
|
+
mergeSelection({
|
|
59704
|
+
filepath,
|
|
59705
|
+
typeMap,
|
|
59706
|
+
abstractTypes,
|
|
59707
|
+
object: selection2
|
|
59708
|
+
});
|
|
59709
|
+
}
|
|
59710
|
+
}
|
|
59711
|
+
}
|
|
59452
59712
|
return object;
|
|
59453
59713
|
}
|
|
59454
59714
|
|
|
@@ -59513,7 +59773,12 @@ function artifactGenerator(stats) {
|
|
|
59513
59773
|
writeIndexFile(config2, docs)
|
|
59514
59774
|
].concat(
|
|
59515
59775
|
docs.map(async (doc) => {
|
|
59516
|
-
const {
|
|
59776
|
+
const {
|
|
59777
|
+
document,
|
|
59778
|
+
name,
|
|
59779
|
+
generateArtifact,
|
|
59780
|
+
originalParsed
|
|
59781
|
+
} = doc;
|
|
59517
59782
|
if (!generateArtifact) {
|
|
59518
59783
|
return;
|
|
59519
59784
|
}
|
|
@@ -59552,6 +59817,16 @@ function artifactGenerator(stats) {
|
|
|
59552
59817
|
);
|
|
59553
59818
|
let rootType = "";
|
|
59554
59819
|
let selectionSet;
|
|
59820
|
+
let originalSelectionSet = null;
|
|
59821
|
+
const fragmentDefinitions = doc.document.definitions.filter(
|
|
59822
|
+
(definition) => definition.kind === "FragmentDefinition"
|
|
59823
|
+
).reduce(
|
|
59824
|
+
(prev, definition) => ({
|
|
59825
|
+
...prev,
|
|
59826
|
+
[definition.name.value]: definition
|
|
59827
|
+
}),
|
|
59828
|
+
{}
|
|
59829
|
+
);
|
|
59555
59830
|
if (docKind !== ArtifactKind.Fragment) {
|
|
59556
59831
|
const operation = operations[0];
|
|
59557
59832
|
if (operation.operation === "query") {
|
|
@@ -59568,9 +59843,12 @@ function artifactGenerator(stats) {
|
|
|
59568
59843
|
});
|
|
59569
59844
|
}
|
|
59570
59845
|
selectionSet = operation.selectionSet;
|
|
59846
|
+
if (originalParsed.definitions[0].kind === "OperationDefinition") {
|
|
59847
|
+
originalSelectionSet = originalParsed.definitions[0].selectionSet;
|
|
59848
|
+
}
|
|
59571
59849
|
} else {
|
|
59572
59850
|
const matchingFragment = fragments.find(
|
|
59573
|
-
(
|
|
59851
|
+
(fragment2) => fragment2.name.value === name
|
|
59574
59852
|
);
|
|
59575
59853
|
if (!matchingFragment) {
|
|
59576
59854
|
throw new HoudiniError({
|
|
@@ -59580,6 +59858,12 @@ function artifactGenerator(stats) {
|
|
|
59580
59858
|
}
|
|
59581
59859
|
rootType = matchingFragment.typeCondition.name.value;
|
|
59582
59860
|
selectionSet = matchingFragment.selectionSet;
|
|
59861
|
+
if (originalParsed.definitions[0].kind === "FragmentDefinition") {
|
|
59862
|
+
originalSelectionSet = originalParsed.definitions[0].selectionSet;
|
|
59863
|
+
}
|
|
59864
|
+
}
|
|
59865
|
+
if (!originalSelectionSet) {
|
|
59866
|
+
throw new Error("Not original selection set!");
|
|
59583
59867
|
}
|
|
59584
59868
|
let inputs = operations[0]?.variableDefinitions;
|
|
59585
59869
|
let directive = fragments[0]?.directives?.find(
|
|
@@ -59588,21 +59872,18 @@ function artifactGenerator(stats) {
|
|
|
59588
59872
|
if (docKind === ArtifactKind.Fragment && directive) {
|
|
59589
59873
|
inputs = fragmentArgumentsDefinitions(config2, doc.filename, fragments[0]);
|
|
59590
59874
|
}
|
|
59591
|
-
const
|
|
59875
|
+
const mask = selection_default({
|
|
59592
59876
|
config: config2,
|
|
59593
59877
|
filepath: doc.filename,
|
|
59594
|
-
|
|
59595
|
-
|
|
59596
|
-
|
|
59597
|
-
|
|
59598
|
-
|
|
59599
|
-
|
|
59600
|
-
|
|
59601
|
-
|
|
59602
|
-
|
|
59603
|
-
),
|
|
59604
|
-
ignoreMaskDisable: docKind === "HoudiniQuery",
|
|
59605
|
-
applyFragments: docKind !== "HoudiniFragment"
|
|
59878
|
+
rootType,
|
|
59879
|
+
operations: {},
|
|
59880
|
+
document: doc,
|
|
59881
|
+
selections: flattenSelections({
|
|
59882
|
+
config: config2,
|
|
59883
|
+
filepath: doc.filename,
|
|
59884
|
+
selections: selectionSet.selections,
|
|
59885
|
+
fragmentDefinitions
|
|
59886
|
+
})
|
|
59606
59887
|
});
|
|
59607
59888
|
let artifact = {
|
|
59608
59889
|
name,
|
|
@@ -59611,21 +59892,29 @@ function artifactGenerator(stats) {
|
|
|
59611
59892
|
refetch: doc.refetch,
|
|
59612
59893
|
raw: rawString,
|
|
59613
59894
|
rootType,
|
|
59614
|
-
selection:
|
|
59895
|
+
selection: selection_default({
|
|
59615
59896
|
config: config2,
|
|
59616
59897
|
filepath: doc.filename,
|
|
59617
59898
|
rootType,
|
|
59618
|
-
selections:
|
|
59899
|
+
selections: flattenSelections({
|
|
59900
|
+
config: config2,
|
|
59901
|
+
filepath: doc.filename,
|
|
59902
|
+
selections: selectionSet.selections,
|
|
59903
|
+
fragmentDefinitions,
|
|
59904
|
+
ignoreMaskDisable: docKind !== "HoudiniFragment",
|
|
59905
|
+
keepFragmentSpreadNodes: true
|
|
59906
|
+
}),
|
|
59619
59907
|
operations: operationsByPath(
|
|
59620
59908
|
config2,
|
|
59621
59909
|
doc.filename,
|
|
59622
59910
|
operations[0],
|
|
59623
59911
|
filterTypes
|
|
59624
59912
|
),
|
|
59625
|
-
includeFragments: docKind !== "HoudiniFragment",
|
|
59626
59913
|
document: doc
|
|
59627
|
-
})
|
|
59914
|
+
}),
|
|
59915
|
+
pluginData: {}
|
|
59628
59916
|
};
|
|
59917
|
+
applyMask(config2, artifact.selection, mask);
|
|
59629
59918
|
artifact.pluginData = {};
|
|
59630
59919
|
for (const plugin2 of config2.plugins) {
|
|
59631
59920
|
if (!plugin2.artifactData) {
|
|
@@ -59702,6 +59991,49 @@ function artifactGenerator(stats) {
|
|
|
59702
59991
|
stats.deleted = await cleanupFiles(config2.artifactDirectory, listOfArtifacts);
|
|
59703
59992
|
};
|
|
59704
59993
|
}
|
|
59994
|
+
function applyMask(config2, target, mask) {
|
|
59995
|
+
for (const [fieldName, value] of Object.entries(mask.fields ?? {})) {
|
|
59996
|
+
const targetSelection = target.fields?.[fieldName];
|
|
59997
|
+
if (!targetSelection || !mask.fields) {
|
|
59998
|
+
continue;
|
|
59999
|
+
}
|
|
60000
|
+
targetSelection.visible = true;
|
|
60001
|
+
if (targetSelection.selection && value.selection) {
|
|
60002
|
+
applyMask(config2, targetSelection.selection, value.selection);
|
|
60003
|
+
}
|
|
60004
|
+
}
|
|
60005
|
+
for (const [type, selection] of Object.entries(mask.abstractFields?.fields ?? {})) {
|
|
60006
|
+
if (!selection) {
|
|
60007
|
+
continue;
|
|
60008
|
+
}
|
|
60009
|
+
if (target.abstractFields?.fields[type]) {
|
|
60010
|
+
applyMask(config2, { fields: target.abstractFields.fields[type] }, { fields: selection });
|
|
60011
|
+
}
|
|
60012
|
+
const targetType = config2.schema.getType(type);
|
|
60013
|
+
if (!targetType) {
|
|
60014
|
+
continue;
|
|
60015
|
+
}
|
|
60016
|
+
if (graphql12.isAbstractType(targetType)) {
|
|
60017
|
+
for (const possible of config2.schema.getPossibleTypes(targetType)) {
|
|
60018
|
+
if (target.abstractFields?.fields[possible.name]) {
|
|
60019
|
+
applyMask(
|
|
60020
|
+
config2,
|
|
60021
|
+
{ fields: target.abstractFields.fields[possible.name] },
|
|
60022
|
+
{ fields: selection }
|
|
60023
|
+
);
|
|
60024
|
+
}
|
|
60025
|
+
}
|
|
60026
|
+
}
|
|
60027
|
+
const mappedType = target.abstractFields?.typeMap[type];
|
|
60028
|
+
if (target.abstractFields && mappedType && target.abstractFields.fields[mappedType]) {
|
|
60029
|
+
applyMask(
|
|
60030
|
+
config2,
|
|
60031
|
+
{ fields: target.abstractFields.fields[mappedType] },
|
|
60032
|
+
{ fields: selection }
|
|
60033
|
+
);
|
|
60034
|
+
}
|
|
60035
|
+
}
|
|
60036
|
+
}
|
|
59705
60037
|
|
|
59706
60038
|
// src/codegen/generators/runtime/graphqlFunction.ts
|
|
59707
60039
|
var recast6 = __toESM(require_main2(), 1);
|
|
@@ -60027,7 +60359,7 @@ function addReferencedInputTypes(config2, filepath, body, visitedTypes, missingS
|
|
|
60027
60359
|
var graphql16 = __toESM(require_graphql2(), 1);
|
|
60028
60360
|
var recast10 = __toESM(require_main2(), 1);
|
|
60029
60361
|
var AST10 = recast10.types.builders;
|
|
60030
|
-
var
|
|
60362
|
+
var fragmentKey2 = " $fragments";
|
|
60031
60363
|
function inlineType({
|
|
60032
60364
|
config: config2,
|
|
60033
60365
|
filepath,
|
|
@@ -60067,24 +60399,24 @@ function inlineType({
|
|
|
60067
60399
|
const rootObj = type;
|
|
60068
60400
|
const inlineFragments = {};
|
|
60069
60401
|
const selectedFields = [];
|
|
60070
|
-
for (const
|
|
60071
|
-
if (
|
|
60072
|
-
const fragmentType = config2.schema.getType(
|
|
60402
|
+
for (const selection of selections) {
|
|
60403
|
+
if (selection.kind === "InlineFragment" && selection.typeCondition) {
|
|
60404
|
+
const fragmentType = config2.schema.getType(selection.typeCondition.name.value);
|
|
60073
60405
|
if (!graphql16.isInterfaceType(type) && !graphql16.isUnionType(type)) {
|
|
60074
|
-
selectedFields.push(...
|
|
60406
|
+
selectedFields.push(...selection.selectionSet.selections);
|
|
60075
60407
|
continue;
|
|
60076
60408
|
}
|
|
60077
60409
|
if (!graphql16.isInterfaceType(fragmentType) && !graphql16.isUnionType(fragmentType)) {
|
|
60078
60410
|
if (!inlineFragments[fragmentType.name]) {
|
|
60079
60411
|
inlineFragments[fragmentType.name] = [];
|
|
60080
60412
|
}
|
|
60081
|
-
inlineFragments[fragmentType.name].push(...
|
|
60413
|
+
inlineFragments[fragmentType.name].push(...selection.selectionSet.selections);
|
|
60082
60414
|
continue;
|
|
60083
60415
|
}
|
|
60084
60416
|
const possibleParents = config2.schema.getPossibleTypes(type).map((t) => t.name);
|
|
60085
60417
|
const freeSelections = [];
|
|
60086
60418
|
const typeSpecificSelections = {};
|
|
60087
|
-
for (const node of
|
|
60419
|
+
for (const node of selection.selectionSet.selections) {
|
|
60088
60420
|
if (node.kind !== "InlineFragment") {
|
|
60089
60421
|
freeSelections.push(node);
|
|
60090
60422
|
} else if (node.typeCondition) {
|
|
@@ -60107,23 +60439,30 @@ function inlineType({
|
|
|
60107
60439
|
);
|
|
60108
60440
|
}
|
|
60109
60441
|
}
|
|
60110
|
-
} else if (
|
|
60111
|
-
selectedFields.push(...
|
|
60442
|
+
} else if (selection.kind === "InlineFragment" && !selection.typeCondition) {
|
|
60443
|
+
selectedFields.push(...selection.selectionSet.selections);
|
|
60112
60444
|
} else {
|
|
60113
|
-
selectedFields.push(
|
|
60445
|
+
selectedFields.push(selection);
|
|
60114
60446
|
}
|
|
60115
60447
|
}
|
|
60448
|
+
const fields = Object.values(
|
|
60449
|
+
selectedFields.filter((field) => field.kind === "Field").reduce(
|
|
60450
|
+
(sel, field) => ({
|
|
60451
|
+
...sel,
|
|
60452
|
+
[field.alias?.value ?? field.name.value]: field
|
|
60453
|
+
}),
|
|
60454
|
+
{}
|
|
60455
|
+
)
|
|
60456
|
+
);
|
|
60116
60457
|
result = AST10.tsTypeLiteral([
|
|
60117
|
-
...(
|
|
60118
|
-
|
|
60119
|
-
|
|
60120
|
-
const { field } = selectionTypeInfo(config2.schema, filepath, rootObj, selection2);
|
|
60121
|
-
const attributeName = selection2.alias?.value || selection2.name.value;
|
|
60458
|
+
...fields.map((selection) => {
|
|
60459
|
+
const { field } = selectionTypeInfo(config2.schema, filepath, rootObj, selection);
|
|
60460
|
+
const attributeName = selection.alias?.value || selection.name.value;
|
|
60122
60461
|
let attributeType = inlineType({
|
|
60123
60462
|
config: config2,
|
|
60124
60463
|
filepath,
|
|
60125
60464
|
rootType: field.type,
|
|
60126
|
-
selections:
|
|
60465
|
+
selections: selection.selectionSet?.selections,
|
|
60127
60466
|
root: false,
|
|
60128
60467
|
allowReadonly,
|
|
60129
60468
|
visitedTypes,
|
|
@@ -60132,7 +60471,7 @@ function inlineType({
|
|
|
60132
60471
|
includeFragments,
|
|
60133
60472
|
allOptional
|
|
60134
60473
|
});
|
|
60135
|
-
const hasIncludeOrSkipDirective =
|
|
60474
|
+
const hasIncludeOrSkipDirective = selection.directives && selection.directives.filter(
|
|
60136
60475
|
(directive) => directive.name.value === "include" || directive.name.value === "skip"
|
|
60137
60476
|
).length > 0;
|
|
60138
60477
|
if (hasIncludeOrSkipDirective) {
|
|
@@ -60156,15 +60495,13 @@ function inlineType({
|
|
|
60156
60495
|
result.members.push(
|
|
60157
60496
|
readonlyProperty(
|
|
60158
60497
|
AST10.tsPropertySignature(
|
|
60159
|
-
AST10.
|
|
60498
|
+
AST10.stringLiteral(fragmentKey2),
|
|
60160
60499
|
AST10.tsTypeAnnotation(
|
|
60161
60500
|
AST10.tsTypeLiteral(
|
|
60162
60501
|
(fragmentSpreads || []).map(
|
|
60163
60502
|
(fragmentSpread) => AST10.tsPropertySignature(
|
|
60164
60503
|
AST10.identifier(fragmentSpread.name.value),
|
|
60165
|
-
AST10.tsTypeAnnotation(
|
|
60166
|
-
AST10.tsLiteralType(AST10.booleanLiteral(true))
|
|
60167
|
-
)
|
|
60504
|
+
AST10.tsTypeAnnotation(AST10.tsTypeLiteral([]))
|
|
60168
60505
|
)
|
|
60169
60506
|
)
|
|
60170
60507
|
)
|
|
@@ -60174,7 +60511,7 @@ function inlineType({
|
|
|
60174
60511
|
)
|
|
60175
60512
|
);
|
|
60176
60513
|
}
|
|
60177
|
-
const inlineFragmentSelections = Object.entries(inlineFragments).flatMap(([typeName,
|
|
60514
|
+
const inlineFragmentSelections = Object.entries(inlineFragments).flatMap(([typeName, fragment2]) => {
|
|
60178
60515
|
const fragmentRootType = config2.schema.getType(typeName);
|
|
60179
60516
|
if (!fragmentRootType) {
|
|
60180
60517
|
return [];
|
|
@@ -60183,7 +60520,7 @@ function inlineType({
|
|
|
60183
60520
|
config: config2,
|
|
60184
60521
|
filepath,
|
|
60185
60522
|
rootType: fragmentRootType,
|
|
60186
|
-
selections:
|
|
60523
|
+
selections: fragment2,
|
|
60187
60524
|
allowReadonly,
|
|
60188
60525
|
visitedTypes,
|
|
60189
60526
|
root,
|
|
@@ -60255,10 +60592,10 @@ function inlineType({
|
|
|
60255
60592
|
}
|
|
60256
60593
|
return result;
|
|
60257
60594
|
}
|
|
60258
|
-
function selectionTypeInfo(schema, filepath, rootType,
|
|
60259
|
-
const selectionName =
|
|
60595
|
+
function selectionTypeInfo(schema, filepath, rootType, selection) {
|
|
60596
|
+
const selectionName = selection.name.value;
|
|
60260
60597
|
let fields = {};
|
|
60261
|
-
if (
|
|
60598
|
+
if (selection.kind === "Field" && selection.name.value === "__typename") {
|
|
60262
60599
|
return {
|
|
60263
60600
|
field: {
|
|
60264
60601
|
name: "__typename",
|
|
@@ -60329,7 +60666,7 @@ async function generateDocumentTypes(config2, docs) {
|
|
|
60329
60666
|
filepath: filename,
|
|
60330
60667
|
selections: definition.selectionSet.selections,
|
|
60331
60668
|
fragmentDefinitions,
|
|
60332
|
-
|
|
60669
|
+
keepFragmentSpreadNodes: true
|
|
60333
60670
|
});
|
|
60334
60671
|
if (definition?.kind === "OperationDefinition") {
|
|
60335
60672
|
await generateOperationTypeDefs(
|
|
@@ -60553,39 +60890,26 @@ async function generateFragmentTypeDefs(config2, filepath, body, selections, def
|
|
|
60553
60890
|
if (!type) {
|
|
60554
60891
|
throw new Error("Should not get here");
|
|
60555
60892
|
}
|
|
60556
|
-
let extraExports = [];
|
|
60557
60893
|
let directive = definition.directives?.find(
|
|
60558
60894
|
(directive2) => directive2.name.value === config2.argumentsDirective
|
|
60559
60895
|
);
|
|
60560
|
-
|
|
60561
|
-
|
|
60562
|
-
|
|
60563
|
-
AST11.
|
|
60564
|
-
AST11.identifier(
|
|
60565
|
-
AST11.
|
|
60566
|
-
(
|
|
60567
|
-
|
|
60568
|
-
|
|
60569
|
-
|
|
60570
|
-
|
|
60571
|
-
|
|
60572
|
-
|
|
60573
|
-
missingScalars,
|
|
60574
|
-
definition2,
|
|
60575
|
-
body
|
|
60576
|
-
)
|
|
60577
|
-
),
|
|
60578
|
-
definition2.type.kind !== "NonNullType"
|
|
60579
|
-
);
|
|
60580
|
-
}
|
|
60581
|
-
)
|
|
60582
|
-
)
|
|
60583
|
-
)
|
|
60584
|
-
)
|
|
60585
|
-
);
|
|
60586
|
-
}
|
|
60896
|
+
let inputValue = !directive ? AST11.tsTypeLiteral([]) : AST11.tsTypeLiteral(
|
|
60897
|
+
(fragmentArgumentsDefinitions(config2, filepath, definition) || []).map(
|
|
60898
|
+
(definition2) => {
|
|
60899
|
+
return AST11.tsPropertySignature(
|
|
60900
|
+
AST11.identifier(definition2.variable.name.value),
|
|
60901
|
+
AST11.tsTypeAnnotation(
|
|
60902
|
+
tsTypeReference(config2, missingScalars, definition2, body)
|
|
60903
|
+
),
|
|
60904
|
+
definition2.type.kind !== "NonNullType"
|
|
60905
|
+
);
|
|
60906
|
+
}
|
|
60907
|
+
)
|
|
60908
|
+
);
|
|
60587
60909
|
body.push(
|
|
60588
|
-
|
|
60910
|
+
AST11.exportNamedDeclaration(
|
|
60911
|
+
AST11.tsTypeAliasDeclaration(AST11.identifier(inputTypeName), inputValue)
|
|
60912
|
+
),
|
|
60589
60913
|
AST11.exportNamedDeclaration(
|
|
60590
60914
|
AST11.tsTypeAliasDeclaration(
|
|
60591
60915
|
AST11.identifier(propTypeName),
|
|
@@ -60601,14 +60925,12 @@ async function generateFragmentTypeDefs(config2, filepath, body, selections, def
|
|
|
60601
60925
|
),
|
|
60602
60926
|
readonlyProperty(
|
|
60603
60927
|
AST11.tsPropertySignature(
|
|
60604
|
-
AST11.stringLiteral(
|
|
60928
|
+
AST11.stringLiteral(fragmentKey2),
|
|
60605
60929
|
AST11.tsTypeAnnotation(
|
|
60606
60930
|
AST11.tsTypeLiteral([
|
|
60607
60931
|
AST11.tsPropertySignature(
|
|
60608
60932
|
AST11.stringLiteral(propTypeName),
|
|
60609
|
-
AST11.tsTypeAnnotation(
|
|
60610
|
-
AST11.tsLiteralType(AST11.booleanLiteral(true))
|
|
60611
|
-
)
|
|
60933
|
+
AST11.tsTypeAnnotation(AST11.tsAnyKeyword())
|
|
60612
60934
|
)
|
|
60613
60935
|
])
|
|
60614
60936
|
)
|
|
@@ -61320,6 +61642,13 @@ async function addID(config2, documents) {
|
|
|
61320
61642
|
return;
|
|
61321
61643
|
}
|
|
61322
61644
|
return addKeysToSelection(config2, node, fragmentType);
|
|
61645
|
+
},
|
|
61646
|
+
FragmentDefinition(node) {
|
|
61647
|
+
const fragmentType = config2.schema.getType(node.typeCondition.name.value);
|
|
61648
|
+
if (!fragmentType) {
|
|
61649
|
+
return;
|
|
61650
|
+
}
|
|
61651
|
+
return addKeysToSelection(config2, node, fragmentType);
|
|
61323
61652
|
}
|
|
61324
61653
|
});
|
|
61325
61654
|
}
|
|
@@ -61338,7 +61667,7 @@ function addKeysToSelection(config2, node, fieldType) {
|
|
|
61338
61667
|
const selections = [...node.selectionSet.selections];
|
|
61339
61668
|
for (const keyField of keyFields) {
|
|
61340
61669
|
if (node.selectionSet.selections.find(
|
|
61341
|
-
(
|
|
61670
|
+
(selection) => selection.kind === "Field" && !selection.alias && selection.name.value === keyField
|
|
61342
61671
|
)) {
|
|
61343
61672
|
continue;
|
|
61344
61673
|
}
|
|
@@ -62629,7 +62958,7 @@ function pipelineTest(config2, documents, shouldPass, testBody) {
|
|
|
62629
62958
|
} catch (e) {
|
|
62630
62959
|
if (shouldPass) {
|
|
62631
62960
|
console.error(e);
|
|
62632
|
-
throw "pipeline failed when it should have passed";
|
|
62961
|
+
throw "pipeline failed when it should have passed. " + e;
|
|
62633
62962
|
}
|
|
62634
62963
|
error = e;
|
|
62635
62964
|
}
|