guardia-messenger/node_modules/graphql/validation/rules/NoFragmentCyclesRule.js
DESKTOP-TKLFCPRython f29f525c77 refactor: 101.79.17.164 → zioinfo.co.kr 전체 도메인 변환 + Manager UI 배포
- 37개 파일 IP → zioinfo.co.kr 치환 (소스/매뉴얼/설정/하네스)
- Manager DrConsole/NetworkConsole/CsapConsole 빌드 + /var/www/manager/ 배포
- 테스트: Manager HTTP 200, ITSM 신규 API 7개 전체 200

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-31 10:09:17 +09:00

71 lines
2.2 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.NoFragmentCyclesRule = NoFragmentCyclesRule;
var _GraphQLError = require("../../error/GraphQLError.js");
function NoFragmentCyclesRule(context) {
// Tracks already visited fragments to maintain O(N) and to ensure that cycles
// are not redundantly reported.
var visitedFrags = Object.create(null); // Array of AST nodes used to produce meaningful errors
var spreadPath = []; // Position in the spread path
var spreadPathIndexByName = Object.create(null);
return {
OperationDefinition: function OperationDefinition() {
return false;
},
FragmentDefinition: function FragmentDefinition(node) {
detectCycleRecursive(node);
return false;
}
}; // This does a straight-forward DFS to find cycles.
// It does not terminate when a cycle was found but continues to explore
// the graph to find all possible cycles.
function detectCycleRecursive(fragment) {
if (visitedFrags[fragment.name.value]) {
return;
}
var fragmentName = fragment.name.value;
visitedFrags[fragmentName] = true;
var spreadNodes = context.getFragmentSpreads(fragment.selectionSet);
if (spreadNodes.length === 0) {
return;
}
spreadPathIndexByName[fragmentName] = spreadPath.length;
for (var _i2 = 0; _i2 < spreadNodes.length; _i2++) {
var spreadNode = spreadNodes[_i2];
var spreadName = spreadNode.name.value;
var cycleIndex = spreadPathIndexByName[spreadName];
spreadPath.push(spreadNode);
if (cycleIndex === undefined) {
var spreadFragment = context.getFragment(spreadName);
if (spreadFragment) {
detectCycleRecursive(spreadFragment);
}
} else {
var cyclePath = spreadPath.slice(cycleIndex);
var viaPath = cyclePath.slice(0, -1).map(function (s) {
return '"' + s.name.value + '"';
}).join(', ');
context.reportError(new _GraphQLError.GraphQLError("Cannot spread fragment \"".concat(spreadName, "\" within itself") + (viaPath !== '' ? " via ".concat(viaPath, ".") : '.'), cyclePath));
}
spreadPath.pop();
}
spreadPathIndexByName[fragmentName] = undefined;
}
}