houdini 1.0.10 → 1.1.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 +639 -325
- package/build/cmd-esm/index.js +639 -325
- 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 +584 -321
- package/build/codegen-esm/index.js +584 -321
- 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 +638 -324
- package/build/test-esm/index.js +638 -324
- package/build/vite-cjs/index.js +637 -323
- package/build/vite-esm/index.js +637 -323
- package/package.json +2 -2
package/build/vite-cjs/index.js
CHANGED
|
@@ -7511,7 +7511,7 @@ var require_definition = __commonJS({
|
|
|
7511
7511
|
exports.assertLeafType = assertLeafType;
|
|
7512
7512
|
exports.isCompositeType = isCompositeType;
|
|
7513
7513
|
exports.assertCompositeType = assertCompositeType;
|
|
7514
|
-
exports.isAbstractType =
|
|
7514
|
+
exports.isAbstractType = isAbstractType4;
|
|
7515
7515
|
exports.assertAbstractType = assertAbstractType;
|
|
7516
7516
|
exports.GraphQLList = GraphQLList6;
|
|
7517
7517
|
exports.GraphQLNonNull = GraphQLNonNull6;
|
|
@@ -7682,11 +7682,11 @@ var require_definition = __commonJS({
|
|
|
7682
7682
|
}
|
|
7683
7683
|
return type;
|
|
7684
7684
|
}
|
|
7685
|
-
function
|
|
7685
|
+
function isAbstractType4(type) {
|
|
7686
7686
|
return isInterfaceType12(type) || isUnionType13(type);
|
|
7687
7687
|
}
|
|
7688
7688
|
function assertAbstractType(type) {
|
|
7689
|
-
if (!
|
|
7689
|
+
if (!isAbstractType4(type)) {
|
|
7690
7690
|
throw new Error("Expected ".concat((0, _inspect.default)(type), " to be a GraphQL abstract type."));
|
|
7691
7691
|
}
|
|
7692
7692
|
return type;
|
|
@@ -10950,8 +10950,8 @@ var require_KnownFragmentNamesRule = __commonJS({
|
|
|
10950
10950
|
return {
|
|
10951
10951
|
FragmentSpread: function FragmentSpread(node) {
|
|
10952
10952
|
var fragmentName = node.name.value;
|
|
10953
|
-
var
|
|
10954
|
-
if (!
|
|
10953
|
+
var fragment2 = context.getFragment(fragmentName);
|
|
10954
|
+
if (!fragment2) {
|
|
10955
10955
|
context.reportError(new _GraphQLError.GraphQLError('Unknown fragment "'.concat(fragmentName, '".'), node.name));
|
|
10956
10956
|
}
|
|
10957
10957
|
}
|
|
@@ -10987,8 +10987,8 @@ var require_NoUnusedFragmentsRule = __commonJS({
|
|
|
10987
10987
|
for (var _i2 = 0; _i2 < operationDefs.length; _i2++) {
|
|
10988
10988
|
var operation = operationDefs[_i2];
|
|
10989
10989
|
for (var _i4 = 0, _context$getRecursive2 = context.getRecursivelyReferencedFragments(operation); _i4 < _context$getRecursive2.length; _i4++) {
|
|
10990
|
-
var
|
|
10991
|
-
fragmentNameUsed[
|
|
10990
|
+
var fragment2 = _context$getRecursive2[_i4];
|
|
10991
|
+
fragmentNameUsed[fragment2.name.value] = true;
|
|
10992
10992
|
}
|
|
10993
10993
|
}
|
|
10994
10994
|
for (var _i6 = 0; _i6 < fragmentDefs.length; _i6++) {
|
|
@@ -11078,13 +11078,13 @@ var require_NoFragmentCyclesRule = __commonJS({
|
|
|
11078
11078
|
return false;
|
|
11079
11079
|
}
|
|
11080
11080
|
};
|
|
11081
|
-
function detectCycleRecursive(
|
|
11082
|
-
if (visitedFrags[
|
|
11081
|
+
function detectCycleRecursive(fragment2) {
|
|
11082
|
+
if (visitedFrags[fragment2.name.value]) {
|
|
11083
11083
|
return;
|
|
11084
11084
|
}
|
|
11085
|
-
var fragmentName =
|
|
11085
|
+
var fragmentName = fragment2.name.value;
|
|
11086
11086
|
visitedFrags[fragmentName] = true;
|
|
11087
|
-
var spreadNodes = context.getFragmentSpreads(
|
|
11087
|
+
var spreadNodes = context.getFragmentSpreads(fragment2.selectionSet);
|
|
11088
11088
|
if (spreadNodes.length === 0) {
|
|
11089
11089
|
return;
|
|
11090
11090
|
}
|
|
@@ -11905,11 +11905,11 @@ var require_OverlappingFieldsCanBeMergedRule = __commonJS({
|
|
|
11905
11905
|
return conflicts;
|
|
11906
11906
|
}
|
|
11907
11907
|
function collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentNames, comparedFragmentPairs, areMutuallyExclusive, fieldMap, fragmentName) {
|
|
11908
|
-
var
|
|
11909
|
-
if (!
|
|
11908
|
+
var fragment2 = context.getFragment(fragmentName);
|
|
11909
|
+
if (!fragment2) {
|
|
11910
11910
|
return;
|
|
11911
11911
|
}
|
|
11912
|
-
var _getReferencedFieldsA = getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames,
|
|
11912
|
+
var _getReferencedFieldsA = getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragment2), fieldMap2 = _getReferencedFieldsA[0], fragmentNames2 = _getReferencedFieldsA[1];
|
|
11913
11913
|
if (fieldMap === fieldMap2) {
|
|
11914
11914
|
return;
|
|
11915
11915
|
}
|
|
@@ -12080,38 +12080,38 @@ var require_OverlappingFieldsCanBeMergedRule = __commonJS({
|
|
|
12080
12080
|
}
|
|
12081
12081
|
return cached;
|
|
12082
12082
|
}
|
|
12083
|
-
function getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames,
|
|
12084
|
-
var cached = cachedFieldsAndFragmentNames.get(
|
|
12083
|
+
function getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragment2) {
|
|
12084
|
+
var cached = cachedFieldsAndFragmentNames.get(fragment2.selectionSet);
|
|
12085
12085
|
if (cached) {
|
|
12086
12086
|
return cached;
|
|
12087
12087
|
}
|
|
12088
|
-
var fragmentType = (0, _typeFromAST.typeFromAST)(context.getSchema(),
|
|
12089
|
-
return getFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragmentType,
|
|
12088
|
+
var fragmentType = (0, _typeFromAST.typeFromAST)(context.getSchema(), fragment2.typeCondition);
|
|
12089
|
+
return getFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragmentType, fragment2.selectionSet);
|
|
12090
12090
|
}
|
|
12091
12091
|
function _collectFieldsAndFragmentNames(context, parentType, selectionSet, nodeAndDefs, fragmentNames) {
|
|
12092
12092
|
for (var _i9 = 0, _selectionSet$selecti2 = selectionSet.selections; _i9 < _selectionSet$selecti2.length; _i9++) {
|
|
12093
|
-
var
|
|
12094
|
-
switch (
|
|
12093
|
+
var selection = _selectionSet$selecti2[_i9];
|
|
12094
|
+
switch (selection.kind) {
|
|
12095
12095
|
case _kinds.Kind.FIELD: {
|
|
12096
|
-
var fieldName =
|
|
12096
|
+
var fieldName = selection.name.value;
|
|
12097
12097
|
var fieldDef = void 0;
|
|
12098
12098
|
if ((0, _definition.isObjectType)(parentType) || (0, _definition.isInterfaceType)(parentType)) {
|
|
12099
12099
|
fieldDef = parentType.getFields()[fieldName];
|
|
12100
12100
|
}
|
|
12101
|
-
var responseName =
|
|
12101
|
+
var responseName = selection.alias ? selection.alias.value : fieldName;
|
|
12102
12102
|
if (!nodeAndDefs[responseName]) {
|
|
12103
12103
|
nodeAndDefs[responseName] = [];
|
|
12104
12104
|
}
|
|
12105
|
-
nodeAndDefs[responseName].push([parentType,
|
|
12105
|
+
nodeAndDefs[responseName].push([parentType, selection, fieldDef]);
|
|
12106
12106
|
break;
|
|
12107
12107
|
}
|
|
12108
12108
|
case _kinds.Kind.FRAGMENT_SPREAD:
|
|
12109
|
-
fragmentNames[
|
|
12109
|
+
fragmentNames[selection.name.value] = true;
|
|
12110
12110
|
break;
|
|
12111
12111
|
case _kinds.Kind.INLINE_FRAGMENT: {
|
|
12112
|
-
var typeCondition =
|
|
12112
|
+
var typeCondition = selection.typeCondition;
|
|
12113
12113
|
var inlineFragmentType = typeCondition ? (0, _typeFromAST.typeFromAST)(context.getSchema(), typeCondition) : parentType;
|
|
12114
|
-
_collectFieldsAndFragmentNames(context, inlineFragmentType,
|
|
12114
|
+
_collectFieldsAndFragmentNames(context, inlineFragmentType, selection.selectionSet, nodeAndDefs, fragmentNames);
|
|
12115
12115
|
break;
|
|
12116
12116
|
}
|
|
12117
12117
|
}
|
|
@@ -12647,11 +12647,11 @@ var require_ValidationContext = __commonJS({
|
|
|
12647
12647
|
while (setsToVisit.length !== 0) {
|
|
12648
12648
|
var set = setsToVisit.pop();
|
|
12649
12649
|
for (var _i2 = 0, _set$selections2 = set.selections; _i2 < _set$selections2.length; _i2++) {
|
|
12650
|
-
var
|
|
12651
|
-
if (
|
|
12652
|
-
spreads.push(
|
|
12653
|
-
} else if (
|
|
12654
|
-
setsToVisit.push(
|
|
12650
|
+
var selection = _set$selections2[_i2];
|
|
12651
|
+
if (selection.kind === _kinds.Kind.FRAGMENT_SPREAD) {
|
|
12652
|
+
spreads.push(selection);
|
|
12653
|
+
} else if (selection.selectionSet) {
|
|
12654
|
+
setsToVisit.push(selection.selectionSet);
|
|
12655
12655
|
}
|
|
12656
12656
|
}
|
|
12657
12657
|
}
|
|
@@ -12672,10 +12672,10 @@ var require_ValidationContext = __commonJS({
|
|
|
12672
12672
|
var fragName = spread.name.value;
|
|
12673
12673
|
if (collectedNames[fragName] !== true) {
|
|
12674
12674
|
collectedNames[fragName] = true;
|
|
12675
|
-
var
|
|
12676
|
-
if (
|
|
12677
|
-
fragments.push(
|
|
12678
|
-
nodesToVisit.push(
|
|
12675
|
+
var fragment2 = this.getFragment(fragName);
|
|
12676
|
+
if (fragment2) {
|
|
12677
|
+
fragments.push(fragment2);
|
|
12678
|
+
nodesToVisit.push(fragment2.selectionSet);
|
|
12679
12679
|
}
|
|
12680
12680
|
}
|
|
12681
12681
|
}
|
|
@@ -13588,37 +13588,37 @@ var require_execute = __commonJS({
|
|
|
13588
13588
|
}
|
|
13589
13589
|
function collectFields(exeContext, runtimeType, selectionSet, fields, visitedFragmentNames) {
|
|
13590
13590
|
for (var _i6 = 0, _selectionSet$selecti2 = selectionSet.selections; _i6 < _selectionSet$selecti2.length; _i6++) {
|
|
13591
|
-
var
|
|
13592
|
-
switch (
|
|
13591
|
+
var selection = _selectionSet$selecti2[_i6];
|
|
13592
|
+
switch (selection.kind) {
|
|
13593
13593
|
case _kinds.Kind.FIELD: {
|
|
13594
|
-
if (!shouldIncludeNode(exeContext,
|
|
13594
|
+
if (!shouldIncludeNode(exeContext, selection)) {
|
|
13595
13595
|
continue;
|
|
13596
13596
|
}
|
|
13597
|
-
var name = getFieldEntryKey(
|
|
13597
|
+
var name = getFieldEntryKey(selection);
|
|
13598
13598
|
if (!fields[name]) {
|
|
13599
13599
|
fields[name] = [];
|
|
13600
13600
|
}
|
|
13601
|
-
fields[name].push(
|
|
13601
|
+
fields[name].push(selection);
|
|
13602
13602
|
break;
|
|
13603
13603
|
}
|
|
13604
13604
|
case _kinds.Kind.INLINE_FRAGMENT: {
|
|
13605
|
-
if (!shouldIncludeNode(exeContext,
|
|
13605
|
+
if (!shouldIncludeNode(exeContext, selection) || !doesFragmentConditionMatch(exeContext, selection, runtimeType)) {
|
|
13606
13606
|
continue;
|
|
13607
13607
|
}
|
|
13608
|
-
collectFields(exeContext, runtimeType,
|
|
13608
|
+
collectFields(exeContext, runtimeType, selection.selectionSet, fields, visitedFragmentNames);
|
|
13609
13609
|
break;
|
|
13610
13610
|
}
|
|
13611
13611
|
case _kinds.Kind.FRAGMENT_SPREAD: {
|
|
13612
|
-
var fragName =
|
|
13613
|
-
if (visitedFragmentNames[fragName] || !shouldIncludeNode(exeContext,
|
|
13612
|
+
var fragName = selection.name.value;
|
|
13613
|
+
if (visitedFragmentNames[fragName] || !shouldIncludeNode(exeContext, selection)) {
|
|
13614
13614
|
continue;
|
|
13615
13615
|
}
|
|
13616
13616
|
visitedFragmentNames[fragName] = true;
|
|
13617
|
-
var
|
|
13618
|
-
if (!
|
|
13617
|
+
var fragment2 = exeContext.fragments[fragName];
|
|
13618
|
+
if (!fragment2 || !doesFragmentConditionMatch(exeContext, fragment2, runtimeType)) {
|
|
13619
13619
|
continue;
|
|
13620
13620
|
}
|
|
13621
|
-
collectFields(exeContext, runtimeType,
|
|
13621
|
+
collectFields(exeContext, runtimeType, fragment2.selectionSet, fields, visitedFragmentNames);
|
|
13622
13622
|
break;
|
|
13623
13623
|
}
|
|
13624
13624
|
}
|
|
@@ -13636,8 +13636,8 @@ var require_execute = __commonJS({
|
|
|
13636
13636
|
}
|
|
13637
13637
|
return true;
|
|
13638
13638
|
}
|
|
13639
|
-
function doesFragmentConditionMatch(exeContext,
|
|
13640
|
-
var typeConditionNode =
|
|
13639
|
+
function doesFragmentConditionMatch(exeContext, fragment2, type) {
|
|
13640
|
+
var typeConditionNode = fragment2.typeCondition;
|
|
13641
13641
|
if (!typeConditionNode) {
|
|
13642
13642
|
return true;
|
|
13643
13643
|
}
|
|
@@ -65340,14 +65340,14 @@ function deepEquals(objA, objB, map = /* @__PURE__ */ new WeakMap()) {
|
|
|
65340
65340
|
}
|
|
65341
65341
|
|
|
65342
65342
|
// src/runtime/lib/selection.ts
|
|
65343
|
-
function getFieldsForType(
|
|
65344
|
-
let targetSelection =
|
|
65345
|
-
if (
|
|
65346
|
-
const mappedType =
|
|
65343
|
+
function getFieldsForType(selection, __typename) {
|
|
65344
|
+
let targetSelection = selection.fields || {};
|
|
65345
|
+
if (selection.abstractFields && __typename) {
|
|
65346
|
+
const mappedType = selection.abstractFields.typeMap[__typename];
|
|
65347
65347
|
if (mappedType) {
|
|
65348
|
-
targetSelection =
|
|
65349
|
-
} else if (
|
|
65350
|
-
targetSelection =
|
|
65348
|
+
targetSelection = selection.abstractFields.fields[mappedType];
|
|
65349
|
+
} else if (selection.abstractFields.fields[__typename]) {
|
|
65350
|
+
targetSelection = selection.abstractFields.fields[__typename];
|
|
65351
65351
|
}
|
|
65352
65352
|
}
|
|
65353
65353
|
return targetSelection;
|
|
@@ -65355,7 +65355,7 @@ function getFieldsForType(selection2, __typename) {
|
|
|
65355
65355
|
|
|
65356
65356
|
// src/runtime/lib/scalars.ts
|
|
65357
65357
|
async function marshalSelection({
|
|
65358
|
-
selection
|
|
65358
|
+
selection,
|
|
65359
65359
|
data
|
|
65360
65360
|
}) {
|
|
65361
65361
|
const config4 = getCurrentConfig();
|
|
@@ -65363,18 +65363,18 @@ async function marshalSelection({
|
|
|
65363
65363
|
return data;
|
|
65364
65364
|
}
|
|
65365
65365
|
if (Array.isArray(data)) {
|
|
65366
|
-
return await Promise.all(data.map((val) => marshalSelection({ selection
|
|
65366
|
+
return await Promise.all(data.map((val) => marshalSelection({ selection, data: val })));
|
|
65367
65367
|
}
|
|
65368
|
-
const targetSelection = getFieldsForType(
|
|
65368
|
+
const targetSelection = getFieldsForType(selection, data["__typename"]);
|
|
65369
65369
|
return Object.fromEntries(
|
|
65370
65370
|
await Promise.all(
|
|
65371
65371
|
Object.entries(data).map(async ([fieldName, value]) => {
|
|
65372
|
-
const { type, selection:
|
|
65372
|
+
const { type, selection: selection2 } = targetSelection[fieldName];
|
|
65373
65373
|
if (!type) {
|
|
65374
65374
|
return [fieldName, value];
|
|
65375
65375
|
}
|
|
65376
|
-
if (
|
|
65377
|
-
return [fieldName, await marshalSelection({ selection:
|
|
65376
|
+
if (selection2) {
|
|
65377
|
+
return [fieldName, await marshalSelection({ selection: selection2, data: value })];
|
|
65378
65378
|
}
|
|
65379
65379
|
if (config4.scalars?.[type]) {
|
|
65380
65380
|
const marshalFn = config4.scalars[type].marshal;
|
|
@@ -65425,6 +65425,7 @@ var DataSource = {
|
|
|
65425
65425
|
Network: "network",
|
|
65426
65426
|
Ssr: "ssr"
|
|
65427
65427
|
};
|
|
65428
|
+
var fragmentKey = " $fragments";
|
|
65428
65429
|
|
|
65429
65430
|
// src/runtime/lib/key.ts
|
|
65430
65431
|
var computeKey = ({ field, args }) => {
|
|
@@ -67167,7 +67168,7 @@ var List = class {
|
|
|
67167
67168
|
recordType,
|
|
67168
67169
|
key,
|
|
67169
67170
|
listType,
|
|
67170
|
-
selection
|
|
67171
|
+
selection,
|
|
67171
67172
|
when,
|
|
67172
67173
|
filters,
|
|
67173
67174
|
connection,
|
|
@@ -67179,7 +67180,7 @@ var List = class {
|
|
|
67179
67180
|
this.key = key;
|
|
67180
67181
|
this.type = listType;
|
|
67181
67182
|
this.cache = manager.cache;
|
|
67182
|
-
this.selection =
|
|
67183
|
+
this.selection = selection;
|
|
67183
67184
|
this._when = when;
|
|
67184
67185
|
this.filters = filters;
|
|
67185
67186
|
this.name = name;
|
|
@@ -67190,19 +67191,19 @@ var List = class {
|
|
|
67190
67191
|
when(when) {
|
|
67191
67192
|
return this.manager.lists.get(this.name).get(this.recordID).when(when);
|
|
67192
67193
|
}
|
|
67193
|
-
append(
|
|
67194
|
-
return this.addToList(
|
|
67194
|
+
append(selection, data, variables = {}) {
|
|
67195
|
+
return this.addToList(selection, data, variables, "last");
|
|
67195
67196
|
}
|
|
67196
|
-
prepend(
|
|
67197
|
-
return this.addToList(
|
|
67197
|
+
prepend(selection, data, variables = {}) {
|
|
67198
|
+
return this.addToList(selection, data, variables, "first");
|
|
67198
67199
|
}
|
|
67199
|
-
addToList(
|
|
67200
|
+
addToList(selection, data, variables = {}, where) {
|
|
67200
67201
|
const listType = this.listType(data);
|
|
67201
67202
|
const dataID = this.cache._internal_unstable.id(listType, data);
|
|
67202
67203
|
if (!this.validateWhen() || !dataID) {
|
|
67203
67204
|
return;
|
|
67204
67205
|
}
|
|
67205
|
-
let insertSelection =
|
|
67206
|
+
let insertSelection = selection;
|
|
67206
67207
|
let insertData = data;
|
|
67207
67208
|
if (this.connection) {
|
|
67208
67209
|
insertSelection = {
|
|
@@ -67222,9 +67223,9 @@ var List = class {
|
|
|
67222
67223
|
type: listType,
|
|
67223
67224
|
keyRaw: "node",
|
|
67224
67225
|
selection: {
|
|
67225
|
-
...
|
|
67226
|
+
...selection,
|
|
67226
67227
|
fields: {
|
|
67227
|
-
...
|
|
67228
|
+
...selection.fields,
|
|
67228
67229
|
__typename: {
|
|
67229
67230
|
keyRaw: "__typename",
|
|
67230
67231
|
type: "String"
|
|
@@ -67253,9 +67254,9 @@ var List = class {
|
|
|
67253
67254
|
type: listType,
|
|
67254
67255
|
updates: ["append", "prepend"],
|
|
67255
67256
|
selection: {
|
|
67256
|
-
...
|
|
67257
|
+
...selection,
|
|
67257
67258
|
fields: {
|
|
67258
|
-
...
|
|
67259
|
+
...selection.fields,
|
|
67259
67260
|
__typename: {
|
|
67260
67261
|
keyRaw: "__typename",
|
|
67261
67262
|
type: "String"
|
|
@@ -67330,7 +67331,8 @@ var List = class {
|
|
|
67330
67331
|
this.cache._internal_unstable.getSelection({
|
|
67331
67332
|
parent: spec.parentID || this.manager.rootID,
|
|
67332
67333
|
selection: spec.selection,
|
|
67333
|
-
variables: spec.variables?.() || {}
|
|
67334
|
+
variables: spec.variables?.() || {},
|
|
67335
|
+
ignoreMasking: false
|
|
67334
67336
|
}).data
|
|
67335
67337
|
);
|
|
67336
67338
|
}
|
|
@@ -67366,9 +67368,9 @@ var List = class {
|
|
|
67366
67368
|
}
|
|
67367
67369
|
return ok;
|
|
67368
67370
|
}
|
|
67369
|
-
toggleElement(
|
|
67371
|
+
toggleElement(selection, data, variables = {}, where) {
|
|
67370
67372
|
if (!this.remove(data, variables)) {
|
|
67371
|
-
this.addToList(
|
|
67373
|
+
this.addToList(selection, data, variables, where);
|
|
67372
67374
|
}
|
|
67373
67375
|
}
|
|
67374
67376
|
*[Symbol.iterator]() {
|
|
@@ -67943,14 +67945,24 @@ var InMemorySubscriptions = class {
|
|
|
67943
67945
|
add({
|
|
67944
67946
|
parent,
|
|
67945
67947
|
spec,
|
|
67946
|
-
selection
|
|
67948
|
+
selection,
|
|
67947
67949
|
variables,
|
|
67948
67950
|
parentType
|
|
67949
67951
|
}) {
|
|
67950
67952
|
const __typename = this.cache._internal_unstable.storage.get(parent, "__typename").value;
|
|
67951
|
-
let targetSelection = getFieldsForType(
|
|
67953
|
+
let targetSelection = getFieldsForType(selection, __typename);
|
|
67952
67954
|
for (const fieldSelection of Object.values(targetSelection || {})) {
|
|
67953
|
-
const {
|
|
67955
|
+
const {
|
|
67956
|
+
keyRaw,
|
|
67957
|
+
selection: innerSelection,
|
|
67958
|
+
type,
|
|
67959
|
+
list,
|
|
67960
|
+
filters,
|
|
67961
|
+
visible
|
|
67962
|
+
} = fieldSelection;
|
|
67963
|
+
if (!visible) {
|
|
67964
|
+
continue;
|
|
67965
|
+
}
|
|
67954
67966
|
const key = evaluateKey(keyRaw, variables);
|
|
67955
67967
|
let targetSelection2;
|
|
67956
67968
|
if (innerSelection) {
|
|
@@ -67998,10 +68010,10 @@ var InMemorySubscriptions = class {
|
|
|
67998
68010
|
addFieldSubscription({
|
|
67999
68011
|
id,
|
|
68000
68012
|
key,
|
|
68001
|
-
selection
|
|
68013
|
+
selection,
|
|
68002
68014
|
type
|
|
68003
68015
|
}) {
|
|
68004
|
-
const spec =
|
|
68016
|
+
const spec = selection[0];
|
|
68005
68017
|
if (!this.subscribers[id]) {
|
|
68006
68018
|
this.subscribers[id] = {};
|
|
68007
68019
|
}
|
|
@@ -68013,7 +68025,7 @@ var InMemorySubscriptions = class {
|
|
|
68013
68025
|
}
|
|
68014
68026
|
this.keyVersions[key].add(key);
|
|
68015
68027
|
if (!this.subscribers[id][key].map(([{ set }]) => set).includes(spec.set)) {
|
|
68016
|
-
this.subscribers[id][key].push([spec,
|
|
68028
|
+
this.subscribers[id][key].push([spec, selection[1]]);
|
|
68017
68029
|
}
|
|
68018
68030
|
if (!this.referenceCounts[id]) {
|
|
68019
68031
|
this.referenceCounts[id] = {};
|
|
@@ -68024,14 +68036,13 @@ var InMemorySubscriptions = class {
|
|
|
68024
68036
|
const counts = this.referenceCounts[id][key];
|
|
68025
68037
|
counts.set(spec.set, (counts.get(spec.set) || 0) + 1);
|
|
68026
68038
|
this.cache._internal_unstable.lifetimes.resetLifetime(id, key);
|
|
68027
|
-
const { selection: innerSelection } = selection2[1]?.[key] ?? {};
|
|
68028
68039
|
}
|
|
68029
68040
|
registerList({
|
|
68030
68041
|
list,
|
|
68031
68042
|
id,
|
|
68032
68043
|
key,
|
|
68033
68044
|
parentType,
|
|
68034
|
-
selection
|
|
68045
|
+
selection,
|
|
68035
68046
|
filters,
|
|
68036
68047
|
variables
|
|
68037
68048
|
}) {
|
|
@@ -68042,7 +68053,7 @@ var InMemorySubscriptions = class {
|
|
|
68042
68053
|
recordType: this.cache._internal_unstable.storage.get(id, "__typename")?.value || parentType,
|
|
68043
68054
|
listType: list.type,
|
|
68044
68055
|
key,
|
|
68045
|
-
selection
|
|
68056
|
+
selection,
|
|
68046
68057
|
filters: Object.entries(filters || {}).reduce((acc, [key2, { kind, value }]) => {
|
|
68047
68058
|
return {
|
|
68048
68059
|
...acc,
|
|
@@ -68058,14 +68069,14 @@ var InMemorySubscriptions = class {
|
|
|
68058
68069
|
parentType
|
|
68059
68070
|
}) {
|
|
68060
68071
|
for (const [spec, targetSelection] of subscribers) {
|
|
68061
|
-
for (const
|
|
68072
|
+
for (const selection of Object.values(targetSelection ?? {})) {
|
|
68062
68073
|
const {
|
|
68063
68074
|
type: linkedType,
|
|
68064
68075
|
keyRaw,
|
|
68065
68076
|
selection: innerSelection,
|
|
68066
68077
|
list,
|
|
68067
68078
|
filters
|
|
68068
|
-
} =
|
|
68079
|
+
} = selection;
|
|
68069
68080
|
const key = evaluateKey(keyRaw, variables);
|
|
68070
68081
|
const fieldSelection = innerSelection ? getFieldsForType(innerSelection, parentType) : void 0;
|
|
68071
68082
|
this.addFieldSubscription({
|
|
@@ -68085,7 +68096,7 @@ var InMemorySubscriptions = class {
|
|
|
68085
68096
|
parentType: parentType || spec.rootType
|
|
68086
68097
|
});
|
|
68087
68098
|
}
|
|
68088
|
-
const childSelection =
|
|
68099
|
+
const childSelection = selection.selection;
|
|
68089
68100
|
if (childSelection) {
|
|
68090
68101
|
const { value: link } = this.cache._internal_unstable.storage.get(parent, key);
|
|
68091
68102
|
const children = !Array.isArray(link) ? [link] : flatten(link);
|
|
@@ -68112,11 +68123,11 @@ var InMemorySubscriptions = class {
|
|
|
68112
68123
|
get(id, field) {
|
|
68113
68124
|
return this.subscribers[id]?.[field] || [];
|
|
68114
68125
|
}
|
|
68115
|
-
remove(id,
|
|
68126
|
+
remove(id, selection, targets, variables, visited = []) {
|
|
68116
68127
|
visited.push(id);
|
|
68117
68128
|
const linkedIDs = [];
|
|
68118
68129
|
const __typename = this.cache._internal_unstable.storage.get(id, "__typename").value;
|
|
68119
|
-
let targetSelection = getFieldsForType(
|
|
68130
|
+
let targetSelection = getFieldsForType(selection, __typename);
|
|
68120
68131
|
for (const fieldSelection of Object.values(targetSelection || {})) {
|
|
68121
68132
|
const key = evaluateKey(fieldSelection.keyRaw, variables);
|
|
68122
68133
|
this.removeSubscribers(id, key, targets);
|
|
@@ -68178,7 +68189,7 @@ var InMemorySubscriptions = class {
|
|
|
68178
68189
|
// src/runtime/cache/cache.ts
|
|
68179
68190
|
var Cache = class {
|
|
68180
68191
|
_internal_unstable;
|
|
68181
|
-
constructor(config4) {
|
|
68192
|
+
constructor({ disabled, ...config4 } = {}) {
|
|
68182
68193
|
this._internal_unstable = new CacheInternal({
|
|
68183
68194
|
cache: this,
|
|
68184
68195
|
storage: new InMemoryStorage(),
|
|
@@ -68186,9 +68197,10 @@ var Cache = class {
|
|
|
68186
68197
|
lists: new ListManager(this, rootID),
|
|
68187
68198
|
lifetimes: new GarbageCollector(this),
|
|
68188
68199
|
staleManager: new StaleManager(this),
|
|
68189
|
-
schema: new SchemaManager(this)
|
|
68200
|
+
schema: new SchemaManager(this),
|
|
68201
|
+
disabled: disabled ?? typeof globalThis.window === "undefined"
|
|
68190
68202
|
});
|
|
68191
|
-
if (config4) {
|
|
68203
|
+
if (Object.keys(config4).length > 0) {
|
|
68192
68204
|
this.setConfig(defaultConfigValues(config4));
|
|
68193
68205
|
}
|
|
68194
68206
|
}
|
|
@@ -68207,7 +68219,8 @@ var Cache = class {
|
|
|
68207
68219
|
this._internal_unstable.getSelection({
|
|
68208
68220
|
parent: spec.parentID || rootID,
|
|
68209
68221
|
selection: spec.selection,
|
|
68210
|
-
variables: spec.variables?.() || {}
|
|
68222
|
+
variables: spec.variables?.() || {},
|
|
68223
|
+
ignoreMasking: false
|
|
68211
68224
|
}).data
|
|
68212
68225
|
);
|
|
68213
68226
|
}
|
|
@@ -68282,16 +68295,13 @@ var Cache = class {
|
|
|
68282
68295
|
getFieldTime(id, field) {
|
|
68283
68296
|
return this._internal_unstable.staleManager.getFieldTime(id, field);
|
|
68284
68297
|
}
|
|
68298
|
+
config() {
|
|
68299
|
+
return this._internal_unstable.config;
|
|
68300
|
+
}
|
|
68285
68301
|
};
|
|
68286
68302
|
var CacheInternal = class {
|
|
68287
68303
|
_disabled = false;
|
|
68288
|
-
|
|
68289
|
-
plugins: {
|
|
68290
|
-
"houdini-svelte": {
|
|
68291
|
-
client: ""
|
|
68292
|
-
}
|
|
68293
|
-
}
|
|
68294
|
-
});
|
|
68304
|
+
_config;
|
|
68295
68305
|
storage;
|
|
68296
68306
|
subscriptions;
|
|
68297
68307
|
lists;
|
|
@@ -68306,7 +68316,9 @@ var CacheInternal = class {
|
|
|
68306
68316
|
cache,
|
|
68307
68317
|
lifetimes,
|
|
68308
68318
|
staleManager,
|
|
68309
|
-
schema
|
|
68319
|
+
schema,
|
|
68320
|
+
disabled,
|
|
68321
|
+
config: config4
|
|
68310
68322
|
}) {
|
|
68311
68323
|
this.storage = storage;
|
|
68312
68324
|
this.subscriptions = subscriptions;
|
|
@@ -68315,7 +68327,8 @@ var CacheInternal = class {
|
|
|
68315
68327
|
this.lifetimes = lifetimes;
|
|
68316
68328
|
this.staleManager = staleManager;
|
|
68317
68329
|
this.schema = schema;
|
|
68318
|
-
this.
|
|
68330
|
+
this._config = config4;
|
|
68331
|
+
this._disabled = disabled;
|
|
68319
68332
|
try {
|
|
68320
68333
|
if (process.env.HOUDINI_TEST === "true") {
|
|
68321
68334
|
this._disabled = false;
|
|
@@ -68323,12 +68336,15 @@ var CacheInternal = class {
|
|
|
68323
68336
|
} catch {
|
|
68324
68337
|
}
|
|
68325
68338
|
}
|
|
68339
|
+
get config() {
|
|
68340
|
+
return this._config ?? getCurrentConfig();
|
|
68341
|
+
}
|
|
68326
68342
|
setConfig(config4) {
|
|
68327
|
-
this.
|
|
68343
|
+
this._config = config4;
|
|
68328
68344
|
}
|
|
68329
68345
|
writeSelection({
|
|
68330
68346
|
data,
|
|
68331
|
-
selection
|
|
68347
|
+
selection,
|
|
68332
68348
|
variables = {},
|
|
68333
68349
|
parent = rootID,
|
|
68334
68350
|
applyUpdates,
|
|
@@ -68340,9 +68356,9 @@ var CacheInternal = class {
|
|
|
68340
68356
|
if (this._disabled) {
|
|
68341
68357
|
return [];
|
|
68342
68358
|
}
|
|
68343
|
-
let targetSelection = getFieldsForType(
|
|
68359
|
+
let targetSelection = getFieldsForType(selection, data["__typename"]);
|
|
68344
68360
|
for (const [field, value] of Object.entries(data)) {
|
|
68345
|
-
if (!
|
|
68361
|
+
if (!selection || !targetSelection[field]) {
|
|
68346
68362
|
continue;
|
|
68347
68363
|
}
|
|
68348
68364
|
let {
|
|
@@ -68598,25 +68614,40 @@ var CacheInternal = class {
|
|
|
68598
68614
|
return toNotify;
|
|
68599
68615
|
}
|
|
68600
68616
|
getSelection({
|
|
68601
|
-
selection
|
|
68617
|
+
selection,
|
|
68602
68618
|
parent = rootID,
|
|
68603
68619
|
variables,
|
|
68604
|
-
stepsFromConnection = null
|
|
68620
|
+
stepsFromConnection = null,
|
|
68621
|
+
ignoreMasking
|
|
68605
68622
|
}) {
|
|
68606
68623
|
if (parent === null) {
|
|
68607
68624
|
return { data: null, partial: false, stale: false, hasData: true };
|
|
68608
68625
|
}
|
|
68609
68626
|
const target = {};
|
|
68627
|
+
if (selection.fragments) {
|
|
68628
|
+
target[fragmentKey] = Object.fromEntries(
|
|
68629
|
+
Object.entries(selection.fragments).map(([key, value]) => [
|
|
68630
|
+
key,
|
|
68631
|
+
{
|
|
68632
|
+
parent,
|
|
68633
|
+
variables: evaluateFragmentVariables(value, variables ?? {})
|
|
68634
|
+
}
|
|
68635
|
+
])
|
|
68636
|
+
);
|
|
68637
|
+
}
|
|
68610
68638
|
let hasData = false;
|
|
68611
68639
|
let partial = false;
|
|
68612
68640
|
let cascadeNull = false;
|
|
68613
68641
|
let stale = false;
|
|
68614
68642
|
const typename = this.storage.get(parent, "__typename").value;
|
|
68615
|
-
let targetSelection = getFieldsForType(
|
|
68643
|
+
let targetSelection = getFieldsForType(selection, typename);
|
|
68616
68644
|
for (const [
|
|
68617
68645
|
attributeName,
|
|
68618
|
-
{ type, keyRaw, selection: fieldSelection, nullable, list }
|
|
68646
|
+
{ type, keyRaw, selection: fieldSelection, nullable, list, visible }
|
|
68619
68647
|
] of Object.entries(targetSelection)) {
|
|
68648
|
+
if (!visible && !ignoreMasking) {
|
|
68649
|
+
continue;
|
|
68650
|
+
}
|
|
68620
68651
|
const key = evaluateKey(keyRaw, variables);
|
|
68621
68652
|
const { value } = this.storage.get(parent, key);
|
|
68622
68653
|
const dt_field = this.staleManager.getFieldTime(parent, key);
|
|
@@ -68656,7 +68687,8 @@ var CacheInternal = class {
|
|
|
68656
68687
|
fields: fieldSelection,
|
|
68657
68688
|
variables,
|
|
68658
68689
|
linkedList: value,
|
|
68659
|
-
stepsFromConnection: nextStep
|
|
68690
|
+
stepsFromConnection: nextStep,
|
|
68691
|
+
ignoreMasking: !!ignoreMasking
|
|
68660
68692
|
});
|
|
68661
68693
|
target[attributeName] = listValue.data;
|
|
68662
68694
|
if (listValue.partial) {
|
|
@@ -68673,7 +68705,8 @@ var CacheInternal = class {
|
|
|
68673
68705
|
parent: value,
|
|
68674
68706
|
selection: fieldSelection,
|
|
68675
68707
|
variables,
|
|
68676
|
-
stepsFromConnection: nextStep
|
|
68708
|
+
stepsFromConnection: nextStep,
|
|
68709
|
+
ignoreMasking
|
|
68677
68710
|
});
|
|
68678
68711
|
target[attributeName] = objectFields.data;
|
|
68679
68712
|
if (objectFields.partial) {
|
|
@@ -68717,7 +68750,8 @@ var CacheInternal = class {
|
|
|
68717
68750
|
fields,
|
|
68718
68751
|
variables,
|
|
68719
68752
|
linkedList,
|
|
68720
|
-
stepsFromConnection
|
|
68753
|
+
stepsFromConnection,
|
|
68754
|
+
ignoreMasking
|
|
68721
68755
|
}) {
|
|
68722
68756
|
const result = [];
|
|
68723
68757
|
let partialData = false;
|
|
@@ -68729,7 +68763,8 @@ var CacheInternal = class {
|
|
|
68729
68763
|
fields,
|
|
68730
68764
|
variables,
|
|
68731
68765
|
linkedList: entry,
|
|
68732
|
-
stepsFromConnection
|
|
68766
|
+
stepsFromConnection,
|
|
68767
|
+
ignoreMasking
|
|
68733
68768
|
});
|
|
68734
68769
|
result.push(nestedValue.data);
|
|
68735
68770
|
if (nestedValue.partial) {
|
|
@@ -68750,7 +68785,8 @@ var CacheInternal = class {
|
|
|
68750
68785
|
parent: entry,
|
|
68751
68786
|
selection: fields,
|
|
68752
68787
|
variables,
|
|
68753
|
-
stepsFromConnection
|
|
68788
|
+
stepsFromConnection,
|
|
68789
|
+
ignoreMasking
|
|
68754
68790
|
});
|
|
68755
68791
|
result.push(data);
|
|
68756
68792
|
if (partial) {
|
|
@@ -68853,11 +68889,54 @@ var CacheInternal = class {
|
|
|
68853
68889
|
}
|
|
68854
68890
|
}
|
|
68855
68891
|
};
|
|
68892
|
+
function evaluateFragmentVariables(variables, args) {
|
|
68893
|
+
return Object.fromEntries(
|
|
68894
|
+
Object.entries(variables).map(([key, value]) => [key, fragmentVariableValue(value, args)])
|
|
68895
|
+
);
|
|
68896
|
+
}
|
|
68897
|
+
function fragmentVariableValue(value, args) {
|
|
68898
|
+
if (value.kind === "StringValue") {
|
|
68899
|
+
return value.value;
|
|
68900
|
+
}
|
|
68901
|
+
if (value.kind === "BooleanValue") {
|
|
68902
|
+
return value.value;
|
|
68903
|
+
}
|
|
68904
|
+
if (value.kind === "EnumValue") {
|
|
68905
|
+
return value.value;
|
|
68906
|
+
}
|
|
68907
|
+
if (value.kind === "FloatValue") {
|
|
68908
|
+
return parseFloat(value.value);
|
|
68909
|
+
}
|
|
68910
|
+
if (value.kind === "IntValue") {
|
|
68911
|
+
return parseInt(value.value, 10);
|
|
68912
|
+
}
|
|
68913
|
+
if (value.kind === "NullValue") {
|
|
68914
|
+
return null;
|
|
68915
|
+
}
|
|
68916
|
+
if (value.kind === "Variable") {
|
|
68917
|
+
return args[value.name.value];
|
|
68918
|
+
}
|
|
68919
|
+
if (value.kind === "ListValue") {
|
|
68920
|
+
return value.values.map((value2) => fragmentVariableValue(value2, args));
|
|
68921
|
+
}
|
|
68922
|
+
if (value.kind === "ObjectValue") {
|
|
68923
|
+
return value.fields.reduce(
|
|
68924
|
+
(obj, field) => ({
|
|
68925
|
+
...obj,
|
|
68926
|
+
[field.name.value]: fragmentVariableValue(field.value, args)
|
|
68927
|
+
}),
|
|
68928
|
+
{}
|
|
68929
|
+
);
|
|
68930
|
+
}
|
|
68931
|
+
}
|
|
68856
68932
|
var rootID = "_ROOT_";
|
|
68857
68933
|
|
|
68858
68934
|
// src/runtime/cache/index.ts
|
|
68859
68935
|
var cache_default = new Cache();
|
|
68860
68936
|
|
|
68937
|
+
// src/runtime/client/plugins/cache.ts
|
|
68938
|
+
var serverSide = typeof globalThis.window === "undefined";
|
|
68939
|
+
|
|
68861
68940
|
// src/runtime/client/utils/documentPlugins.ts
|
|
68862
68941
|
var documentPlugin = (kind, source) => {
|
|
68863
68942
|
return () => {
|
|
@@ -68893,7 +68972,6 @@ var documentPlugin = (kind, source) => {
|
|
|
68893
68972
|
var query = documentPlugin(ArtifactKind.Query, function() {
|
|
68894
68973
|
let subscriptionSpec = null;
|
|
68895
68974
|
let lastVariables = null;
|
|
68896
|
-
let artifactName = "";
|
|
68897
68975
|
return {
|
|
68898
68976
|
start(ctx, { next }) {
|
|
68899
68977
|
ctx.variables = {
|
|
@@ -68903,8 +68981,7 @@ var query = documentPlugin(ArtifactKind.Query, function() {
|
|
|
68903
68981
|
next(ctx);
|
|
68904
68982
|
},
|
|
68905
68983
|
end(ctx, { resolve: resolve2, marshalVariables, variablesChanged }) {
|
|
68906
|
-
if (variablesChanged(ctx)) {
|
|
68907
|
-
artifactName = ctx.artifact.name;
|
|
68984
|
+
if (variablesChanged(ctx) && !ctx.cacheParams?.disableSubscriptions) {
|
|
68908
68985
|
if (subscriptionSpec) {
|
|
68909
68986
|
cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.() || {});
|
|
68910
68987
|
}
|
|
@@ -68925,19 +69002,61 @@ var query = documentPlugin(ArtifactKind.Query, function() {
|
|
|
68925
69002
|
});
|
|
68926
69003
|
}
|
|
68927
69004
|
};
|
|
68928
|
-
cache_default.subscribe(subscriptionSpec, lastVariables
|
|
69005
|
+
cache_default.subscribe(subscriptionSpec, lastVariables);
|
|
68929
69006
|
}
|
|
68930
69007
|
resolve2(ctx);
|
|
68931
69008
|
},
|
|
68932
69009
|
cleanup() {
|
|
68933
69010
|
if (subscriptionSpec) {
|
|
68934
|
-
cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.()
|
|
69011
|
+
cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.());
|
|
68935
69012
|
lastVariables = null;
|
|
68936
69013
|
}
|
|
68937
69014
|
}
|
|
68938
69015
|
};
|
|
68939
69016
|
});
|
|
68940
69017
|
|
|
69018
|
+
// src/runtime/client/plugins/fragment.ts
|
|
69019
|
+
var fragment = documentPlugin(ArtifactKind.Fragment, function() {
|
|
69020
|
+
let subscriptionSpec = null;
|
|
69021
|
+
return {
|
|
69022
|
+
start(ctx, { next, resolve: resolve2, variablesChanged, marshalVariables }) {
|
|
69023
|
+
if (!ctx.stuff.parentID) {
|
|
69024
|
+
return next(ctx);
|
|
69025
|
+
}
|
|
69026
|
+
if (variablesChanged(ctx) && !ctx.cacheParams?.disableSubscriptions) {
|
|
69027
|
+
if (subscriptionSpec) {
|
|
69028
|
+
cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.() || {});
|
|
69029
|
+
}
|
|
69030
|
+
const variables = marshalVariables(ctx);
|
|
69031
|
+
subscriptionSpec = {
|
|
69032
|
+
rootType: ctx.artifact.rootType,
|
|
69033
|
+
selection: ctx.artifact.selection,
|
|
69034
|
+
variables: () => variables,
|
|
69035
|
+
parentID: ctx.stuff.parentID,
|
|
69036
|
+
set: (newValue) => {
|
|
69037
|
+
resolve2(ctx, {
|
|
69038
|
+
data: newValue,
|
|
69039
|
+
errors: null,
|
|
69040
|
+
fetching: false,
|
|
69041
|
+
partial: false,
|
|
69042
|
+
stale: false,
|
|
69043
|
+
source: DataSource.Cache,
|
|
69044
|
+
variables
|
|
69045
|
+
});
|
|
69046
|
+
}
|
|
69047
|
+
};
|
|
69048
|
+
cache_default.subscribe(subscriptionSpec, variables);
|
|
69049
|
+
}
|
|
69050
|
+
next(ctx);
|
|
69051
|
+
},
|
|
69052
|
+
cleanup() {
|
|
69053
|
+
if (subscriptionSpec) {
|
|
69054
|
+
cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.());
|
|
69055
|
+
}
|
|
69056
|
+
}
|
|
69057
|
+
};
|
|
69058
|
+
});
|
|
69059
|
+
|
|
68941
69060
|
// src/runtime/client/plugins/mutation.ts
|
|
68942
69061
|
var mutation = documentPlugin(ArtifactKind.Mutation, () => {
|
|
68943
69062
|
return {
|
|
@@ -69094,6 +69213,7 @@ var Config = class {
|
|
|
69094
69213
|
this.schemaPollInterval = watchSchema?.interval ?? 2e3;
|
|
69095
69214
|
this.schemaPollHeaders = watchSchema?.headers ?? {};
|
|
69096
69215
|
this.rootDir = join2(this.projectRoot, "$houdini");
|
|
69216
|
+
this.#fragmentVariableMaps = {};
|
|
69097
69217
|
if (defaultKeys) {
|
|
69098
69218
|
this.defaultKeys = defaultKeys;
|
|
69099
69219
|
}
|
|
@@ -69243,7 +69363,7 @@ var Config = class {
|
|
|
69243
69363
|
return `$houdini/${this.artifactDirectoryName}/${name}`;
|
|
69244
69364
|
}
|
|
69245
69365
|
keyFieldsForType(type) {
|
|
69246
|
-
return keyFieldsForType(this.configFile, type);
|
|
69366
|
+
return this.schema.getQueryType()?.name === type ? [] : keyFieldsForType(this.configFile, type);
|
|
69247
69367
|
}
|
|
69248
69368
|
computeID(type, data) {
|
|
69249
69369
|
return computeID(this.configFile, type, data);
|
|
@@ -69262,7 +69382,7 @@ var Config = class {
|
|
|
69262
69382
|
({ kind }) => kind === graphql2.Kind.FRAGMENT_DEFINITION
|
|
69263
69383
|
);
|
|
69264
69384
|
if (fragmentDefinitions.length) {
|
|
69265
|
-
return fragmentDefinitions.
|
|
69385
|
+
return fragmentDefinitions[0].name.value;
|
|
69266
69386
|
}
|
|
69267
69387
|
throw new Error("Could not generate artifact name for document: " + graphql2.print(document));
|
|
69268
69388
|
}
|
|
@@ -69434,6 +69554,56 @@ var Config = class {
|
|
|
69434
69554
|
}, []) ?? [];
|
|
69435
69555
|
return !defaultDirectives.includes(name) && (internalDirectives.includes(name) || this.isDeleteDirective(name));
|
|
69436
69556
|
}
|
|
69557
|
+
#fragmentVariableMaps;
|
|
69558
|
+
registerFragmentVariablesHash({
|
|
69559
|
+
hash,
|
|
69560
|
+
args,
|
|
69561
|
+
fragment: fragment2
|
|
69562
|
+
}) {
|
|
69563
|
+
this.#fragmentVariableMaps[hash] = {
|
|
69564
|
+
args: this.#serializeValueMap(args),
|
|
69565
|
+
fragment: fragment2
|
|
69566
|
+
};
|
|
69567
|
+
}
|
|
69568
|
+
getFragmentVariablesHash(hash) {
|
|
69569
|
+
return this.#fragmentVariableMaps[hash] ?? {
|
|
69570
|
+
fragment: hash,
|
|
69571
|
+
args: {},
|
|
69572
|
+
hash
|
|
69573
|
+
};
|
|
69574
|
+
}
|
|
69575
|
+
#serializeValueMap(map) {
|
|
69576
|
+
if (!map) {
|
|
69577
|
+
return null;
|
|
69578
|
+
}
|
|
69579
|
+
return Object.fromEntries(
|
|
69580
|
+
Object.entries(map).map(([key, input]) => {
|
|
69581
|
+
const result = {
|
|
69582
|
+
kind: input.kind
|
|
69583
|
+
};
|
|
69584
|
+
if (typeof input === "object") {
|
|
69585
|
+
if ("value" in input) {
|
|
69586
|
+
result.value = input.value;
|
|
69587
|
+
}
|
|
69588
|
+
if ("values" in input) {
|
|
69589
|
+
result.values = input.values.map(
|
|
69590
|
+
(value) => this.#serializeValueMap({ foo: value }).foo
|
|
69591
|
+
);
|
|
69592
|
+
}
|
|
69593
|
+
if ("name" in input) {
|
|
69594
|
+
result.name = input.name;
|
|
69595
|
+
}
|
|
69596
|
+
if ("fields" in input) {
|
|
69597
|
+
result.fields = input.fields.map((field) => ({
|
|
69598
|
+
name: field.name,
|
|
69599
|
+
value: this.#serializeValueMap({ foo: field.value }).foo
|
|
69600
|
+
}));
|
|
69601
|
+
}
|
|
69602
|
+
}
|
|
69603
|
+
return [key, result];
|
|
69604
|
+
})
|
|
69605
|
+
);
|
|
69606
|
+
}
|
|
69437
69607
|
isListFragment(name) {
|
|
69438
69608
|
return name.endsWith(this.insertFragmentSuffix) || name.endsWith(this.removeFragmentSuffix) || name.endsWith(this.toggleFragmentSuffix);
|
|
69439
69609
|
}
|
|
@@ -69935,11 +70105,17 @@ function deepMerge(filepath, ...targets) {
|
|
|
69935
70105
|
if (targets.length === 1) {
|
|
69936
70106
|
return targets[0];
|
|
69937
70107
|
} else if (targets.length === 2) {
|
|
69938
|
-
return (0, import_deepmerge.default)(targets[0], targets[1]
|
|
70108
|
+
return (0, import_deepmerge.default)(targets[0], targets[1], {
|
|
70109
|
+
arrayMerge: (source, update) => [...new Set(source.concat(update))]
|
|
70110
|
+
});
|
|
69939
70111
|
}
|
|
69940
70112
|
return deepMerge(filepath, targets[0], deepMerge(filepath, ...targets.slice(1)));
|
|
69941
70113
|
} catch (e2) {
|
|
69942
|
-
throw new HoudiniError({
|
|
70114
|
+
throw new HoudiniError({
|
|
70115
|
+
filepath,
|
|
70116
|
+
message: "could not merge: " + targets,
|
|
70117
|
+
description: e2.message
|
|
70118
|
+
});
|
|
69943
70119
|
}
|
|
69944
70120
|
}
|
|
69945
70121
|
|
|
@@ -70167,16 +70343,16 @@ function flattenSelections({
|
|
|
70167
70343
|
filepath,
|
|
70168
70344
|
selections,
|
|
70169
70345
|
fragmentDefinitions,
|
|
70170
|
-
|
|
70171
|
-
|
|
70346
|
+
ignoreMaskDisable,
|
|
70347
|
+
keepFragmentSpreadNodes
|
|
70172
70348
|
}) {
|
|
70173
70349
|
const fields = new FieldCollection({
|
|
70174
70350
|
config: config4,
|
|
70175
70351
|
filepath,
|
|
70176
70352
|
selections,
|
|
70177
70353
|
fragmentDefinitions,
|
|
70178
|
-
|
|
70179
|
-
|
|
70354
|
+
ignoreMaskDisable: !!ignoreMaskDisable,
|
|
70355
|
+
keepFragmentSpreadNodes: !!keepFragmentSpreadNodes
|
|
70180
70356
|
});
|
|
70181
70357
|
return fields.toSelectionSet();
|
|
70182
70358
|
}
|
|
@@ -70187,57 +70363,59 @@ var FieldCollection = class {
|
|
|
70187
70363
|
fields;
|
|
70188
70364
|
inlineFragments;
|
|
70189
70365
|
fragmentSpreads;
|
|
70190
|
-
applyFragments;
|
|
70191
70366
|
ignoreMaskDisable;
|
|
70367
|
+
keepFragmentSpreadNodes;
|
|
70192
70368
|
constructor(args) {
|
|
70193
70369
|
this.config = args.config;
|
|
70194
70370
|
this.fragmentDefinitions = args.fragmentDefinitions;
|
|
70195
|
-
this.applyFragments = args.applyFragments;
|
|
70196
70371
|
this.ignoreMaskDisable = args.ignoreMaskDisable;
|
|
70372
|
+
this.keepFragmentSpreadNodes = args.keepFragmentSpreadNodes;
|
|
70197
70373
|
this.fields = {};
|
|
70198
70374
|
this.inlineFragments = {};
|
|
70199
70375
|
this.fragmentSpreads = {};
|
|
70200
70376
|
this.filepath = args.filepath;
|
|
70201
|
-
for (const
|
|
70202
|
-
this.add(
|
|
70377
|
+
for (const selection of args.selections) {
|
|
70378
|
+
this.add(selection);
|
|
70203
70379
|
}
|
|
70204
70380
|
}
|
|
70205
70381
|
get size() {
|
|
70206
70382
|
return Object.keys(this.fields).length + Object.keys(this.inlineFragments).length + Object.keys(this.fragmentSpreads).length;
|
|
70207
70383
|
}
|
|
70208
|
-
add(
|
|
70209
|
-
if (
|
|
70210
|
-
const key =
|
|
70384
|
+
add(selection) {
|
|
70385
|
+
if (selection.kind === "Field") {
|
|
70386
|
+
const key = selection.alias?.value || selection.name.value;
|
|
70211
70387
|
if (!this.fields[key]) {
|
|
70212
70388
|
this.fields[key] = {
|
|
70213
|
-
astNode:
|
|
70389
|
+
astNode: selection,
|
|
70214
70390
|
selection: this.empty()
|
|
70215
70391
|
};
|
|
70216
70392
|
}
|
|
70217
|
-
for (const subselect of
|
|
70393
|
+
for (const subselect of selection.selectionSet?.selections || []) {
|
|
70218
70394
|
this.fields[key].selection.add(subselect);
|
|
70219
70395
|
}
|
|
70396
|
+
this.fields[key].selection.fragmentSpreads = this.collectFragmentSpreads(
|
|
70397
|
+
selection.selectionSet?.selections ?? []
|
|
70398
|
+
);
|
|
70220
70399
|
return;
|
|
70221
70400
|
}
|
|
70222
|
-
if (
|
|
70223
|
-
for (const subselect of
|
|
70401
|
+
if (selection.kind === "InlineFragment" && !selection.typeCondition) {
|
|
70402
|
+
for (const subselect of selection.selectionSet.selections) {
|
|
70224
70403
|
this.add(subselect);
|
|
70225
70404
|
}
|
|
70226
70405
|
}
|
|
70227
|
-
if (
|
|
70228
|
-
this.walkInlineFragment(
|
|
70406
|
+
if (selection.kind === "InlineFragment" && selection.typeCondition) {
|
|
70407
|
+
this.walkInlineFragment(selection);
|
|
70229
70408
|
return;
|
|
70230
70409
|
}
|
|
70231
|
-
if (
|
|
70232
|
-
this.fragmentSpreads[selection2.name.value] = selection2;
|
|
70410
|
+
if (selection.kind === "FragmentSpread") {
|
|
70233
70411
|
let includeFragments = this.config.defaultFragmentMasking === "disable";
|
|
70234
|
-
const maskEnableDirective =
|
|
70412
|
+
const maskEnableDirective = selection.directives?.find(
|
|
70235
70413
|
({ name }) => name.value === this.config.maskEnableDirective
|
|
70236
70414
|
);
|
|
70237
70415
|
if (maskEnableDirective) {
|
|
70238
70416
|
includeFragments = false;
|
|
70239
70417
|
}
|
|
70240
|
-
const maskDisableDirective =
|
|
70418
|
+
const maskDisableDirective = selection.directives?.find(
|
|
70241
70419
|
({ name }) => name.value === this.config.maskDisableDirective
|
|
70242
70420
|
);
|
|
70243
70421
|
if (maskDisableDirective) {
|
|
@@ -70246,14 +70424,17 @@ var FieldCollection = class {
|
|
|
70246
70424
|
if (this.ignoreMaskDisable) {
|
|
70247
70425
|
includeFragments = true;
|
|
70248
70426
|
}
|
|
70249
|
-
if (
|
|
70427
|
+
if (this.keepFragmentSpreadNodes) {
|
|
70428
|
+
this.fragmentSpreads[selection.name.value] = selection;
|
|
70429
|
+
}
|
|
70430
|
+
if (!includeFragments) {
|
|
70250
70431
|
return;
|
|
70251
70432
|
}
|
|
70252
|
-
const definition = this.fragmentDefinitions[
|
|
70433
|
+
const definition = this.fragmentDefinitions[selection.name.value];
|
|
70253
70434
|
if (!definition) {
|
|
70254
70435
|
throw new HoudiniError({
|
|
70255
70436
|
filepath: this.filepath,
|
|
70256
|
-
message: "Could not find referenced fragment definition: " +
|
|
70437
|
+
message: "Could not find referenced fragment definition: " + selection.name.value + "\n" + JSON.stringify(Object.keys(this.fragmentDefinitions), null, 4)
|
|
70257
70438
|
});
|
|
70258
70439
|
}
|
|
70259
70440
|
this.add({
|
|
@@ -70272,19 +70453,35 @@ var FieldCollection = class {
|
|
|
70272
70453
|
});
|
|
70273
70454
|
}
|
|
70274
70455
|
}
|
|
70456
|
+
collectFragmentSpreads(selections, result = {}) {
|
|
70457
|
+
for (const selection of selections) {
|
|
70458
|
+
if (selection.kind === "Field") {
|
|
70459
|
+
continue;
|
|
70460
|
+
}
|
|
70461
|
+
if (selection.kind === "InlineFragment") {
|
|
70462
|
+
this.collectFragmentSpreads(selection.selectionSet.selections, result);
|
|
70463
|
+
continue;
|
|
70464
|
+
}
|
|
70465
|
+
if (selection.kind === "FragmentSpread") {
|
|
70466
|
+
result[selection.name.value] = selection;
|
|
70467
|
+
continue;
|
|
70468
|
+
}
|
|
70469
|
+
}
|
|
70470
|
+
return result;
|
|
70471
|
+
}
|
|
70275
70472
|
toSelectionSet() {
|
|
70276
|
-
return Object.values(this.inlineFragments).flatMap((
|
|
70277
|
-
if (
|
|
70473
|
+
return Object.values(this.inlineFragments).flatMap((fragment2) => {
|
|
70474
|
+
if (fragment2.selection.size === 0) {
|
|
70278
70475
|
return [];
|
|
70279
70476
|
}
|
|
70280
|
-
|
|
70281
|
-
...
|
|
70477
|
+
fragment2.astNode = {
|
|
70478
|
+
...fragment2.astNode,
|
|
70282
70479
|
selectionSet: {
|
|
70283
|
-
...
|
|
70284
|
-
selections:
|
|
70480
|
+
...fragment2.astNode.selectionSet,
|
|
70481
|
+
selections: fragment2.selection.toSelectionSet()
|
|
70285
70482
|
}
|
|
70286
70483
|
};
|
|
70287
|
-
return [
|
|
70484
|
+
return [fragment2.astNode];
|
|
70288
70485
|
}).concat(
|
|
70289
70486
|
Object.values(this.fields).map((field) => {
|
|
70290
70487
|
if (field.astNode.selectionSet) {
|
|
@@ -70294,15 +70491,15 @@ var FieldCollection = class {
|
|
|
70294
70491
|
})
|
|
70295
70492
|
).concat(Object.values(this.fragmentSpreads));
|
|
70296
70493
|
}
|
|
70297
|
-
walkInlineFragment(
|
|
70298
|
-
const key =
|
|
70494
|
+
walkInlineFragment(selection) {
|
|
70495
|
+
const key = selection.typeCondition.name.value;
|
|
70299
70496
|
if (!this.inlineFragments[key]) {
|
|
70300
70497
|
this.inlineFragments[key] = {
|
|
70301
|
-
astNode:
|
|
70498
|
+
astNode: selection,
|
|
70302
70499
|
selection: this.empty()
|
|
70303
70500
|
};
|
|
70304
70501
|
}
|
|
70305
|
-
for (const subselect of
|
|
70502
|
+
for (const subselect of selection.selectionSet.selections || []) {
|
|
70306
70503
|
if (subselect.kind !== "InlineFragment" || !subselect.typeCondition) {
|
|
70307
70504
|
this.inlineFragments[key].selection.add(subselect);
|
|
70308
70505
|
continue;
|
|
@@ -70316,8 +70513,8 @@ var FieldCollection = class {
|
|
|
70316
70513
|
fragmentDefinitions: this.fragmentDefinitions,
|
|
70317
70514
|
selections: [],
|
|
70318
70515
|
filepath: this.filepath,
|
|
70319
|
-
|
|
70320
|
-
|
|
70516
|
+
ignoreMaskDisable: this.ignoreMaskDisable,
|
|
70517
|
+
keepFragmentSpreadNodes: this.keepFragmentSpreadNodes
|
|
70321
70518
|
});
|
|
70322
70519
|
}
|
|
70323
70520
|
};
|
|
@@ -70395,13 +70592,13 @@ function murmurHash(str) {
|
|
|
70395
70592
|
// src/codegen/transforms/fragmentVariables.ts
|
|
70396
70593
|
var graphql5 = __toESM(require_graphql2(), 1);
|
|
70397
70594
|
|
|
70398
|
-
// src/codegen/transforms/
|
|
70595
|
+
// src/codegen/transforms/collectDefinitions.ts
|
|
70399
70596
|
var import_graphql30 = __toESM(require_graphql2(), 1);
|
|
70400
70597
|
async function includeFragmentDefinitions(config4, documents) {
|
|
70401
|
-
const fragments =
|
|
70598
|
+
const fragments = collectDefinitions(config4, documents);
|
|
70402
70599
|
for (const [index, { name, document, filename }] of documents.entries()) {
|
|
70403
70600
|
const operation = document.definitions.find(
|
|
70404
|
-
(
|
|
70601
|
+
(def) => def.kind === import_graphql30.Kind.OPERATION_DEFINITION || def.kind === "FragmentDefinition"
|
|
70405
70602
|
);
|
|
70406
70603
|
if (!operation) {
|
|
70407
70604
|
continue;
|
|
@@ -70420,7 +70617,7 @@ async function includeFragmentDefinitions(config4, documents) {
|
|
|
70420
70617
|
};
|
|
70421
70618
|
}
|
|
70422
70619
|
}
|
|
70423
|
-
function
|
|
70620
|
+
function collectDefinitions(config4, docs) {
|
|
70424
70621
|
return docs.reduce((acc, doc) => {
|
|
70425
70622
|
const definitions = doc.document.definitions.reduce(
|
|
70426
70623
|
(prev, definition) => definition.kind !== "FragmentDefinition" ? prev : {
|
|
@@ -70444,11 +70641,11 @@ function findRequiredFragments(selectionSet) {
|
|
|
70444
70641
|
return [];
|
|
70445
70642
|
}
|
|
70446
70643
|
const referencedFragments = [];
|
|
70447
|
-
for (const
|
|
70448
|
-
if (
|
|
70449
|
-
referencedFragments.push(
|
|
70450
|
-
} else if (
|
|
70451
|
-
referencedFragments.push(...findRequiredFragments(
|
|
70644
|
+
for (const selection of selectionSet.selections) {
|
|
70645
|
+
if (selection.kind === import_graphql30.Kind.FRAGMENT_SPREAD) {
|
|
70646
|
+
referencedFragments.push(selection.name.value);
|
|
70647
|
+
} else if (selection.selectionSet) {
|
|
70648
|
+
referencedFragments.push(...findRequiredFragments(selection.selectionSet));
|
|
70452
70649
|
}
|
|
70453
70650
|
}
|
|
70454
70651
|
return referencedFragments;
|
|
@@ -70481,7 +70678,7 @@ function flattenFragments(filepath, operation, fragments) {
|
|
|
70481
70678
|
// src/codegen/transforms/fragmentVariables.ts
|
|
70482
70679
|
var GraphqlKinds2 = graphql5.Kind;
|
|
70483
70680
|
async function fragmentVariables(config4, documents) {
|
|
70484
|
-
const fragments =
|
|
70681
|
+
const fragments = collectDefinitions(config4, documents);
|
|
70485
70682
|
const generatedFragments = {};
|
|
70486
70683
|
const visitedFragments = /* @__PURE__ */ new Set();
|
|
70487
70684
|
for (const doc2 of documents) {
|
|
@@ -70541,9 +70738,17 @@ function inlineFragmentArgs({
|
|
|
70541
70738
|
).reduce((acc, arg) => ({ ...acc, [arg.name]: arg }), {});
|
|
70542
70739
|
const result = graphql5.visit(document, {
|
|
70543
70740
|
FragmentSpread(node) {
|
|
70741
|
+
if (!fragmentDefinitions[node.name.value]) {
|
|
70742
|
+
throw new Error("Could not find definition for fragment" + node.name.value);
|
|
70743
|
+
}
|
|
70544
70744
|
const { definition } = fragmentDefinitions[node.name.value];
|
|
70545
70745
|
let { args, hash } = collectWithArguments(config4, filepath, node, scope);
|
|
70546
70746
|
const newFragmentName = `${node.name.value}${hash}`;
|
|
70747
|
+
config4.registerFragmentVariablesHash({
|
|
70748
|
+
hash: newFragmentName,
|
|
70749
|
+
fragment: node.name.value,
|
|
70750
|
+
args
|
|
70751
|
+
});
|
|
70547
70752
|
if (!visitedFragments.has(newFragmentName)) {
|
|
70548
70753
|
visitedFragments.add(newFragmentName);
|
|
70549
70754
|
const defaultArguments = collectDefaultArgumentValues(config4, filepath, definition);
|
|
@@ -70942,7 +71147,7 @@ function operationObject({
|
|
|
70942
71147
|
listName,
|
|
70943
71148
|
operationKind,
|
|
70944
71149
|
type,
|
|
70945
|
-
selection
|
|
71150
|
+
selection,
|
|
70946
71151
|
filepath
|
|
70947
71152
|
}) {
|
|
70948
71153
|
let parentID;
|
|
@@ -70950,7 +71155,7 @@ function operationObject({
|
|
|
70950
71155
|
let position = config4.internalListPosition;
|
|
70951
71156
|
let allLists = config4.defaultListTarget ?? void 0;
|
|
70952
71157
|
let operationWhen;
|
|
70953
|
-
const internalDirectives =
|
|
71158
|
+
const internalDirectives = selection.directives?.filter(
|
|
70954
71159
|
(directive) => config4.isInternalDirective(directive.name.value)
|
|
70955
71160
|
);
|
|
70956
71161
|
if (internalDirectives && internalDirectives.length > 0) {
|
|
@@ -71192,7 +71397,7 @@ async function paginate(config4, documents) {
|
|
|
71192
71397
|
let fragmentName = "";
|
|
71193
71398
|
let refetchQueryName = "";
|
|
71194
71399
|
let nodeQuery = false;
|
|
71195
|
-
let
|
|
71400
|
+
let fragment2 = "";
|
|
71196
71401
|
let paginateMode = config4.defaultPaginateMode;
|
|
71197
71402
|
doc.document = graphql10.visit(doc.document, {
|
|
71198
71403
|
OperationDefinition(node) {
|
|
@@ -71235,7 +71440,7 @@ async function paginate(config4, documents) {
|
|
|
71235
71440
|
};
|
|
71236
71441
|
},
|
|
71237
71442
|
FragmentDefinition(node) {
|
|
71238
|
-
|
|
71443
|
+
fragment2 = node.typeCondition.name.value;
|
|
71239
71444
|
fragmentName = node.name.value;
|
|
71240
71445
|
refetchQueryName = config4.paginationQueryName(fragmentName);
|
|
71241
71446
|
nodeQuery = node.typeCondition.name.value !== config4.schema.getQueryType()?.name;
|
|
@@ -71282,17 +71487,17 @@ async function paginate(config4, documents) {
|
|
|
71282
71487
|
}
|
|
71283
71488
|
});
|
|
71284
71489
|
let targetType = config4.schema.getQueryType()?.name || "";
|
|
71285
|
-
if (
|
|
71490
|
+
if (fragment2) {
|
|
71286
71491
|
const nodeInterface = config4.schema.getType("Node");
|
|
71287
71492
|
if (nodeInterface) {
|
|
71288
71493
|
const { objects, interfaces } = config4.schema.getImplementations(nodeInterface);
|
|
71289
|
-
if (objects.find((obj) => obj.name ===
|
|
71494
|
+
if (objects.find((obj) => obj.name === fragment2) || interfaces.find((int) => int.name === fragment2)) {
|
|
71290
71495
|
targetType = "Node";
|
|
71291
71496
|
} else {
|
|
71292
|
-
targetType =
|
|
71497
|
+
targetType = fragment2;
|
|
71293
71498
|
}
|
|
71294
71499
|
} else {
|
|
71295
|
-
targetType =
|
|
71500
|
+
targetType = fragment2;
|
|
71296
71501
|
}
|
|
71297
71502
|
}
|
|
71298
71503
|
const pageSize = flags.first.defaultValue ?? flags.last.defaultValue ?? flags.limit.defaultValue;
|
|
@@ -71314,7 +71519,7 @@ async function paginate(config4, documents) {
|
|
|
71314
71519
|
start,
|
|
71315
71520
|
mode: paginateMode
|
|
71316
71521
|
};
|
|
71317
|
-
if (!
|
|
71522
|
+
if (!fragment2) {
|
|
71318
71523
|
continue;
|
|
71319
71524
|
}
|
|
71320
71525
|
const paginationArgs = Object.entries(flags).filter(([_, { enabled }]) => enabled).map(([key, value]) => ({ name: key, ...value }));
|
|
@@ -71335,15 +71540,22 @@ async function paginate(config4, documents) {
|
|
|
71335
71540
|
["arguments"]: paginationArgs.map(
|
|
71336
71541
|
({ name }) => variableAsArgument(name)
|
|
71337
71542
|
)
|
|
71543
|
+
},
|
|
71544
|
+
{
|
|
71545
|
+
kind: graphql10.Kind.DIRECTIVE,
|
|
71546
|
+
name: {
|
|
71547
|
+
kind: "Name",
|
|
71548
|
+
value: config4.maskDisableDirective
|
|
71549
|
+
}
|
|
71338
71550
|
}
|
|
71339
71551
|
]
|
|
71340
71552
|
}
|
|
71341
71553
|
];
|
|
71342
|
-
const keys = config4.keyFieldsForType(!nodeQuery ? config4.schema.getQueryType()?.name || "" :
|
|
71343
|
-
if (
|
|
71554
|
+
const keys = config4.keyFieldsForType(!nodeQuery ? config4.schema.getQueryType()?.name || "" : fragment2).flatMap((key) => {
|
|
71555
|
+
if (fragment2 === config4.schema.getQueryType()?.name) {
|
|
71344
71556
|
return [];
|
|
71345
71557
|
}
|
|
71346
|
-
const fragmentType = config4.schema.getType(
|
|
71558
|
+
const fragmentType = config4.schema.getType(fragment2);
|
|
71347
71559
|
const { type, wrappers } = unwrapType(
|
|
71348
71560
|
config4,
|
|
71349
71561
|
fragmentType.getFields()[key].type
|
|
@@ -71355,7 +71567,7 @@ async function paginate(config4, documents) {
|
|
|
71355
71567
|
}
|
|
71356
71568
|
];
|
|
71357
71569
|
});
|
|
71358
|
-
const typeConfig = config4.typeConfig?.[
|
|
71570
|
+
const typeConfig = config4.typeConfig?.[fragment2];
|
|
71359
71571
|
const queryDoc = {
|
|
71360
71572
|
kind: graphql10.Kind.DOCUMENT,
|
|
71361
71573
|
definitions: [
|
|
@@ -71697,7 +71909,7 @@ async function addListFragments(config4, documents) {
|
|
|
71697
71909
|
);
|
|
71698
71910
|
const targetField = ancestors[ancestors.length - 1];
|
|
71699
71911
|
const targetFieldDefinition = parentType.getFields()[targetField.name.value];
|
|
71700
|
-
const { selection
|
|
71912
|
+
const { selection, type, connection } = connectionSelection(
|
|
71701
71913
|
config4,
|
|
71702
71914
|
targetFieldDefinition,
|
|
71703
71915
|
parentTypeFromAncestors(
|
|
@@ -71708,7 +71920,7 @@ async function addListFragments(config4, documents) {
|
|
|
71708
71920
|
ancestors[ancestors.length - 1].selectionSet
|
|
71709
71921
|
);
|
|
71710
71922
|
lists[nameArg.value.value] = {
|
|
71711
|
-
selection
|
|
71923
|
+
selection,
|
|
71712
71924
|
type,
|
|
71713
71925
|
filename: doc.filename
|
|
71714
71926
|
};
|
|
@@ -71786,14 +71998,14 @@ async function addListFragments(config4, documents) {
|
|
|
71786
71998
|
const generatedDoc = {
|
|
71787
71999
|
kind: graphql11.Kind.DOCUMENT,
|
|
71788
72000
|
definitions: Object.entries(lists).flatMap(
|
|
71789
|
-
([name, { selection
|
|
72001
|
+
([name, { selection, type }]) => {
|
|
71790
72002
|
const schemaType = config4.schema.getType(type.name);
|
|
71791
|
-
if (!
|
|
72003
|
+
if (!selection) {
|
|
71792
72004
|
throw new HoudiniError({ message: "Lists must have a selection" });
|
|
71793
72005
|
}
|
|
71794
72006
|
const fragmentSelection = {
|
|
71795
72007
|
kind: graphql11.Kind.SELECTION_SET,
|
|
71796
|
-
selections: [...
|
|
72008
|
+
selections: [...selection.selections]
|
|
71797
72009
|
};
|
|
71798
72010
|
if (schemaType && fragmentSelection && !fragmentSelection?.selections.find(
|
|
71799
72011
|
(field) => field.kind === "Field" && config4.keyFieldsForType(type.name).includes(field.name.value)
|
|
@@ -71885,7 +72097,7 @@ async function addListFragments(config4, documents) {
|
|
|
71885
72097
|
artifact: null
|
|
71886
72098
|
});
|
|
71887
72099
|
}
|
|
71888
|
-
function connectionSelection(config4, field, type,
|
|
72100
|
+
function connectionSelection(config4, field, type, selection) {
|
|
71889
72101
|
const fieldArgs = field.args.reduce(
|
|
71890
72102
|
(args, arg) => ({
|
|
71891
72103
|
...args,
|
|
@@ -71894,34 +72106,34 @@ function connectionSelection(config4, field, type, selection2) {
|
|
|
71894
72106
|
{}
|
|
71895
72107
|
);
|
|
71896
72108
|
if (fieldArgs["limit"]) {
|
|
71897
|
-
return { selection
|
|
72109
|
+
return { selection, type, connection: false, error: null };
|
|
71898
72110
|
}
|
|
71899
72111
|
const forwardPagination = fieldArgs["first"] === "Int" && ["Cursor", "String"].includes(fieldArgs["after"]);
|
|
71900
72112
|
const backwardsPagination = fieldArgs["last"] === "Int" && ["Cursor", "String"].includes(fieldArgs["before"]);
|
|
71901
72113
|
if (!forwardPagination && !backwardsPagination) {
|
|
71902
|
-
return { selection
|
|
72114
|
+
return { selection, type, connection: false, error: missingPaginationArgMessage(config4) };
|
|
71903
72115
|
}
|
|
71904
|
-
const edgesField =
|
|
71905
|
-
(
|
|
72116
|
+
const edgesField = selection?.selections.find(
|
|
72117
|
+
(selection2) => selection2.kind === "Field" && selection2.name.value === "edges"
|
|
71906
72118
|
);
|
|
71907
72119
|
if (!edgesField) {
|
|
71908
|
-
return { selection
|
|
72120
|
+
return { selection, type, connection: false, error: missingEdgeSelectionMessage(config4) };
|
|
71909
72121
|
}
|
|
71910
72122
|
const nodeSelection = edgesField.selectionSet?.selections.find(
|
|
71911
|
-
(
|
|
72123
|
+
(selection2) => selection2.kind === "Field" && selection2.name.value === "node"
|
|
71912
72124
|
);
|
|
71913
72125
|
if (!nodeSelection.selectionSet) {
|
|
71914
|
-
return { selection
|
|
72126
|
+
return { selection, type, connection: false, error: missingNodeSelectionMessage(config4) };
|
|
71915
72127
|
}
|
|
71916
72128
|
const edgeField = unwrapType(config4, field.type).type.getFields()["edges"];
|
|
71917
72129
|
const { wrappers, type: edgeFieldType } = unwrapType(config4, edgeField.type);
|
|
71918
72130
|
const list = wrappers[wrappers.length - 2] === "List" /* List */;
|
|
71919
72131
|
if (!list) {
|
|
71920
|
-
return { selection
|
|
72132
|
+
return { selection, type, connection: false, error: edgeInvalidTypeMessage(config4) };
|
|
71921
72133
|
}
|
|
71922
72134
|
const nodeField = edgeFieldType.getFields()["node"];
|
|
71923
72135
|
if (!nodeField) {
|
|
71924
|
-
return { selection
|
|
72136
|
+
return { selection, type, connection: false, error: nodeNotDefinedMessage(config4) };
|
|
71925
72137
|
}
|
|
71926
72138
|
return {
|
|
71927
72139
|
selection: nodeSelection.selectionSet,
|
|
@@ -72000,59 +72212,45 @@ function fieldKey(config4, field) {
|
|
|
72000
72212
|
}
|
|
72001
72213
|
|
|
72002
72214
|
// src/codegen/generators/artifacts/selection.ts
|
|
72003
|
-
function
|
|
72215
|
+
function selection_default(args) {
|
|
72216
|
+
const typeMap = {};
|
|
72217
|
+
const abstractTypes = [];
|
|
72218
|
+
return mergeSelection({
|
|
72219
|
+
object: prepareSelection({ ...args, typeMap, abstractTypes }),
|
|
72220
|
+
filepath: args.filepath,
|
|
72221
|
+
typeMap,
|
|
72222
|
+
abstractTypes
|
|
72223
|
+
});
|
|
72224
|
+
}
|
|
72225
|
+
function prepareSelection({
|
|
72004
72226
|
config: config4,
|
|
72005
72227
|
filepath,
|
|
72006
72228
|
rootType,
|
|
72007
72229
|
selections,
|
|
72008
72230
|
operations,
|
|
72009
72231
|
path: path2 = [],
|
|
72010
|
-
includeFragments,
|
|
72011
72232
|
document,
|
|
72012
|
-
inConnection
|
|
72233
|
+
inConnection,
|
|
72234
|
+
typeMap,
|
|
72235
|
+
abstractTypes
|
|
72013
72236
|
}) {
|
|
72014
72237
|
let object = {};
|
|
72015
|
-
const typeMap = {};
|
|
72016
|
-
const abstractTypes = [];
|
|
72017
72238
|
for (const field of selections) {
|
|
72018
|
-
if (field.kind === "
|
|
72019
|
-
const fragmentDefinition = document.document.definitions.find(
|
|
72020
|
-
(defn) => defn.kind === "FragmentDefinition" && defn.name.value === field.name.value
|
|
72021
|
-
);
|
|
72022
|
-
if (!fragmentDefinition) {
|
|
72023
|
-
throw new HoudiniError({
|
|
72024
|
-
filepath,
|
|
72025
|
-
message: "selection: could not find definition for fragment " + field.name.value
|
|
72026
|
-
});
|
|
72027
|
-
}
|
|
72028
|
-
object = deepMerge(
|
|
72029
|
-
filepath,
|
|
72030
|
-
object,
|
|
72031
|
-
selection({
|
|
72032
|
-
config: config4,
|
|
72033
|
-
filepath,
|
|
72034
|
-
rootType: fragmentDefinition.typeCondition.name.value,
|
|
72035
|
-
operations,
|
|
72036
|
-
selections: fragmentDefinition.selectionSet.selections,
|
|
72037
|
-
path: path2,
|
|
72038
|
-
includeFragments,
|
|
72039
|
-
document
|
|
72040
|
-
})
|
|
72041
|
-
);
|
|
72042
|
-
} else if (field.kind === "InlineFragment") {
|
|
72239
|
+
if (field.kind === "InlineFragment") {
|
|
72043
72240
|
if (!field.typeCondition || field.typeCondition.name.value === rootType) {
|
|
72044
72241
|
object.fields = deepMerge(
|
|
72045
72242
|
filepath,
|
|
72046
72243
|
object.fields || {},
|
|
72047
|
-
|
|
72244
|
+
prepareSelection({
|
|
72048
72245
|
config: config4,
|
|
72049
72246
|
filepath,
|
|
72050
72247
|
rootType: field.typeCondition?.name.value || rootType,
|
|
72051
72248
|
operations,
|
|
72052
72249
|
selections: field.selectionSet.selections,
|
|
72053
72250
|
path: path2,
|
|
72054
|
-
|
|
72055
|
-
|
|
72251
|
+
document,
|
|
72252
|
+
typeMap,
|
|
72253
|
+
abstractTypes
|
|
72056
72254
|
}).fields || {}
|
|
72057
72255
|
);
|
|
72058
72256
|
} else {
|
|
@@ -72090,15 +72288,16 @@ function selection({
|
|
|
72090
72288
|
}
|
|
72091
72289
|
object.abstractFields.fields = {
|
|
72092
72290
|
...object.abstractFields.fields,
|
|
72093
|
-
[field.typeCondition.name.value]:
|
|
72291
|
+
[field.typeCondition.name.value]: prepareSelection({
|
|
72094
72292
|
config: config4,
|
|
72095
72293
|
filepath,
|
|
72096
72294
|
rootType: field.typeCondition?.name.value || rootType,
|
|
72097
72295
|
operations,
|
|
72098
72296
|
selections: field.selectionSet.selections,
|
|
72099
72297
|
path: path2,
|
|
72100
|
-
|
|
72101
|
-
|
|
72298
|
+
document,
|
|
72299
|
+
typeMap,
|
|
72300
|
+
abstractTypes
|
|
72102
72301
|
}).fields
|
|
72103
72302
|
};
|
|
72104
72303
|
}
|
|
@@ -72119,10 +72318,14 @@ function selection({
|
|
|
72119
72318
|
}
|
|
72120
72319
|
const typeName = fieldType.toString();
|
|
72121
72320
|
const pathSoFar = path2.concat(attributeName);
|
|
72122
|
-
const
|
|
72321
|
+
const keys = config4.keyFieldsForType(rootType);
|
|
72322
|
+
let fieldObj = {
|
|
72123
72323
|
type: typeName,
|
|
72124
72324
|
keyRaw: fieldKey(config4, field)
|
|
72125
72325
|
};
|
|
72326
|
+
if (keys.includes(field.name.value)) {
|
|
72327
|
+
fieldObj.visible = true;
|
|
72328
|
+
}
|
|
72126
72329
|
if (nullable) {
|
|
72127
72330
|
fieldObj.nullable = true;
|
|
72128
72331
|
}
|
|
@@ -72170,16 +72373,17 @@ function selection({
|
|
|
72170
72373
|
}
|
|
72171
72374
|
if (field.selectionSet) {
|
|
72172
72375
|
const connectionState = paginated && document.refetch?.method === "cursor" || continueConnection;
|
|
72173
|
-
fieldObj.selection =
|
|
72376
|
+
fieldObj.selection = prepareSelection({
|
|
72174
72377
|
config: config4,
|
|
72175
72378
|
filepath,
|
|
72176
72379
|
rootType: typeName,
|
|
72177
72380
|
selections: field.selectionSet.selections,
|
|
72178
72381
|
operations,
|
|
72179
72382
|
path: pathSoFar,
|
|
72180
|
-
includeFragments,
|
|
72181
72383
|
document,
|
|
72182
|
-
inConnection: connectionState
|
|
72384
|
+
inConnection: connectionState,
|
|
72385
|
+
typeMap,
|
|
72386
|
+
abstractTypes
|
|
72183
72387
|
});
|
|
72184
72388
|
}
|
|
72185
72389
|
if (field.arguments?.length && fieldObj.list) {
|
|
@@ -72194,12 +72398,29 @@ function selection({
|
|
|
72194
72398
|
if (graphql13.isInterfaceType(fieldType) || graphql13.isUnionType(fieldType)) {
|
|
72195
72399
|
fieldObj.abstract = true;
|
|
72196
72400
|
}
|
|
72401
|
+
if (object.fields?.[attributeName]) {
|
|
72402
|
+
fieldObj = deepMerge(filepath, object.fields[attributeName], fieldObj);
|
|
72403
|
+
}
|
|
72197
72404
|
object.fields = {
|
|
72198
72405
|
...object.fields,
|
|
72199
72406
|
[attributeName]: fieldObj
|
|
72200
72407
|
};
|
|
72408
|
+
} else if (field.kind === "FragmentSpread") {
|
|
72409
|
+
const { fragment: fragment2, args } = config4.getFragmentVariablesHash(field.name.value);
|
|
72410
|
+
object.fragments = {
|
|
72411
|
+
...object.fragments,
|
|
72412
|
+
[fragment2]: args ?? {}
|
|
72413
|
+
};
|
|
72201
72414
|
}
|
|
72202
72415
|
}
|
|
72416
|
+
return object;
|
|
72417
|
+
}
|
|
72418
|
+
function mergeSelection({
|
|
72419
|
+
filepath,
|
|
72420
|
+
object,
|
|
72421
|
+
typeMap,
|
|
72422
|
+
abstractTypes
|
|
72423
|
+
}) {
|
|
72203
72424
|
if (Object.keys(object.fields || {}).length > 0 && object.abstractFields && Object.keys(object.abstractFields.fields).length > 0) {
|
|
72204
72425
|
for (const [typeName, possibles] of Object.entries(typeMap)) {
|
|
72205
72426
|
let overlap = false;
|
|
@@ -72207,8 +72428,8 @@ function selection({
|
|
|
72207
72428
|
if (object.abstractFields.fields[typeName]) {
|
|
72208
72429
|
object.abstractFields.fields[typeName] = deepMerge(
|
|
72209
72430
|
filepath,
|
|
72210
|
-
object.abstractFields.fields[typeName]
|
|
72211
|
-
object.abstractFields.fields[possible]
|
|
72431
|
+
object.abstractFields.fields[typeName] ?? {},
|
|
72432
|
+
object.abstractFields.fields[possible] ?? {}
|
|
72212
72433
|
);
|
|
72213
72434
|
overlap = true;
|
|
72214
72435
|
}
|
|
@@ -72239,6 +72460,30 @@ function selection({
|
|
|
72239
72460
|
}
|
|
72240
72461
|
}
|
|
72241
72462
|
}
|
|
72463
|
+
for (const [key, value] of Object.entries(object.fields ?? {})) {
|
|
72464
|
+
const selection = value.selection;
|
|
72465
|
+
if (selection) {
|
|
72466
|
+
mergeSelection({
|
|
72467
|
+
filepath,
|
|
72468
|
+
typeMap,
|
|
72469
|
+
abstractTypes,
|
|
72470
|
+
object: selection
|
|
72471
|
+
});
|
|
72472
|
+
}
|
|
72473
|
+
}
|
|
72474
|
+
for (const [type, selection] of Object.entries(object.abstractFields?.fields ?? {})) {
|
|
72475
|
+
for (const [key, value] of Object.entries(selection ?? {})) {
|
|
72476
|
+
const selection2 = value.selection;
|
|
72477
|
+
if (selection2) {
|
|
72478
|
+
mergeSelection({
|
|
72479
|
+
filepath,
|
|
72480
|
+
typeMap,
|
|
72481
|
+
abstractTypes,
|
|
72482
|
+
object: selection2
|
|
72483
|
+
});
|
|
72484
|
+
}
|
|
72485
|
+
}
|
|
72486
|
+
}
|
|
72242
72487
|
return object;
|
|
72243
72488
|
}
|
|
72244
72489
|
|
|
@@ -72303,7 +72548,12 @@ function artifactGenerator(stats) {
|
|
|
72303
72548
|
writeIndexFile(config4, docs)
|
|
72304
72549
|
].concat(
|
|
72305
72550
|
docs.map(async (doc) => {
|
|
72306
|
-
const {
|
|
72551
|
+
const {
|
|
72552
|
+
document,
|
|
72553
|
+
name,
|
|
72554
|
+
generateArtifact,
|
|
72555
|
+
originalParsed
|
|
72556
|
+
} = doc;
|
|
72307
72557
|
if (!generateArtifact) {
|
|
72308
72558
|
return;
|
|
72309
72559
|
}
|
|
@@ -72342,6 +72592,16 @@ function artifactGenerator(stats) {
|
|
|
72342
72592
|
);
|
|
72343
72593
|
let rootType = "";
|
|
72344
72594
|
let selectionSet;
|
|
72595
|
+
let originalSelectionSet = null;
|
|
72596
|
+
const fragmentDefinitions = doc.document.definitions.filter(
|
|
72597
|
+
(definition) => definition.kind === "FragmentDefinition"
|
|
72598
|
+
).reduce(
|
|
72599
|
+
(prev, definition) => ({
|
|
72600
|
+
...prev,
|
|
72601
|
+
[definition.name.value]: definition
|
|
72602
|
+
}),
|
|
72603
|
+
{}
|
|
72604
|
+
);
|
|
72345
72605
|
if (docKind !== ArtifactKind.Fragment) {
|
|
72346
72606
|
const operation = operations[0];
|
|
72347
72607
|
if (operation.operation === "query") {
|
|
@@ -72358,9 +72618,12 @@ function artifactGenerator(stats) {
|
|
|
72358
72618
|
});
|
|
72359
72619
|
}
|
|
72360
72620
|
selectionSet = operation.selectionSet;
|
|
72621
|
+
if (originalParsed.definitions[0].kind === "OperationDefinition") {
|
|
72622
|
+
originalSelectionSet = originalParsed.definitions[0].selectionSet;
|
|
72623
|
+
}
|
|
72361
72624
|
} else {
|
|
72362
72625
|
const matchingFragment = fragments.find(
|
|
72363
|
-
(
|
|
72626
|
+
(fragment2) => fragment2.name.value === name
|
|
72364
72627
|
);
|
|
72365
72628
|
if (!matchingFragment) {
|
|
72366
72629
|
throw new HoudiniError({
|
|
@@ -72370,6 +72633,12 @@ function artifactGenerator(stats) {
|
|
|
72370
72633
|
}
|
|
72371
72634
|
rootType = matchingFragment.typeCondition.name.value;
|
|
72372
72635
|
selectionSet = matchingFragment.selectionSet;
|
|
72636
|
+
if (originalParsed.definitions[0].kind === "FragmentDefinition") {
|
|
72637
|
+
originalSelectionSet = originalParsed.definitions[0].selectionSet;
|
|
72638
|
+
}
|
|
72639
|
+
}
|
|
72640
|
+
if (!originalSelectionSet) {
|
|
72641
|
+
throw new Error("Not original selection set!");
|
|
72373
72642
|
}
|
|
72374
72643
|
let inputs = operations[0]?.variableDefinitions;
|
|
72375
72644
|
let directive = fragments[0]?.directives?.find(
|
|
@@ -72378,21 +72647,18 @@ function artifactGenerator(stats) {
|
|
|
72378
72647
|
if (docKind === ArtifactKind.Fragment && directive) {
|
|
72379
72648
|
inputs = fragmentArgumentsDefinitions(config4, doc.filename, fragments[0]);
|
|
72380
72649
|
}
|
|
72381
|
-
const
|
|
72650
|
+
const mask = selection_default({
|
|
72382
72651
|
config: config4,
|
|
72383
72652
|
filepath: doc.filename,
|
|
72384
|
-
|
|
72385
|
-
|
|
72386
|
-
|
|
72387
|
-
|
|
72388
|
-
|
|
72389
|
-
|
|
72390
|
-
|
|
72391
|
-
|
|
72392
|
-
|
|
72393
|
-
),
|
|
72394
|
-
ignoreMaskDisable: docKind === "HoudiniQuery",
|
|
72395
|
-
applyFragments: docKind !== "HoudiniFragment"
|
|
72653
|
+
rootType,
|
|
72654
|
+
operations: {},
|
|
72655
|
+
document: doc,
|
|
72656
|
+
selections: flattenSelections({
|
|
72657
|
+
config: config4,
|
|
72658
|
+
filepath: doc.filename,
|
|
72659
|
+
selections: selectionSet.selections,
|
|
72660
|
+
fragmentDefinitions
|
|
72661
|
+
})
|
|
72396
72662
|
});
|
|
72397
72663
|
let artifact = {
|
|
72398
72664
|
name,
|
|
@@ -72401,21 +72667,29 @@ function artifactGenerator(stats) {
|
|
|
72401
72667
|
refetch: doc.refetch,
|
|
72402
72668
|
raw: rawString,
|
|
72403
72669
|
rootType,
|
|
72404
|
-
selection:
|
|
72670
|
+
selection: selection_default({
|
|
72405
72671
|
config: config4,
|
|
72406
72672
|
filepath: doc.filename,
|
|
72407
72673
|
rootType,
|
|
72408
|
-
selections:
|
|
72674
|
+
selections: flattenSelections({
|
|
72675
|
+
config: config4,
|
|
72676
|
+
filepath: doc.filename,
|
|
72677
|
+
selections: selectionSet.selections,
|
|
72678
|
+
fragmentDefinitions,
|
|
72679
|
+
ignoreMaskDisable: docKind !== "HoudiniFragment",
|
|
72680
|
+
keepFragmentSpreadNodes: true
|
|
72681
|
+
}),
|
|
72409
72682
|
operations: operationsByPath(
|
|
72410
72683
|
config4,
|
|
72411
72684
|
doc.filename,
|
|
72412
72685
|
operations[0],
|
|
72413
72686
|
filterTypes
|
|
72414
72687
|
),
|
|
72415
|
-
includeFragments: docKind !== "HoudiniFragment",
|
|
72416
72688
|
document: doc
|
|
72417
|
-
})
|
|
72689
|
+
}),
|
|
72690
|
+
pluginData: {}
|
|
72418
72691
|
};
|
|
72692
|
+
applyMask(config4, artifact.selection, mask);
|
|
72419
72693
|
artifact.pluginData = {};
|
|
72420
72694
|
for (const plugin2 of config4.plugins) {
|
|
72421
72695
|
if (!plugin2.artifactData) {
|
|
@@ -72492,6 +72766,49 @@ function artifactGenerator(stats) {
|
|
|
72492
72766
|
stats.deleted = await cleanupFiles(config4.artifactDirectory, listOfArtifacts);
|
|
72493
72767
|
};
|
|
72494
72768
|
}
|
|
72769
|
+
function applyMask(config4, target, mask) {
|
|
72770
|
+
for (const [fieldName, value] of Object.entries(mask.fields ?? {})) {
|
|
72771
|
+
const targetSelection = target.fields?.[fieldName];
|
|
72772
|
+
if (!targetSelection || !mask.fields) {
|
|
72773
|
+
continue;
|
|
72774
|
+
}
|
|
72775
|
+
targetSelection.visible = true;
|
|
72776
|
+
if (targetSelection.selection && value.selection) {
|
|
72777
|
+
applyMask(config4, targetSelection.selection, value.selection);
|
|
72778
|
+
}
|
|
72779
|
+
}
|
|
72780
|
+
for (const [type, selection] of Object.entries(mask.abstractFields?.fields ?? {})) {
|
|
72781
|
+
if (!selection) {
|
|
72782
|
+
continue;
|
|
72783
|
+
}
|
|
72784
|
+
if (target.abstractFields?.fields[type]) {
|
|
72785
|
+
applyMask(config4, { fields: target.abstractFields.fields[type] }, { fields: selection });
|
|
72786
|
+
}
|
|
72787
|
+
const targetType = config4.schema.getType(type);
|
|
72788
|
+
if (!targetType) {
|
|
72789
|
+
continue;
|
|
72790
|
+
}
|
|
72791
|
+
if (graphql14.isAbstractType(targetType)) {
|
|
72792
|
+
for (const possible of config4.schema.getPossibleTypes(targetType)) {
|
|
72793
|
+
if (target.abstractFields?.fields[possible.name]) {
|
|
72794
|
+
applyMask(
|
|
72795
|
+
config4,
|
|
72796
|
+
{ fields: target.abstractFields.fields[possible.name] },
|
|
72797
|
+
{ fields: selection }
|
|
72798
|
+
);
|
|
72799
|
+
}
|
|
72800
|
+
}
|
|
72801
|
+
}
|
|
72802
|
+
const mappedType = target.abstractFields?.typeMap[type];
|
|
72803
|
+
if (target.abstractFields && mappedType && target.abstractFields.fields[mappedType]) {
|
|
72804
|
+
applyMask(
|
|
72805
|
+
config4,
|
|
72806
|
+
{ fields: target.abstractFields.fields[mappedType] },
|
|
72807
|
+
{ fields: selection }
|
|
72808
|
+
);
|
|
72809
|
+
}
|
|
72810
|
+
}
|
|
72811
|
+
}
|
|
72495
72812
|
|
|
72496
72813
|
// src/codegen/generators/runtime/graphqlFunction.ts
|
|
72497
72814
|
var recast6 = __toESM(require_main2(), 1);
|
|
@@ -72817,7 +73134,7 @@ function addReferencedInputTypes(config4, filepath, body, visitedTypes, missingS
|
|
|
72817
73134
|
var graphql18 = __toESM(require_graphql2(), 1);
|
|
72818
73135
|
var recast10 = __toESM(require_main2(), 1);
|
|
72819
73136
|
var AST10 = recast10.types.builders;
|
|
72820
|
-
var
|
|
73137
|
+
var fragmentKey2 = " $fragments";
|
|
72821
73138
|
function inlineType({
|
|
72822
73139
|
config: config4,
|
|
72823
73140
|
filepath,
|
|
@@ -72857,24 +73174,24 @@ function inlineType({
|
|
|
72857
73174
|
const rootObj = type;
|
|
72858
73175
|
const inlineFragments = {};
|
|
72859
73176
|
const selectedFields = [];
|
|
72860
|
-
for (const
|
|
72861
|
-
if (
|
|
72862
|
-
const fragmentType = config4.schema.getType(
|
|
73177
|
+
for (const selection of selections) {
|
|
73178
|
+
if (selection.kind === "InlineFragment" && selection.typeCondition) {
|
|
73179
|
+
const fragmentType = config4.schema.getType(selection.typeCondition.name.value);
|
|
72863
73180
|
if (!graphql18.isInterfaceType(type) && !graphql18.isUnionType(type)) {
|
|
72864
|
-
selectedFields.push(...
|
|
73181
|
+
selectedFields.push(...selection.selectionSet.selections);
|
|
72865
73182
|
continue;
|
|
72866
73183
|
}
|
|
72867
73184
|
if (!graphql18.isInterfaceType(fragmentType) && !graphql18.isUnionType(fragmentType)) {
|
|
72868
73185
|
if (!inlineFragments[fragmentType.name]) {
|
|
72869
73186
|
inlineFragments[fragmentType.name] = [];
|
|
72870
73187
|
}
|
|
72871
|
-
inlineFragments[fragmentType.name].push(...
|
|
73188
|
+
inlineFragments[fragmentType.name].push(...selection.selectionSet.selections);
|
|
72872
73189
|
continue;
|
|
72873
73190
|
}
|
|
72874
73191
|
const possibleParents = config4.schema.getPossibleTypes(type).map((t2) => t2.name);
|
|
72875
73192
|
const freeSelections = [];
|
|
72876
73193
|
const typeSpecificSelections = {};
|
|
72877
|
-
for (const node of
|
|
73194
|
+
for (const node of selection.selectionSet.selections) {
|
|
72878
73195
|
if (node.kind !== "InlineFragment") {
|
|
72879
73196
|
freeSelections.push(node);
|
|
72880
73197
|
} else if (node.typeCondition) {
|
|
@@ -72897,23 +73214,30 @@ function inlineType({
|
|
|
72897
73214
|
);
|
|
72898
73215
|
}
|
|
72899
73216
|
}
|
|
72900
|
-
} else if (
|
|
72901
|
-
selectedFields.push(...
|
|
73217
|
+
} else if (selection.kind === "InlineFragment" && !selection.typeCondition) {
|
|
73218
|
+
selectedFields.push(...selection.selectionSet.selections);
|
|
72902
73219
|
} else {
|
|
72903
|
-
selectedFields.push(
|
|
73220
|
+
selectedFields.push(selection);
|
|
72904
73221
|
}
|
|
72905
73222
|
}
|
|
73223
|
+
const fields = Object.values(
|
|
73224
|
+
selectedFields.filter((field) => field.kind === "Field").reduce(
|
|
73225
|
+
(sel, field) => ({
|
|
73226
|
+
...sel,
|
|
73227
|
+
[field.alias?.value ?? field.name.value]: field
|
|
73228
|
+
}),
|
|
73229
|
+
{}
|
|
73230
|
+
)
|
|
73231
|
+
);
|
|
72906
73232
|
result = AST10.tsTypeLiteral([
|
|
72907
|
-
...(
|
|
72908
|
-
|
|
72909
|
-
|
|
72910
|
-
const { field } = selectionTypeInfo(config4.schema, filepath, rootObj, selection2);
|
|
72911
|
-
const attributeName = selection2.alias?.value || selection2.name.value;
|
|
73233
|
+
...fields.map((selection) => {
|
|
73234
|
+
const { field } = selectionTypeInfo(config4.schema, filepath, rootObj, selection);
|
|
73235
|
+
const attributeName = selection.alias?.value || selection.name.value;
|
|
72912
73236
|
let attributeType = inlineType({
|
|
72913
73237
|
config: config4,
|
|
72914
73238
|
filepath,
|
|
72915
73239
|
rootType: field.type,
|
|
72916
|
-
selections:
|
|
73240
|
+
selections: selection.selectionSet?.selections,
|
|
72917
73241
|
root: false,
|
|
72918
73242
|
allowReadonly,
|
|
72919
73243
|
visitedTypes,
|
|
@@ -72922,7 +73246,7 @@ function inlineType({
|
|
|
72922
73246
|
includeFragments,
|
|
72923
73247
|
allOptional
|
|
72924
73248
|
});
|
|
72925
|
-
const hasIncludeOrSkipDirective =
|
|
73249
|
+
const hasIncludeOrSkipDirective = selection.directives && selection.directives.filter(
|
|
72926
73250
|
(directive) => directive.name.value === "include" || directive.name.value === "skip"
|
|
72927
73251
|
).length > 0;
|
|
72928
73252
|
if (hasIncludeOrSkipDirective) {
|
|
@@ -72946,15 +73270,13 @@ function inlineType({
|
|
|
72946
73270
|
result.members.push(
|
|
72947
73271
|
readonlyProperty(
|
|
72948
73272
|
AST10.tsPropertySignature(
|
|
72949
|
-
AST10.
|
|
73273
|
+
AST10.stringLiteral(fragmentKey2),
|
|
72950
73274
|
AST10.tsTypeAnnotation(
|
|
72951
73275
|
AST10.tsTypeLiteral(
|
|
72952
73276
|
(fragmentSpreads || []).map(
|
|
72953
73277
|
(fragmentSpread) => AST10.tsPropertySignature(
|
|
72954
73278
|
AST10.identifier(fragmentSpread.name.value),
|
|
72955
|
-
AST10.tsTypeAnnotation(
|
|
72956
|
-
AST10.tsLiteralType(AST10.booleanLiteral(true))
|
|
72957
|
-
)
|
|
73279
|
+
AST10.tsTypeAnnotation(AST10.tsTypeLiteral([]))
|
|
72958
73280
|
)
|
|
72959
73281
|
)
|
|
72960
73282
|
)
|
|
@@ -72964,7 +73286,7 @@ function inlineType({
|
|
|
72964
73286
|
)
|
|
72965
73287
|
);
|
|
72966
73288
|
}
|
|
72967
|
-
const inlineFragmentSelections = Object.entries(inlineFragments).flatMap(([typeName,
|
|
73289
|
+
const inlineFragmentSelections = Object.entries(inlineFragments).flatMap(([typeName, fragment2]) => {
|
|
72968
73290
|
const fragmentRootType = config4.schema.getType(typeName);
|
|
72969
73291
|
if (!fragmentRootType) {
|
|
72970
73292
|
return [];
|
|
@@ -72973,7 +73295,7 @@ function inlineType({
|
|
|
72973
73295
|
config: config4,
|
|
72974
73296
|
filepath,
|
|
72975
73297
|
rootType: fragmentRootType,
|
|
72976
|
-
selections:
|
|
73298
|
+
selections: fragment2,
|
|
72977
73299
|
allowReadonly,
|
|
72978
73300
|
visitedTypes,
|
|
72979
73301
|
root,
|
|
@@ -73045,10 +73367,10 @@ function inlineType({
|
|
|
73045
73367
|
}
|
|
73046
73368
|
return result;
|
|
73047
73369
|
}
|
|
73048
|
-
function selectionTypeInfo(schema, filepath, rootType,
|
|
73049
|
-
const selectionName =
|
|
73370
|
+
function selectionTypeInfo(schema, filepath, rootType, selection) {
|
|
73371
|
+
const selectionName = selection.name.value;
|
|
73050
73372
|
let fields = {};
|
|
73051
|
-
if (
|
|
73373
|
+
if (selection.kind === "Field" && selection.name.value === "__typename") {
|
|
73052
73374
|
return {
|
|
73053
73375
|
field: {
|
|
73054
73376
|
name: "__typename",
|
|
@@ -73119,7 +73441,7 @@ async function generateDocumentTypes(config4, docs) {
|
|
|
73119
73441
|
filepath: filename,
|
|
73120
73442
|
selections: definition.selectionSet.selections,
|
|
73121
73443
|
fragmentDefinitions,
|
|
73122
|
-
|
|
73444
|
+
keepFragmentSpreadNodes: true
|
|
73123
73445
|
});
|
|
73124
73446
|
if (definition?.kind === "OperationDefinition") {
|
|
73125
73447
|
await generateOperationTypeDefs(
|
|
@@ -73343,39 +73665,26 @@ async function generateFragmentTypeDefs(config4, filepath, body, selections, def
|
|
|
73343
73665
|
if (!type) {
|
|
73344
73666
|
throw new Error("Should not get here");
|
|
73345
73667
|
}
|
|
73346
|
-
let extraExports = [];
|
|
73347
73668
|
let directive = definition.directives?.find(
|
|
73348
73669
|
(directive2) => directive2.name.value === config4.argumentsDirective
|
|
73349
73670
|
);
|
|
73350
|
-
|
|
73351
|
-
|
|
73352
|
-
|
|
73353
|
-
AST11.
|
|
73354
|
-
AST11.identifier(
|
|
73355
|
-
AST11.
|
|
73356
|
-
(
|
|
73357
|
-
|
|
73358
|
-
|
|
73359
|
-
|
|
73360
|
-
|
|
73361
|
-
|
|
73362
|
-
|
|
73363
|
-
missingScalars,
|
|
73364
|
-
definition2,
|
|
73365
|
-
body
|
|
73366
|
-
)
|
|
73367
|
-
),
|
|
73368
|
-
definition2.type.kind !== "NonNullType"
|
|
73369
|
-
);
|
|
73370
|
-
}
|
|
73371
|
-
)
|
|
73372
|
-
)
|
|
73373
|
-
)
|
|
73374
|
-
)
|
|
73375
|
-
);
|
|
73376
|
-
}
|
|
73671
|
+
let inputValue = !directive ? AST11.tsTypeLiteral([]) : AST11.tsTypeLiteral(
|
|
73672
|
+
(fragmentArgumentsDefinitions(config4, filepath, definition) || []).map(
|
|
73673
|
+
(definition2) => {
|
|
73674
|
+
return AST11.tsPropertySignature(
|
|
73675
|
+
AST11.identifier(definition2.variable.name.value),
|
|
73676
|
+
AST11.tsTypeAnnotation(
|
|
73677
|
+
tsTypeReference(config4, missingScalars, definition2, body)
|
|
73678
|
+
),
|
|
73679
|
+
definition2.type.kind !== "NonNullType"
|
|
73680
|
+
);
|
|
73681
|
+
}
|
|
73682
|
+
)
|
|
73683
|
+
);
|
|
73377
73684
|
body.push(
|
|
73378
|
-
|
|
73685
|
+
AST11.exportNamedDeclaration(
|
|
73686
|
+
AST11.tsTypeAliasDeclaration(AST11.identifier(inputTypeName), inputValue)
|
|
73687
|
+
),
|
|
73379
73688
|
AST11.exportNamedDeclaration(
|
|
73380
73689
|
AST11.tsTypeAliasDeclaration(
|
|
73381
73690
|
AST11.identifier(propTypeName),
|
|
@@ -73391,14 +73700,12 @@ async function generateFragmentTypeDefs(config4, filepath, body, selections, def
|
|
|
73391
73700
|
),
|
|
73392
73701
|
readonlyProperty(
|
|
73393
73702
|
AST11.tsPropertySignature(
|
|
73394
|
-
AST11.stringLiteral(
|
|
73703
|
+
AST11.stringLiteral(fragmentKey2),
|
|
73395
73704
|
AST11.tsTypeAnnotation(
|
|
73396
73705
|
AST11.tsTypeLiteral([
|
|
73397
73706
|
AST11.tsPropertySignature(
|
|
73398
73707
|
AST11.stringLiteral(propTypeName),
|
|
73399
|
-
AST11.tsTypeAnnotation(
|
|
73400
|
-
AST11.tsLiteralType(AST11.booleanLiteral(true))
|
|
73401
|
-
)
|
|
73708
|
+
AST11.tsTypeAnnotation(AST11.tsAnyKeyword())
|
|
73402
73709
|
)
|
|
73403
73710
|
])
|
|
73404
73711
|
)
|
|
@@ -74110,6 +74417,13 @@ async function addID(config4, documents) {
|
|
|
74110
74417
|
return;
|
|
74111
74418
|
}
|
|
74112
74419
|
return addKeysToSelection(config4, node, fragmentType);
|
|
74420
|
+
},
|
|
74421
|
+
FragmentDefinition(node) {
|
|
74422
|
+
const fragmentType = config4.schema.getType(node.typeCondition.name.value);
|
|
74423
|
+
if (!fragmentType) {
|
|
74424
|
+
return;
|
|
74425
|
+
}
|
|
74426
|
+
return addKeysToSelection(config4, node, fragmentType);
|
|
74113
74427
|
}
|
|
74114
74428
|
});
|
|
74115
74429
|
}
|
|
@@ -74128,7 +74442,7 @@ function addKeysToSelection(config4, node, fieldType) {
|
|
|
74128
74442
|
const selections = [...node.selectionSet.selections];
|
|
74129
74443
|
for (const keyField of keyFields) {
|
|
74130
74444
|
if (node.selectionSet.selections.find(
|
|
74131
|
-
(
|
|
74445
|
+
(selection) => selection.kind === "Field" && !selection.alias && selection.name.value === keyField
|
|
74132
74446
|
)) {
|
|
74133
74447
|
continue;
|
|
74134
74448
|
}
|