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/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,60 @@ 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 = {
|
|
70397
|
+
...this.collectFragmentSpreads(selection.selectionSet?.selections ?? []),
|
|
70398
|
+
...this.fields[key].selection.fragmentSpreads
|
|
70399
|
+
};
|
|
70220
70400
|
return;
|
|
70221
70401
|
}
|
|
70222
|
-
if (
|
|
70223
|
-
for (const subselect of
|
|
70402
|
+
if (selection.kind === "InlineFragment" && !selection.typeCondition) {
|
|
70403
|
+
for (const subselect of selection.selectionSet.selections) {
|
|
70224
70404
|
this.add(subselect);
|
|
70225
70405
|
}
|
|
70226
70406
|
}
|
|
70227
|
-
if (
|
|
70228
|
-
this.walkInlineFragment(
|
|
70407
|
+
if (selection.kind === "InlineFragment" && selection.typeCondition) {
|
|
70408
|
+
this.walkInlineFragment(selection);
|
|
70229
70409
|
return;
|
|
70230
70410
|
}
|
|
70231
|
-
if (
|
|
70232
|
-
this.fragmentSpreads[selection2.name.value] = selection2;
|
|
70411
|
+
if (selection.kind === "FragmentSpread") {
|
|
70233
70412
|
let includeFragments = this.config.defaultFragmentMasking === "disable";
|
|
70234
|
-
const maskEnableDirective =
|
|
70413
|
+
const maskEnableDirective = selection.directives?.find(
|
|
70235
70414
|
({ name }) => name.value === this.config.maskEnableDirective
|
|
70236
70415
|
);
|
|
70237
70416
|
if (maskEnableDirective) {
|
|
70238
70417
|
includeFragments = false;
|
|
70239
70418
|
}
|
|
70240
|
-
const maskDisableDirective =
|
|
70419
|
+
const maskDisableDirective = selection.directives?.find(
|
|
70241
70420
|
({ name }) => name.value === this.config.maskDisableDirective
|
|
70242
70421
|
);
|
|
70243
70422
|
if (maskDisableDirective) {
|
|
@@ -70246,14 +70425,17 @@ var FieldCollection = class {
|
|
|
70246
70425
|
if (this.ignoreMaskDisable) {
|
|
70247
70426
|
includeFragments = true;
|
|
70248
70427
|
}
|
|
70249
|
-
if (
|
|
70428
|
+
if (this.keepFragmentSpreadNodes) {
|
|
70429
|
+
this.fragmentSpreads[selection.name.value] = selection;
|
|
70430
|
+
}
|
|
70431
|
+
if (!includeFragments) {
|
|
70250
70432
|
return;
|
|
70251
70433
|
}
|
|
70252
|
-
const definition = this.fragmentDefinitions[
|
|
70434
|
+
const definition = this.fragmentDefinitions[selection.name.value];
|
|
70253
70435
|
if (!definition) {
|
|
70254
70436
|
throw new HoudiniError({
|
|
70255
70437
|
filepath: this.filepath,
|
|
70256
|
-
message: "Could not find referenced fragment definition: " +
|
|
70438
|
+
message: "Could not find referenced fragment definition: " + selection.name.value + "\n" + JSON.stringify(Object.keys(this.fragmentDefinitions), null, 4)
|
|
70257
70439
|
});
|
|
70258
70440
|
}
|
|
70259
70441
|
this.add({
|
|
@@ -70272,37 +70454,67 @@ var FieldCollection = class {
|
|
|
70272
70454
|
});
|
|
70273
70455
|
}
|
|
70274
70456
|
}
|
|
70457
|
+
collectFragmentSpreads(selections, result = {}) {
|
|
70458
|
+
for (const selection of selections) {
|
|
70459
|
+
if (selection.kind === "Field") {
|
|
70460
|
+
continue;
|
|
70461
|
+
}
|
|
70462
|
+
if (selection.kind === "InlineFragment") {
|
|
70463
|
+
this.collectFragmentSpreads(selection.selectionSet.selections, result);
|
|
70464
|
+
continue;
|
|
70465
|
+
}
|
|
70466
|
+
if (selection.kind === "FragmentSpread") {
|
|
70467
|
+
result[selection.name.value] = selection;
|
|
70468
|
+
continue;
|
|
70469
|
+
}
|
|
70470
|
+
}
|
|
70471
|
+
return result;
|
|
70472
|
+
}
|
|
70275
70473
|
toSelectionSet() {
|
|
70276
|
-
return Object.values(this.inlineFragments).flatMap((
|
|
70277
|
-
if (
|
|
70474
|
+
return Object.values(this.inlineFragments).flatMap((fragment2) => {
|
|
70475
|
+
if (fragment2.selection.size === 0) {
|
|
70278
70476
|
return [];
|
|
70279
70477
|
}
|
|
70280
|
-
|
|
70281
|
-
...
|
|
70478
|
+
fragment2.astNode = {
|
|
70479
|
+
...fragment2.astNode,
|
|
70282
70480
|
selectionSet: {
|
|
70283
|
-
...
|
|
70284
|
-
selections:
|
|
70481
|
+
...fragment2.astNode.selectionSet,
|
|
70482
|
+
selections: fragment2.selection.toSelectionSet()
|
|
70285
70483
|
}
|
|
70286
70484
|
};
|
|
70287
|
-
return [
|
|
70485
|
+
return [fragment2.astNode];
|
|
70288
70486
|
}).concat(
|
|
70289
70487
|
Object.values(this.fields).map((field) => {
|
|
70290
|
-
|
|
70291
|
-
field.astNode
|
|
70292
|
-
|
|
70293
|
-
|
|
70488
|
+
return {
|
|
70489
|
+
...field.astNode,
|
|
70490
|
+
selectionSet: field.astNode.selectionSet ? {
|
|
70491
|
+
kind: "SelectionSet",
|
|
70492
|
+
selections: field.selection.toSelectionSet()
|
|
70493
|
+
} : void 0
|
|
70494
|
+
};
|
|
70294
70495
|
})
|
|
70295
|
-
).concat(
|
|
70496
|
+
).concat(
|
|
70497
|
+
Object.values(this.fragmentSpreads).map((spread) => {
|
|
70498
|
+
return {
|
|
70499
|
+
kind: "FragmentSpread",
|
|
70500
|
+
name: {
|
|
70501
|
+
kind: "Name",
|
|
70502
|
+
value: spread.name.value
|
|
70503
|
+
},
|
|
70504
|
+
directives: spread.directives
|
|
70505
|
+
};
|
|
70506
|
+
})
|
|
70507
|
+
);
|
|
70296
70508
|
}
|
|
70297
|
-
walkInlineFragment(
|
|
70298
|
-
const key =
|
|
70509
|
+
walkInlineFragment(selection) {
|
|
70510
|
+
const key = selection.typeCondition.name.value;
|
|
70299
70511
|
if (!this.inlineFragments[key]) {
|
|
70300
70512
|
this.inlineFragments[key] = {
|
|
70301
|
-
astNode:
|
|
70513
|
+
astNode: selection,
|
|
70302
70514
|
selection: this.empty()
|
|
70303
70515
|
};
|
|
70304
70516
|
}
|
|
70305
|
-
for (const subselect of
|
|
70517
|
+
for (const subselect of selection.selectionSet.selections || []) {
|
|
70306
70518
|
if (subselect.kind !== "InlineFragment" || !subselect.typeCondition) {
|
|
70307
70519
|
this.inlineFragments[key].selection.add(subselect);
|
|
70308
70520
|
continue;
|
|
@@ -70316,8 +70528,8 @@ var FieldCollection = class {
|
|
|
70316
70528
|
fragmentDefinitions: this.fragmentDefinitions,
|
|
70317
70529
|
selections: [],
|
|
70318
70530
|
filepath: this.filepath,
|
|
70319
|
-
|
|
70320
|
-
|
|
70531
|
+
ignoreMaskDisable: this.ignoreMaskDisable,
|
|
70532
|
+
keepFragmentSpreadNodes: this.keepFragmentSpreadNodes
|
|
70321
70533
|
});
|
|
70322
70534
|
}
|
|
70323
70535
|
};
|
|
@@ -70395,13 +70607,13 @@ function murmurHash(str) {
|
|
|
70395
70607
|
// src/codegen/transforms/fragmentVariables.ts
|
|
70396
70608
|
var graphql5 = __toESM(require_graphql2(), 1);
|
|
70397
70609
|
|
|
70398
|
-
// src/codegen/transforms/
|
|
70610
|
+
// src/codegen/transforms/collectDefinitions.ts
|
|
70399
70611
|
var import_graphql30 = __toESM(require_graphql2(), 1);
|
|
70400
70612
|
async function includeFragmentDefinitions(config4, documents) {
|
|
70401
|
-
const fragments =
|
|
70613
|
+
const fragments = collectDefinitions(config4, documents);
|
|
70402
70614
|
for (const [index, { name, document, filename }] of documents.entries()) {
|
|
70403
70615
|
const operation = document.definitions.find(
|
|
70404
|
-
(
|
|
70616
|
+
(def) => def.kind === import_graphql30.Kind.OPERATION_DEFINITION || def.kind === "FragmentDefinition"
|
|
70405
70617
|
);
|
|
70406
70618
|
if (!operation) {
|
|
70407
70619
|
continue;
|
|
@@ -70420,7 +70632,7 @@ async function includeFragmentDefinitions(config4, documents) {
|
|
|
70420
70632
|
};
|
|
70421
70633
|
}
|
|
70422
70634
|
}
|
|
70423
|
-
function
|
|
70635
|
+
function collectDefinitions(config4, docs) {
|
|
70424
70636
|
return docs.reduce((acc, doc) => {
|
|
70425
70637
|
const definitions = doc.document.definitions.reduce(
|
|
70426
70638
|
(prev, definition) => definition.kind !== "FragmentDefinition" ? prev : {
|
|
@@ -70444,11 +70656,11 @@ function findRequiredFragments(selectionSet) {
|
|
|
70444
70656
|
return [];
|
|
70445
70657
|
}
|
|
70446
70658
|
const referencedFragments = [];
|
|
70447
|
-
for (const
|
|
70448
|
-
if (
|
|
70449
|
-
referencedFragments.push(
|
|
70450
|
-
} else if (
|
|
70451
|
-
referencedFragments.push(...findRequiredFragments(
|
|
70659
|
+
for (const selection of selectionSet.selections) {
|
|
70660
|
+
if (selection.kind === import_graphql30.Kind.FRAGMENT_SPREAD) {
|
|
70661
|
+
referencedFragments.push(selection.name.value);
|
|
70662
|
+
} else if (selection.selectionSet) {
|
|
70663
|
+
referencedFragments.push(...findRequiredFragments(selection.selectionSet));
|
|
70452
70664
|
}
|
|
70453
70665
|
}
|
|
70454
70666
|
return referencedFragments;
|
|
@@ -70481,7 +70693,7 @@ function flattenFragments(filepath, operation, fragments) {
|
|
|
70481
70693
|
// src/codegen/transforms/fragmentVariables.ts
|
|
70482
70694
|
var GraphqlKinds2 = graphql5.Kind;
|
|
70483
70695
|
async function fragmentVariables(config4, documents) {
|
|
70484
|
-
const fragments =
|
|
70696
|
+
const fragments = collectDefinitions(config4, documents);
|
|
70485
70697
|
const generatedFragments = {};
|
|
70486
70698
|
const visitedFragments = /* @__PURE__ */ new Set();
|
|
70487
70699
|
for (const doc2 of documents) {
|
|
@@ -70541,9 +70753,17 @@ function inlineFragmentArgs({
|
|
|
70541
70753
|
).reduce((acc, arg) => ({ ...acc, [arg.name]: arg }), {});
|
|
70542
70754
|
const result = graphql5.visit(document, {
|
|
70543
70755
|
FragmentSpread(node) {
|
|
70756
|
+
if (!fragmentDefinitions[node.name.value]) {
|
|
70757
|
+
throw new Error("Could not find definition for fragment" + node.name.value);
|
|
70758
|
+
}
|
|
70544
70759
|
const { definition } = fragmentDefinitions[node.name.value];
|
|
70545
70760
|
let { args, hash } = collectWithArguments(config4, filepath, node, scope);
|
|
70546
70761
|
const newFragmentName = `${node.name.value}${hash}`;
|
|
70762
|
+
config4.registerFragmentVariablesHash({
|
|
70763
|
+
hash: newFragmentName,
|
|
70764
|
+
fragment: node.name.value,
|
|
70765
|
+
args
|
|
70766
|
+
});
|
|
70547
70767
|
if (!visitedFragments.has(newFragmentName)) {
|
|
70548
70768
|
visitedFragments.add(newFragmentName);
|
|
70549
70769
|
const defaultArguments = collectDefaultArgumentValues(config4, filepath, definition);
|
|
@@ -70942,7 +71162,7 @@ function operationObject({
|
|
|
70942
71162
|
listName,
|
|
70943
71163
|
operationKind,
|
|
70944
71164
|
type,
|
|
70945
|
-
selection
|
|
71165
|
+
selection,
|
|
70946
71166
|
filepath
|
|
70947
71167
|
}) {
|
|
70948
71168
|
let parentID;
|
|
@@ -70950,7 +71170,7 @@ function operationObject({
|
|
|
70950
71170
|
let position = config4.internalListPosition;
|
|
70951
71171
|
let allLists = config4.defaultListTarget ?? void 0;
|
|
70952
71172
|
let operationWhen;
|
|
70953
|
-
const internalDirectives =
|
|
71173
|
+
const internalDirectives = selection.directives?.filter(
|
|
70954
71174
|
(directive) => config4.isInternalDirective(directive.name.value)
|
|
70955
71175
|
);
|
|
70956
71176
|
if (internalDirectives && internalDirectives.length > 0) {
|
|
@@ -71192,7 +71412,7 @@ async function paginate(config4, documents) {
|
|
|
71192
71412
|
let fragmentName = "";
|
|
71193
71413
|
let refetchQueryName = "";
|
|
71194
71414
|
let nodeQuery = false;
|
|
71195
|
-
let
|
|
71415
|
+
let fragment2 = "";
|
|
71196
71416
|
let paginateMode = config4.defaultPaginateMode;
|
|
71197
71417
|
doc.document = graphql10.visit(doc.document, {
|
|
71198
71418
|
OperationDefinition(node) {
|
|
@@ -71235,7 +71455,7 @@ async function paginate(config4, documents) {
|
|
|
71235
71455
|
};
|
|
71236
71456
|
},
|
|
71237
71457
|
FragmentDefinition(node) {
|
|
71238
|
-
|
|
71458
|
+
fragment2 = node.typeCondition.name.value;
|
|
71239
71459
|
fragmentName = node.name.value;
|
|
71240
71460
|
refetchQueryName = config4.paginationQueryName(fragmentName);
|
|
71241
71461
|
nodeQuery = node.typeCondition.name.value !== config4.schema.getQueryType()?.name;
|
|
@@ -71282,17 +71502,17 @@ async function paginate(config4, documents) {
|
|
|
71282
71502
|
}
|
|
71283
71503
|
});
|
|
71284
71504
|
let targetType = config4.schema.getQueryType()?.name || "";
|
|
71285
|
-
if (
|
|
71505
|
+
if (fragment2) {
|
|
71286
71506
|
const nodeInterface = config4.schema.getType("Node");
|
|
71287
71507
|
if (nodeInterface) {
|
|
71288
71508
|
const { objects, interfaces } = config4.schema.getImplementations(nodeInterface);
|
|
71289
|
-
if (objects.find((obj) => obj.name ===
|
|
71509
|
+
if (objects.find((obj) => obj.name === fragment2) || interfaces.find((int) => int.name === fragment2)) {
|
|
71290
71510
|
targetType = "Node";
|
|
71291
71511
|
} else {
|
|
71292
|
-
targetType =
|
|
71512
|
+
targetType = fragment2;
|
|
71293
71513
|
}
|
|
71294
71514
|
} else {
|
|
71295
|
-
targetType =
|
|
71515
|
+
targetType = fragment2;
|
|
71296
71516
|
}
|
|
71297
71517
|
}
|
|
71298
71518
|
const pageSize = flags.first.defaultValue ?? flags.last.defaultValue ?? flags.limit.defaultValue;
|
|
@@ -71314,7 +71534,7 @@ async function paginate(config4, documents) {
|
|
|
71314
71534
|
start,
|
|
71315
71535
|
mode: paginateMode
|
|
71316
71536
|
};
|
|
71317
|
-
if (!
|
|
71537
|
+
if (!fragment2) {
|
|
71318
71538
|
continue;
|
|
71319
71539
|
}
|
|
71320
71540
|
const paginationArgs = Object.entries(flags).filter(([_, { enabled }]) => enabled).map(([key, value]) => ({ name: key, ...value }));
|
|
@@ -71335,15 +71555,22 @@ async function paginate(config4, documents) {
|
|
|
71335
71555
|
["arguments"]: paginationArgs.map(
|
|
71336
71556
|
({ name }) => variableAsArgument(name)
|
|
71337
71557
|
)
|
|
71558
|
+
},
|
|
71559
|
+
{
|
|
71560
|
+
kind: graphql10.Kind.DIRECTIVE,
|
|
71561
|
+
name: {
|
|
71562
|
+
kind: "Name",
|
|
71563
|
+
value: config4.maskDisableDirective
|
|
71564
|
+
}
|
|
71338
71565
|
}
|
|
71339
71566
|
]
|
|
71340
71567
|
}
|
|
71341
71568
|
];
|
|
71342
|
-
const keys = config4.keyFieldsForType(!nodeQuery ? config4.schema.getQueryType()?.name || "" :
|
|
71343
|
-
if (
|
|
71569
|
+
const keys = config4.keyFieldsForType(!nodeQuery ? config4.schema.getQueryType()?.name || "" : fragment2).flatMap((key) => {
|
|
71570
|
+
if (fragment2 === config4.schema.getQueryType()?.name) {
|
|
71344
71571
|
return [];
|
|
71345
71572
|
}
|
|
71346
|
-
const fragmentType = config4.schema.getType(
|
|
71573
|
+
const fragmentType = config4.schema.getType(fragment2);
|
|
71347
71574
|
const { type, wrappers } = unwrapType(
|
|
71348
71575
|
config4,
|
|
71349
71576
|
fragmentType.getFields()[key].type
|
|
@@ -71355,7 +71582,7 @@ async function paginate(config4, documents) {
|
|
|
71355
71582
|
}
|
|
71356
71583
|
];
|
|
71357
71584
|
});
|
|
71358
|
-
const typeConfig = config4.typeConfig?.[
|
|
71585
|
+
const typeConfig = config4.typeConfig?.[fragment2];
|
|
71359
71586
|
const queryDoc = {
|
|
71360
71587
|
kind: graphql10.Kind.DOCUMENT,
|
|
71361
71588
|
definitions: [
|
|
@@ -71697,7 +71924,7 @@ async function addListFragments(config4, documents) {
|
|
|
71697
71924
|
);
|
|
71698
71925
|
const targetField = ancestors[ancestors.length - 1];
|
|
71699
71926
|
const targetFieldDefinition = parentType.getFields()[targetField.name.value];
|
|
71700
|
-
const { selection
|
|
71927
|
+
const { selection, type, connection } = connectionSelection(
|
|
71701
71928
|
config4,
|
|
71702
71929
|
targetFieldDefinition,
|
|
71703
71930
|
parentTypeFromAncestors(
|
|
@@ -71708,7 +71935,7 @@ async function addListFragments(config4, documents) {
|
|
|
71708
71935
|
ancestors[ancestors.length - 1].selectionSet
|
|
71709
71936
|
);
|
|
71710
71937
|
lists[nameArg.value.value] = {
|
|
71711
|
-
selection
|
|
71938
|
+
selection,
|
|
71712
71939
|
type,
|
|
71713
71940
|
filename: doc.filename
|
|
71714
71941
|
};
|
|
@@ -71786,14 +72013,14 @@ async function addListFragments(config4, documents) {
|
|
|
71786
72013
|
const generatedDoc = {
|
|
71787
72014
|
kind: graphql11.Kind.DOCUMENT,
|
|
71788
72015
|
definitions: Object.entries(lists).flatMap(
|
|
71789
|
-
([name, { selection
|
|
72016
|
+
([name, { selection, type }]) => {
|
|
71790
72017
|
const schemaType = config4.schema.getType(type.name);
|
|
71791
|
-
if (!
|
|
72018
|
+
if (!selection) {
|
|
71792
72019
|
throw new HoudiniError({ message: "Lists must have a selection" });
|
|
71793
72020
|
}
|
|
71794
72021
|
const fragmentSelection = {
|
|
71795
72022
|
kind: graphql11.Kind.SELECTION_SET,
|
|
71796
|
-
selections: [...
|
|
72023
|
+
selections: [...selection.selections]
|
|
71797
72024
|
};
|
|
71798
72025
|
if (schemaType && fragmentSelection && !fragmentSelection?.selections.find(
|
|
71799
72026
|
(field) => field.kind === "Field" && config4.keyFieldsForType(type.name).includes(field.name.value)
|
|
@@ -71885,7 +72112,7 @@ async function addListFragments(config4, documents) {
|
|
|
71885
72112
|
artifact: null
|
|
71886
72113
|
});
|
|
71887
72114
|
}
|
|
71888
|
-
function connectionSelection(config4, field, type,
|
|
72115
|
+
function connectionSelection(config4, field, type, selection) {
|
|
71889
72116
|
const fieldArgs = field.args.reduce(
|
|
71890
72117
|
(args, arg) => ({
|
|
71891
72118
|
...args,
|
|
@@ -71894,34 +72121,34 @@ function connectionSelection(config4, field, type, selection2) {
|
|
|
71894
72121
|
{}
|
|
71895
72122
|
);
|
|
71896
72123
|
if (fieldArgs["limit"]) {
|
|
71897
|
-
return { selection
|
|
72124
|
+
return { selection, type, connection: false, error: null };
|
|
71898
72125
|
}
|
|
71899
72126
|
const forwardPagination = fieldArgs["first"] === "Int" && ["Cursor", "String"].includes(fieldArgs["after"]);
|
|
71900
72127
|
const backwardsPagination = fieldArgs["last"] === "Int" && ["Cursor", "String"].includes(fieldArgs["before"]);
|
|
71901
72128
|
if (!forwardPagination && !backwardsPagination) {
|
|
71902
|
-
return { selection
|
|
72129
|
+
return { selection, type, connection: false, error: missingPaginationArgMessage(config4) };
|
|
71903
72130
|
}
|
|
71904
|
-
const edgesField =
|
|
71905
|
-
(
|
|
72131
|
+
const edgesField = selection?.selections.find(
|
|
72132
|
+
(selection2) => selection2.kind === "Field" && selection2.name.value === "edges"
|
|
71906
72133
|
);
|
|
71907
72134
|
if (!edgesField) {
|
|
71908
|
-
return { selection
|
|
72135
|
+
return { selection, type, connection: false, error: missingEdgeSelectionMessage(config4) };
|
|
71909
72136
|
}
|
|
71910
72137
|
const nodeSelection = edgesField.selectionSet?.selections.find(
|
|
71911
|
-
(
|
|
72138
|
+
(selection2) => selection2.kind === "Field" && selection2.name.value === "node"
|
|
71912
72139
|
);
|
|
71913
72140
|
if (!nodeSelection.selectionSet) {
|
|
71914
|
-
return { selection
|
|
72141
|
+
return { selection, type, connection: false, error: missingNodeSelectionMessage(config4) };
|
|
71915
72142
|
}
|
|
71916
72143
|
const edgeField = unwrapType(config4, field.type).type.getFields()["edges"];
|
|
71917
72144
|
const { wrappers, type: edgeFieldType } = unwrapType(config4, edgeField.type);
|
|
71918
72145
|
const list = wrappers[wrappers.length - 2] === "List" /* List */;
|
|
71919
72146
|
if (!list) {
|
|
71920
|
-
return { selection
|
|
72147
|
+
return { selection, type, connection: false, error: edgeInvalidTypeMessage(config4) };
|
|
71921
72148
|
}
|
|
71922
72149
|
const nodeField = edgeFieldType.getFields()["node"];
|
|
71923
72150
|
if (!nodeField) {
|
|
71924
|
-
return { selection
|
|
72151
|
+
return { selection, type, connection: false, error: nodeNotDefinedMessage(config4) };
|
|
71925
72152
|
}
|
|
71926
72153
|
return {
|
|
71927
72154
|
selection: nodeSelection.selectionSet,
|
|
@@ -72000,59 +72227,45 @@ function fieldKey(config4, field) {
|
|
|
72000
72227
|
}
|
|
72001
72228
|
|
|
72002
72229
|
// src/codegen/generators/artifacts/selection.ts
|
|
72003
|
-
function
|
|
72230
|
+
function selection_default(args) {
|
|
72231
|
+
const typeMap = {};
|
|
72232
|
+
const abstractTypes = [];
|
|
72233
|
+
return mergeSelection({
|
|
72234
|
+
object: prepareSelection({ ...args, typeMap, abstractTypes }),
|
|
72235
|
+
filepath: args.filepath,
|
|
72236
|
+
typeMap,
|
|
72237
|
+
abstractTypes
|
|
72238
|
+
});
|
|
72239
|
+
}
|
|
72240
|
+
function prepareSelection({
|
|
72004
72241
|
config: config4,
|
|
72005
72242
|
filepath,
|
|
72006
72243
|
rootType,
|
|
72007
72244
|
selections,
|
|
72008
72245
|
operations,
|
|
72009
72246
|
path: path2 = [],
|
|
72010
|
-
includeFragments,
|
|
72011
72247
|
document,
|
|
72012
|
-
inConnection
|
|
72248
|
+
inConnection,
|
|
72249
|
+
typeMap,
|
|
72250
|
+
abstractTypes
|
|
72013
72251
|
}) {
|
|
72014
72252
|
let object = {};
|
|
72015
|
-
const typeMap = {};
|
|
72016
|
-
const abstractTypes = [];
|
|
72017
72253
|
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") {
|
|
72254
|
+
if (field.kind === "InlineFragment") {
|
|
72043
72255
|
if (!field.typeCondition || field.typeCondition.name.value === rootType) {
|
|
72044
72256
|
object.fields = deepMerge(
|
|
72045
72257
|
filepath,
|
|
72046
72258
|
object.fields || {},
|
|
72047
|
-
|
|
72259
|
+
prepareSelection({
|
|
72048
72260
|
config: config4,
|
|
72049
72261
|
filepath,
|
|
72050
72262
|
rootType: field.typeCondition?.name.value || rootType,
|
|
72051
72263
|
operations,
|
|
72052
72264
|
selections: field.selectionSet.selections,
|
|
72053
72265
|
path: path2,
|
|
72054
|
-
|
|
72055
|
-
|
|
72266
|
+
document,
|
|
72267
|
+
typeMap,
|
|
72268
|
+
abstractTypes
|
|
72056
72269
|
}).fields || {}
|
|
72057
72270
|
);
|
|
72058
72271
|
} else {
|
|
@@ -72090,15 +72303,16 @@ function selection({
|
|
|
72090
72303
|
}
|
|
72091
72304
|
object.abstractFields.fields = {
|
|
72092
72305
|
...object.abstractFields.fields,
|
|
72093
|
-
[field.typeCondition.name.value]:
|
|
72306
|
+
[field.typeCondition.name.value]: prepareSelection({
|
|
72094
72307
|
config: config4,
|
|
72095
72308
|
filepath,
|
|
72096
72309
|
rootType: field.typeCondition?.name.value || rootType,
|
|
72097
72310
|
operations,
|
|
72098
72311
|
selections: field.selectionSet.selections,
|
|
72099
72312
|
path: path2,
|
|
72100
|
-
|
|
72101
|
-
|
|
72313
|
+
document,
|
|
72314
|
+
typeMap,
|
|
72315
|
+
abstractTypes
|
|
72102
72316
|
}).fields
|
|
72103
72317
|
};
|
|
72104
72318
|
}
|
|
@@ -72119,10 +72333,14 @@ function selection({
|
|
|
72119
72333
|
}
|
|
72120
72334
|
const typeName = fieldType.toString();
|
|
72121
72335
|
const pathSoFar = path2.concat(attributeName);
|
|
72122
|
-
const
|
|
72336
|
+
const keys = config4.keyFieldsForType(rootType);
|
|
72337
|
+
let fieldObj = {
|
|
72123
72338
|
type: typeName,
|
|
72124
72339
|
keyRaw: fieldKey(config4, field)
|
|
72125
72340
|
};
|
|
72341
|
+
if (keys.includes(field.name.value)) {
|
|
72342
|
+
fieldObj.visible = true;
|
|
72343
|
+
}
|
|
72126
72344
|
if (nullable) {
|
|
72127
72345
|
fieldObj.nullable = true;
|
|
72128
72346
|
}
|
|
@@ -72170,16 +72388,17 @@ function selection({
|
|
|
72170
72388
|
}
|
|
72171
72389
|
if (field.selectionSet) {
|
|
72172
72390
|
const connectionState = paginated && document.refetch?.method === "cursor" || continueConnection;
|
|
72173
|
-
fieldObj.selection =
|
|
72391
|
+
fieldObj.selection = prepareSelection({
|
|
72174
72392
|
config: config4,
|
|
72175
72393
|
filepath,
|
|
72176
72394
|
rootType: typeName,
|
|
72177
72395
|
selections: field.selectionSet.selections,
|
|
72178
72396
|
operations,
|
|
72179
72397
|
path: pathSoFar,
|
|
72180
|
-
includeFragments,
|
|
72181
72398
|
document,
|
|
72182
|
-
inConnection: connectionState
|
|
72399
|
+
inConnection: connectionState,
|
|
72400
|
+
typeMap,
|
|
72401
|
+
abstractTypes
|
|
72183
72402
|
});
|
|
72184
72403
|
}
|
|
72185
72404
|
if (field.arguments?.length && fieldObj.list) {
|
|
@@ -72194,12 +72413,29 @@ function selection({
|
|
|
72194
72413
|
if (graphql13.isInterfaceType(fieldType) || graphql13.isUnionType(fieldType)) {
|
|
72195
72414
|
fieldObj.abstract = true;
|
|
72196
72415
|
}
|
|
72416
|
+
if (object.fields?.[attributeName]) {
|
|
72417
|
+
fieldObj = deepMerge(filepath, object.fields[attributeName], fieldObj);
|
|
72418
|
+
}
|
|
72197
72419
|
object.fields = {
|
|
72198
72420
|
...object.fields,
|
|
72199
72421
|
[attributeName]: fieldObj
|
|
72200
72422
|
};
|
|
72423
|
+
} else if (field.kind === "FragmentSpread") {
|
|
72424
|
+
const { fragment: fragment2, args } = config4.getFragmentVariablesHash(field.name.value);
|
|
72425
|
+
object.fragments = {
|
|
72426
|
+
...object.fragments,
|
|
72427
|
+
[fragment2]: args ?? {}
|
|
72428
|
+
};
|
|
72201
72429
|
}
|
|
72202
72430
|
}
|
|
72431
|
+
return object;
|
|
72432
|
+
}
|
|
72433
|
+
function mergeSelection({
|
|
72434
|
+
filepath,
|
|
72435
|
+
object,
|
|
72436
|
+
typeMap,
|
|
72437
|
+
abstractTypes
|
|
72438
|
+
}) {
|
|
72203
72439
|
if (Object.keys(object.fields || {}).length > 0 && object.abstractFields && Object.keys(object.abstractFields.fields).length > 0) {
|
|
72204
72440
|
for (const [typeName, possibles] of Object.entries(typeMap)) {
|
|
72205
72441
|
let overlap = false;
|
|
@@ -72207,8 +72443,8 @@ function selection({
|
|
|
72207
72443
|
if (object.abstractFields.fields[typeName]) {
|
|
72208
72444
|
object.abstractFields.fields[typeName] = deepMerge(
|
|
72209
72445
|
filepath,
|
|
72210
|
-
object.abstractFields.fields[typeName]
|
|
72211
|
-
object.abstractFields.fields[possible]
|
|
72446
|
+
object.abstractFields.fields[typeName] ?? {},
|
|
72447
|
+
object.abstractFields.fields[possible] ?? {}
|
|
72212
72448
|
);
|
|
72213
72449
|
overlap = true;
|
|
72214
72450
|
}
|
|
@@ -72239,6 +72475,30 @@ function selection({
|
|
|
72239
72475
|
}
|
|
72240
72476
|
}
|
|
72241
72477
|
}
|
|
72478
|
+
for (const [key, value] of Object.entries(object.fields ?? {})) {
|
|
72479
|
+
const selection = value.selection;
|
|
72480
|
+
if (selection) {
|
|
72481
|
+
mergeSelection({
|
|
72482
|
+
filepath,
|
|
72483
|
+
typeMap,
|
|
72484
|
+
abstractTypes,
|
|
72485
|
+
object: selection
|
|
72486
|
+
});
|
|
72487
|
+
}
|
|
72488
|
+
}
|
|
72489
|
+
for (const [type, selection] of Object.entries(object.abstractFields?.fields ?? {})) {
|
|
72490
|
+
for (const [key, value] of Object.entries(selection ?? {})) {
|
|
72491
|
+
const selection2 = value.selection;
|
|
72492
|
+
if (selection2) {
|
|
72493
|
+
mergeSelection({
|
|
72494
|
+
filepath,
|
|
72495
|
+
typeMap,
|
|
72496
|
+
abstractTypes,
|
|
72497
|
+
object: selection2
|
|
72498
|
+
});
|
|
72499
|
+
}
|
|
72500
|
+
}
|
|
72501
|
+
}
|
|
72242
72502
|
return object;
|
|
72243
72503
|
}
|
|
72244
72504
|
|
|
@@ -72303,7 +72563,12 @@ function artifactGenerator(stats) {
|
|
|
72303
72563
|
writeIndexFile(config4, docs)
|
|
72304
72564
|
].concat(
|
|
72305
72565
|
docs.map(async (doc) => {
|
|
72306
|
-
const {
|
|
72566
|
+
const {
|
|
72567
|
+
document,
|
|
72568
|
+
name,
|
|
72569
|
+
generateArtifact,
|
|
72570
|
+
originalParsed
|
|
72571
|
+
} = doc;
|
|
72307
72572
|
if (!generateArtifact) {
|
|
72308
72573
|
return;
|
|
72309
72574
|
}
|
|
@@ -72342,6 +72607,16 @@ function artifactGenerator(stats) {
|
|
|
72342
72607
|
);
|
|
72343
72608
|
let rootType = "";
|
|
72344
72609
|
let selectionSet;
|
|
72610
|
+
let originalSelectionSet = null;
|
|
72611
|
+
const fragmentDefinitions = doc.document.definitions.filter(
|
|
72612
|
+
(definition) => definition.kind === "FragmentDefinition"
|
|
72613
|
+
).reduce(
|
|
72614
|
+
(prev, definition) => ({
|
|
72615
|
+
...prev,
|
|
72616
|
+
[definition.name.value]: definition
|
|
72617
|
+
}),
|
|
72618
|
+
{}
|
|
72619
|
+
);
|
|
72345
72620
|
if (docKind !== ArtifactKind.Fragment) {
|
|
72346
72621
|
const operation = operations[0];
|
|
72347
72622
|
if (operation.operation === "query") {
|
|
@@ -72358,9 +72633,12 @@ function artifactGenerator(stats) {
|
|
|
72358
72633
|
});
|
|
72359
72634
|
}
|
|
72360
72635
|
selectionSet = operation.selectionSet;
|
|
72636
|
+
if (originalParsed.definitions[0].kind === "OperationDefinition") {
|
|
72637
|
+
originalSelectionSet = originalParsed.definitions[0].selectionSet;
|
|
72638
|
+
}
|
|
72361
72639
|
} else {
|
|
72362
72640
|
const matchingFragment = fragments.find(
|
|
72363
|
-
(
|
|
72641
|
+
(fragment2) => fragment2.name.value === name
|
|
72364
72642
|
);
|
|
72365
72643
|
if (!matchingFragment) {
|
|
72366
72644
|
throw new HoudiniError({
|
|
@@ -72370,6 +72648,12 @@ function artifactGenerator(stats) {
|
|
|
72370
72648
|
}
|
|
72371
72649
|
rootType = matchingFragment.typeCondition.name.value;
|
|
72372
72650
|
selectionSet = matchingFragment.selectionSet;
|
|
72651
|
+
if (originalParsed.definitions[0].kind === "FragmentDefinition") {
|
|
72652
|
+
originalSelectionSet = originalParsed.definitions[0].selectionSet;
|
|
72653
|
+
}
|
|
72654
|
+
}
|
|
72655
|
+
if (!originalSelectionSet) {
|
|
72656
|
+
throw new Error("Not original selection set!");
|
|
72373
72657
|
}
|
|
72374
72658
|
let inputs = operations[0]?.variableDefinitions;
|
|
72375
72659
|
let directive = fragments[0]?.directives?.find(
|
|
@@ -72378,21 +72662,18 @@ function artifactGenerator(stats) {
|
|
|
72378
72662
|
if (docKind === ArtifactKind.Fragment && directive) {
|
|
72379
72663
|
inputs = fragmentArgumentsDefinitions(config4, doc.filename, fragments[0]);
|
|
72380
72664
|
}
|
|
72381
|
-
const
|
|
72665
|
+
const mask = selection_default({
|
|
72382
72666
|
config: config4,
|
|
72383
72667
|
filepath: doc.filename,
|
|
72384
|
-
|
|
72385
|
-
|
|
72386
|
-
|
|
72387
|
-
|
|
72388
|
-
|
|
72389
|
-
|
|
72390
|
-
|
|
72391
|
-
|
|
72392
|
-
|
|
72393
|
-
),
|
|
72394
|
-
ignoreMaskDisable: docKind === "HoudiniQuery",
|
|
72395
|
-
applyFragments: docKind !== "HoudiniFragment"
|
|
72668
|
+
rootType,
|
|
72669
|
+
operations: {},
|
|
72670
|
+
document: doc,
|
|
72671
|
+
selections: flattenSelections({
|
|
72672
|
+
config: config4,
|
|
72673
|
+
filepath: doc.filename,
|
|
72674
|
+
selections: selectionSet.selections,
|
|
72675
|
+
fragmentDefinitions
|
|
72676
|
+
})
|
|
72396
72677
|
});
|
|
72397
72678
|
let artifact = {
|
|
72398
72679
|
name,
|
|
@@ -72401,21 +72682,29 @@ function artifactGenerator(stats) {
|
|
|
72401
72682
|
refetch: doc.refetch,
|
|
72402
72683
|
raw: rawString,
|
|
72403
72684
|
rootType,
|
|
72404
|
-
selection:
|
|
72685
|
+
selection: selection_default({
|
|
72405
72686
|
config: config4,
|
|
72406
72687
|
filepath: doc.filename,
|
|
72407
72688
|
rootType,
|
|
72408
|
-
selections:
|
|
72689
|
+
selections: flattenSelections({
|
|
72690
|
+
config: config4,
|
|
72691
|
+
filepath: doc.filename,
|
|
72692
|
+
selections: selectionSet.selections,
|
|
72693
|
+
fragmentDefinitions,
|
|
72694
|
+
ignoreMaskDisable: docKind !== "HoudiniFragment",
|
|
72695
|
+
keepFragmentSpreadNodes: true
|
|
72696
|
+
}),
|
|
72409
72697
|
operations: operationsByPath(
|
|
72410
72698
|
config4,
|
|
72411
72699
|
doc.filename,
|
|
72412
72700
|
operations[0],
|
|
72413
72701
|
filterTypes
|
|
72414
72702
|
),
|
|
72415
|
-
includeFragments: docKind !== "HoudiniFragment",
|
|
72416
72703
|
document: doc
|
|
72417
|
-
})
|
|
72704
|
+
}),
|
|
72705
|
+
pluginData: {}
|
|
72418
72706
|
};
|
|
72707
|
+
applyMask(config4, artifact.selection, mask);
|
|
72419
72708
|
artifact.pluginData = {};
|
|
72420
72709
|
for (const plugin2 of config4.plugins) {
|
|
72421
72710
|
if (!plugin2.artifactData) {
|
|
@@ -72492,6 +72781,49 @@ function artifactGenerator(stats) {
|
|
|
72492
72781
|
stats.deleted = await cleanupFiles(config4.artifactDirectory, listOfArtifacts);
|
|
72493
72782
|
};
|
|
72494
72783
|
}
|
|
72784
|
+
function applyMask(config4, target, mask) {
|
|
72785
|
+
for (const [fieldName, value] of Object.entries(mask.fields ?? {})) {
|
|
72786
|
+
const targetSelection = target.fields?.[fieldName];
|
|
72787
|
+
if (!targetSelection || !mask.fields) {
|
|
72788
|
+
continue;
|
|
72789
|
+
}
|
|
72790
|
+
targetSelection.visible = true;
|
|
72791
|
+
if (targetSelection.selection && value.selection) {
|
|
72792
|
+
applyMask(config4, targetSelection.selection, value.selection);
|
|
72793
|
+
}
|
|
72794
|
+
}
|
|
72795
|
+
for (const [type, selection] of Object.entries(mask.abstractFields?.fields ?? {})) {
|
|
72796
|
+
if (!selection) {
|
|
72797
|
+
continue;
|
|
72798
|
+
}
|
|
72799
|
+
if (target.abstractFields?.fields[type]) {
|
|
72800
|
+
applyMask(config4, { fields: target.abstractFields.fields[type] }, { fields: selection });
|
|
72801
|
+
}
|
|
72802
|
+
const targetType = config4.schema.getType(type);
|
|
72803
|
+
if (!targetType) {
|
|
72804
|
+
continue;
|
|
72805
|
+
}
|
|
72806
|
+
if (graphql14.isAbstractType(targetType)) {
|
|
72807
|
+
for (const possible of config4.schema.getPossibleTypes(targetType)) {
|
|
72808
|
+
if (target.abstractFields?.fields[possible.name]) {
|
|
72809
|
+
applyMask(
|
|
72810
|
+
config4,
|
|
72811
|
+
{ fields: target.abstractFields.fields[possible.name] },
|
|
72812
|
+
{ fields: selection }
|
|
72813
|
+
);
|
|
72814
|
+
}
|
|
72815
|
+
}
|
|
72816
|
+
}
|
|
72817
|
+
const mappedType = target.abstractFields?.typeMap[type];
|
|
72818
|
+
if (target.abstractFields && mappedType && target.abstractFields.fields[mappedType]) {
|
|
72819
|
+
applyMask(
|
|
72820
|
+
config4,
|
|
72821
|
+
{ fields: target.abstractFields.fields[mappedType] },
|
|
72822
|
+
{ fields: selection }
|
|
72823
|
+
);
|
|
72824
|
+
}
|
|
72825
|
+
}
|
|
72826
|
+
}
|
|
72495
72827
|
|
|
72496
72828
|
// src/codegen/generators/runtime/graphqlFunction.ts
|
|
72497
72829
|
var recast6 = __toESM(require_main2(), 1);
|
|
@@ -72817,7 +73149,7 @@ function addReferencedInputTypes(config4, filepath, body, visitedTypes, missingS
|
|
|
72817
73149
|
var graphql18 = __toESM(require_graphql2(), 1);
|
|
72818
73150
|
var recast10 = __toESM(require_main2(), 1);
|
|
72819
73151
|
var AST10 = recast10.types.builders;
|
|
72820
|
-
var
|
|
73152
|
+
var fragmentKey2 = " $fragments";
|
|
72821
73153
|
function inlineType({
|
|
72822
73154
|
config: config4,
|
|
72823
73155
|
filepath,
|
|
@@ -72857,24 +73189,24 @@ function inlineType({
|
|
|
72857
73189
|
const rootObj = type;
|
|
72858
73190
|
const inlineFragments = {};
|
|
72859
73191
|
const selectedFields = [];
|
|
72860
|
-
for (const
|
|
72861
|
-
if (
|
|
72862
|
-
const fragmentType = config4.schema.getType(
|
|
73192
|
+
for (const selection of selections) {
|
|
73193
|
+
if (selection.kind === "InlineFragment" && selection.typeCondition) {
|
|
73194
|
+
const fragmentType = config4.schema.getType(selection.typeCondition.name.value);
|
|
72863
73195
|
if (!graphql18.isInterfaceType(type) && !graphql18.isUnionType(type)) {
|
|
72864
|
-
selectedFields.push(...
|
|
73196
|
+
selectedFields.push(...selection.selectionSet.selections);
|
|
72865
73197
|
continue;
|
|
72866
73198
|
}
|
|
72867
73199
|
if (!graphql18.isInterfaceType(fragmentType) && !graphql18.isUnionType(fragmentType)) {
|
|
72868
73200
|
if (!inlineFragments[fragmentType.name]) {
|
|
72869
73201
|
inlineFragments[fragmentType.name] = [];
|
|
72870
73202
|
}
|
|
72871
|
-
inlineFragments[fragmentType.name].push(...
|
|
73203
|
+
inlineFragments[fragmentType.name].push(...selection.selectionSet.selections);
|
|
72872
73204
|
continue;
|
|
72873
73205
|
}
|
|
72874
73206
|
const possibleParents = config4.schema.getPossibleTypes(type).map((t2) => t2.name);
|
|
72875
73207
|
const freeSelections = [];
|
|
72876
73208
|
const typeSpecificSelections = {};
|
|
72877
|
-
for (const node of
|
|
73209
|
+
for (const node of selection.selectionSet.selections) {
|
|
72878
73210
|
if (node.kind !== "InlineFragment") {
|
|
72879
73211
|
freeSelections.push(node);
|
|
72880
73212
|
} else if (node.typeCondition) {
|
|
@@ -72897,23 +73229,30 @@ function inlineType({
|
|
|
72897
73229
|
);
|
|
72898
73230
|
}
|
|
72899
73231
|
}
|
|
72900
|
-
} else if (
|
|
72901
|
-
selectedFields.push(...
|
|
73232
|
+
} else if (selection.kind === "InlineFragment" && !selection.typeCondition) {
|
|
73233
|
+
selectedFields.push(...selection.selectionSet.selections);
|
|
72902
73234
|
} else {
|
|
72903
|
-
selectedFields.push(
|
|
73235
|
+
selectedFields.push(selection);
|
|
72904
73236
|
}
|
|
72905
73237
|
}
|
|
73238
|
+
const fields = Object.values(
|
|
73239
|
+
selectedFields.filter((field) => field.kind === "Field").reduce(
|
|
73240
|
+
(sel, field) => ({
|
|
73241
|
+
...sel,
|
|
73242
|
+
[field.alias?.value ?? field.name.value]: field
|
|
73243
|
+
}),
|
|
73244
|
+
{}
|
|
73245
|
+
)
|
|
73246
|
+
);
|
|
72906
73247
|
result = AST10.tsTypeLiteral([
|
|
72907
|
-
...(
|
|
72908
|
-
|
|
72909
|
-
|
|
72910
|
-
const { field } = selectionTypeInfo(config4.schema, filepath, rootObj, selection2);
|
|
72911
|
-
const attributeName = selection2.alias?.value || selection2.name.value;
|
|
73248
|
+
...fields.map((selection) => {
|
|
73249
|
+
const { field } = selectionTypeInfo(config4.schema, filepath, rootObj, selection);
|
|
73250
|
+
const attributeName = selection.alias?.value || selection.name.value;
|
|
72912
73251
|
let attributeType = inlineType({
|
|
72913
73252
|
config: config4,
|
|
72914
73253
|
filepath,
|
|
72915
73254
|
rootType: field.type,
|
|
72916
|
-
selections:
|
|
73255
|
+
selections: selection.selectionSet?.selections,
|
|
72917
73256
|
root: false,
|
|
72918
73257
|
allowReadonly,
|
|
72919
73258
|
visitedTypes,
|
|
@@ -72922,7 +73261,7 @@ function inlineType({
|
|
|
72922
73261
|
includeFragments,
|
|
72923
73262
|
allOptional
|
|
72924
73263
|
});
|
|
72925
|
-
const hasIncludeOrSkipDirective =
|
|
73264
|
+
const hasIncludeOrSkipDirective = selection.directives && selection.directives.filter(
|
|
72926
73265
|
(directive) => directive.name.value === "include" || directive.name.value === "skip"
|
|
72927
73266
|
).length > 0;
|
|
72928
73267
|
if (hasIncludeOrSkipDirective) {
|
|
@@ -72946,15 +73285,13 @@ function inlineType({
|
|
|
72946
73285
|
result.members.push(
|
|
72947
73286
|
readonlyProperty(
|
|
72948
73287
|
AST10.tsPropertySignature(
|
|
72949
|
-
AST10.
|
|
73288
|
+
AST10.stringLiteral(fragmentKey2),
|
|
72950
73289
|
AST10.tsTypeAnnotation(
|
|
72951
73290
|
AST10.tsTypeLiteral(
|
|
72952
73291
|
(fragmentSpreads || []).map(
|
|
72953
73292
|
(fragmentSpread) => AST10.tsPropertySignature(
|
|
72954
73293
|
AST10.identifier(fragmentSpread.name.value),
|
|
72955
|
-
AST10.tsTypeAnnotation(
|
|
72956
|
-
AST10.tsLiteralType(AST10.booleanLiteral(true))
|
|
72957
|
-
)
|
|
73294
|
+
AST10.tsTypeAnnotation(AST10.tsTypeLiteral([]))
|
|
72958
73295
|
)
|
|
72959
73296
|
)
|
|
72960
73297
|
)
|
|
@@ -72964,7 +73301,7 @@ function inlineType({
|
|
|
72964
73301
|
)
|
|
72965
73302
|
);
|
|
72966
73303
|
}
|
|
72967
|
-
const inlineFragmentSelections = Object.entries(inlineFragments).flatMap(([typeName,
|
|
73304
|
+
const inlineFragmentSelections = Object.entries(inlineFragments).flatMap(([typeName, fragment2]) => {
|
|
72968
73305
|
const fragmentRootType = config4.schema.getType(typeName);
|
|
72969
73306
|
if (!fragmentRootType) {
|
|
72970
73307
|
return [];
|
|
@@ -72973,7 +73310,7 @@ function inlineType({
|
|
|
72973
73310
|
config: config4,
|
|
72974
73311
|
filepath,
|
|
72975
73312
|
rootType: fragmentRootType,
|
|
72976
|
-
selections:
|
|
73313
|
+
selections: fragment2,
|
|
72977
73314
|
allowReadonly,
|
|
72978
73315
|
visitedTypes,
|
|
72979
73316
|
root,
|
|
@@ -73045,10 +73382,10 @@ function inlineType({
|
|
|
73045
73382
|
}
|
|
73046
73383
|
return result;
|
|
73047
73384
|
}
|
|
73048
|
-
function selectionTypeInfo(schema, filepath, rootType,
|
|
73049
|
-
const selectionName =
|
|
73385
|
+
function selectionTypeInfo(schema, filepath, rootType, selection) {
|
|
73386
|
+
const selectionName = selection.name.value;
|
|
73050
73387
|
let fields = {};
|
|
73051
|
-
if (
|
|
73388
|
+
if (selection.kind === "Field" && selection.name.value === "__typename") {
|
|
73052
73389
|
return {
|
|
73053
73390
|
field: {
|
|
73054
73391
|
name: "__typename",
|
|
@@ -73119,7 +73456,7 @@ async function generateDocumentTypes(config4, docs) {
|
|
|
73119
73456
|
filepath: filename,
|
|
73120
73457
|
selections: definition.selectionSet.selections,
|
|
73121
73458
|
fragmentDefinitions,
|
|
73122
|
-
|
|
73459
|
+
keepFragmentSpreadNodes: true
|
|
73123
73460
|
});
|
|
73124
73461
|
if (definition?.kind === "OperationDefinition") {
|
|
73125
73462
|
await generateOperationTypeDefs(
|
|
@@ -73343,39 +73680,26 @@ async function generateFragmentTypeDefs(config4, filepath, body, selections, def
|
|
|
73343
73680
|
if (!type) {
|
|
73344
73681
|
throw new Error("Should not get here");
|
|
73345
73682
|
}
|
|
73346
|
-
let extraExports = [];
|
|
73347
73683
|
let directive = definition.directives?.find(
|
|
73348
73684
|
(directive2) => directive2.name.value === config4.argumentsDirective
|
|
73349
73685
|
);
|
|
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
|
-
}
|
|
73686
|
+
let inputValue = !directive ? AST11.tsTypeLiteral([]) : AST11.tsTypeLiteral(
|
|
73687
|
+
(fragmentArgumentsDefinitions(config4, filepath, definition) || []).map(
|
|
73688
|
+
(definition2) => {
|
|
73689
|
+
return AST11.tsPropertySignature(
|
|
73690
|
+
AST11.identifier(definition2.variable.name.value),
|
|
73691
|
+
AST11.tsTypeAnnotation(
|
|
73692
|
+
tsTypeReference(config4, missingScalars, definition2, body)
|
|
73693
|
+
),
|
|
73694
|
+
definition2.type.kind !== "NonNullType"
|
|
73695
|
+
);
|
|
73696
|
+
}
|
|
73697
|
+
)
|
|
73698
|
+
);
|
|
73377
73699
|
body.push(
|
|
73378
|
-
|
|
73700
|
+
AST11.exportNamedDeclaration(
|
|
73701
|
+
AST11.tsTypeAliasDeclaration(AST11.identifier(inputTypeName), inputValue)
|
|
73702
|
+
),
|
|
73379
73703
|
AST11.exportNamedDeclaration(
|
|
73380
73704
|
AST11.tsTypeAliasDeclaration(
|
|
73381
73705
|
AST11.identifier(propTypeName),
|
|
@@ -73391,14 +73715,12 @@ async function generateFragmentTypeDefs(config4, filepath, body, selections, def
|
|
|
73391
73715
|
),
|
|
73392
73716
|
readonlyProperty(
|
|
73393
73717
|
AST11.tsPropertySignature(
|
|
73394
|
-
AST11.stringLiteral(
|
|
73718
|
+
AST11.stringLiteral(fragmentKey2),
|
|
73395
73719
|
AST11.tsTypeAnnotation(
|
|
73396
73720
|
AST11.tsTypeLiteral([
|
|
73397
73721
|
AST11.tsPropertySignature(
|
|
73398
73722
|
AST11.stringLiteral(propTypeName),
|
|
73399
|
-
AST11.tsTypeAnnotation(
|
|
73400
|
-
AST11.tsLiteralType(AST11.booleanLiteral(true))
|
|
73401
|
-
)
|
|
73723
|
+
AST11.tsTypeAnnotation(AST11.tsAnyKeyword())
|
|
73402
73724
|
)
|
|
73403
73725
|
])
|
|
73404
73726
|
)
|
|
@@ -74110,6 +74432,13 @@ async function addID(config4, documents) {
|
|
|
74110
74432
|
return;
|
|
74111
74433
|
}
|
|
74112
74434
|
return addKeysToSelection(config4, node, fragmentType);
|
|
74435
|
+
},
|
|
74436
|
+
FragmentDefinition(node) {
|
|
74437
|
+
const fragmentType = config4.schema.getType(node.typeCondition.name.value);
|
|
74438
|
+
if (!fragmentType) {
|
|
74439
|
+
return;
|
|
74440
|
+
}
|
|
74441
|
+
return addKeysToSelection(config4, node, fragmentType);
|
|
74113
74442
|
}
|
|
74114
74443
|
});
|
|
74115
74444
|
}
|
|
@@ -74128,7 +74457,7 @@ function addKeysToSelection(config4, node, fieldType) {
|
|
|
74128
74457
|
const selections = [...node.selectionSet.selections];
|
|
74129
74458
|
for (const keyField of keyFields) {
|
|
74130
74459
|
if (node.selectionSet.selections.find(
|
|
74131
|
-
(
|
|
74460
|
+
(selection) => selection.kind === "Field" && !selection.alias && selection.name.value === keyField
|
|
74132
74461
|
)) {
|
|
74133
74462
|
continue;
|
|
74134
74463
|
}
|