Skip to content

Commit 4fea508

Browse files
mrTuomoKcursoragent
andcommitted
fix(graphql-proxy-server): replace deprecated util type guards
@types/node 24 no longer types util.isBoolean/isNumber; use typeof checks so proxy typechecks pass on Node 24. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent f501bff commit 4fea508

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

packages/graphql-proxy-server/src/utils/queryBuilder.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,29 @@
1-
import { isBoolean, isNumber } from 'util';
2-
31
import composeQuery from './composeQuery.js';
42

53
interface VariableToKeyItem {
64
key: string;
75
value?: (string | null | number)[] | string | number | boolean | null;
86
}
97

8+
const isScalarQueryValue = (
9+
value: VariableToKeyItem['value']
10+
): value is string | number | boolean => {
11+
if (Array.isArray(value)) {
12+
return false;
13+
}
14+
return (
15+
typeof value === 'boolean' ||
16+
typeof value === 'number' ||
17+
(value !== null && value !== undefined && value !== '')
18+
);
19+
};
20+
1021
const queryBuilder = (items: VariableToKeyItem[]): string => {
1122
return items.reduce((query, item) => {
1223
if (Array.isArray(item.value) && item.value.length) {
1324
return composeQuery(query, item.key, item.value.join(','));
14-
} else if (
15-
(item.value || isBoolean(item.value) || isNumber(item.value)) &&
16-
!Array.isArray(item.value)
17-
) {
25+
}
26+
if (isScalarQueryValue(item.value)) {
1827
return composeQuery(query, item.key, item.value);
1928
}
2029
return query;

0 commit comments

Comments
 (0)