Files
klz-cables.com/.pnpm-store/v10/files/f6/872dc7fcc8ff48d6665cb69767e43cf851bc5ef403580fc1fa84cefddcd45ee5004b618db6c79cc5358f16e1b30e3e0f02461d494f36fd9667ceab76c2f190
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

67 lines
2.0 KiB
Plaintext

'use strict';
Object.defineProperty(exports, '__esModule', {
value: true,
});
exports.ScalarLeafsRule = ScalarLeafsRule;
var _inspect = require('../../jsutils/inspect.js');
var _GraphQLError = require('../../error/GraphQLError.js');
var _definition = require('../../type/definition.js');
/**
* Scalar leafs
*
* A GraphQL document is valid only if all leaf fields (fields without
* sub selections) are of scalar or enum types.
*/
function ScalarLeafsRule(context) {
return {
Field(node) {
const type = context.getType();
const selectionSet = node.selectionSet;
if (type) {
if ((0, _definition.isLeafType)((0, _definition.getNamedType)(type))) {
if (selectionSet) {
const fieldName = node.name.value;
const typeStr = (0, _inspect.inspect)(type);
context.reportError(
new _GraphQLError.GraphQLError(
`Field "${fieldName}" must not have a selection since type "${typeStr}" has no subfields.`,
{
nodes: selectionSet,
},
),
);
}
} else if (!selectionSet) {
const fieldName = node.name.value;
const typeStr = (0, _inspect.inspect)(type);
context.reportError(
new _GraphQLError.GraphQLError(
`Field "${fieldName}" of type "${typeStr}" must have a selection of subfields. Did you mean "${fieldName} { ... }"?`,
{
nodes: node,
},
),
);
} else if (selectionSet.selections.length === 0) {
const fieldName = node.name.value;
const typeStr = (0, _inspect.inspect)(type);
context.reportError(
new _GraphQLError.GraphQLError(
`Field "${fieldName}" of type "${typeStr}" must have at least one field selected.`,
{
nodes: node,
},
),
);
}
}
},
};
}