Files
klz-cables.com/.pnpm-store/v10/files/a5/4c03b7651306141696793cfadbe285bdcaca888048a88942c3329f548a105f99fab9589fbc4e0d925d5e8e5874cbc13e7f3640f05161b046e0a05e959dd1fe
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

62 lines
1.5 KiB
Plaintext

'use strict';
Object.defineProperty(exports, '__esModule', {
value: true,
});
exports.NoUnusedFragmentsRule = NoUnusedFragmentsRule;
var _GraphQLError = require('../../error/GraphQLError.js');
/**
* No unused fragments
*
* A GraphQL document is only valid if all fragment definitions are spread
* within operations, or spread within other fragments spread within operations.
*
* See https://spec.graphql.org/draft/#sec-Fragments-Must-Be-Used
*/
function NoUnusedFragmentsRule(context) {
const operationDefs = [];
const fragmentDefs = [];
return {
OperationDefinition(node) {
operationDefs.push(node);
return false;
},
FragmentDefinition(node) {
fragmentDefs.push(node);
return false;
},
Document: {
leave() {
const fragmentNameUsed = Object.create(null);
for (const operation of operationDefs) {
for (const fragment of context.getRecursivelyReferencedFragments(
operation,
)) {
fragmentNameUsed[fragment.name.value] = true;
}
}
for (const fragmentDef of fragmentDefs) {
const fragName = fragmentDef.name.value;
if (fragmentNameUsed[fragName] !== true) {
context.reportError(
new _GraphQLError.GraphQLError(
`Fragment "${fragName}" is never used.`,
{
nodes: fragmentDef,
},
),
);
}
}
},
},
};
}