Files
klz-cables.com/.pnpm-store/v10/files/a4/b403e2242f54c4a7d75f7550fa5fa63f598d0e383f576ebef34085a5768f3c348e9adab52c4cd0bd24dc7573d5c5007beac5e9c79d1915fa785c0b3e4db345
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

45 lines
1.4 KiB
Plaintext

import { Kind } from 'graphql';
import { createGraphQLError } from '../../error.js';
export function identity(value) {
return value;
}
// eslint-disable-next-line @typescript-eslint/ban-types
export function ensureObject(value, ast) {
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
throw createGraphQLError(`JSONObject cannot represent non-object value: ${value}`, ast
? {
nodes: ast,
}
: undefined);
}
return value;
}
export function parseObject(ast, variables) {
const value = Object.create(null);
ast.fields.forEach(field => {
// eslint-disable-next-line no-use-before-define
value[field.name.value] = parseLiteral(field.value, variables);
});
return value;
}
export function parseLiteral(ast, variables) {
switch (ast.kind) {
case Kind.STRING:
case Kind.BOOLEAN:
return ast.value;
case Kind.INT:
case Kind.FLOAT:
return parseFloat(ast.value);
case Kind.OBJECT:
return parseObject(ast, variables);
case Kind.LIST:
return ast.values.map(n => parseLiteral(n, variables));
case Kind.NULL:
return null;
case Kind.VARIABLE: {
const name = ast.name.value;
return variables ? variables[name] : undefined;
}
}
}