[QRQC_2] No implicitAny in twenty-server (#12075)
# Introduction Following https://github.com/twentyhq/twenty/pull/12068 Related with https://github.com/twentyhq/core-team-issues/issues/975 We're enabling `noImplicitAny` handled few use case manually, added a `ts-expect-error` to the others, we should plan to handle them in the future
This commit is contained in:
@ -16,15 +16,18 @@ export const cleanGraphQLResponse = (input: any) => {
|
||||
if (isObject(obj[key])) {
|
||||
if (obj[key].edges) {
|
||||
// Handle edges by mapping over them and applying cleanObject to each node
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
cleanedObj[key] = obj[key].edges.map((edge) =>
|
||||
cleanObject(edge.node),
|
||||
);
|
||||
} else {
|
||||
// Recursively clean nested objects
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
cleanedObj[key] = cleanObject(obj[key]);
|
||||
}
|
||||
} else {
|
||||
// Directly assign non-object properties
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
cleanedObj[key] = obj[key];
|
||||
}
|
||||
});
|
||||
@ -35,22 +38,29 @@ export const cleanGraphQLResponse = (input: any) => {
|
||||
Object.keys(input).forEach((key) => {
|
||||
if (isObject(input[key]) && input[key].edges) {
|
||||
// Handle collections with edges, ensuring data is placed under the data key
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
output.data[key] = input[key].edges.map((edge) => cleanObject(edge.node));
|
||||
// Move pageInfo and totalCount to the top level
|
||||
if (input[key].pageInfo) {
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
output['pageInfo'] = input[key].pageInfo;
|
||||
}
|
||||
if (input[key].totalCount) {
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
output['totalCount'] = input[key].totalCount;
|
||||
}
|
||||
} else if (isObject(input[key])) {
|
||||
// Recursively clean and assign nested objects under the data key
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
output.data[key] = cleanObject(input[key]);
|
||||
} else if (Array.isArray(input[key])) {
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
const itemsWithEdges = input[key].filter((item) => item.edges);
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
const cleanedObjArray = itemsWithEdges.map(({ edges, ...item }) => {
|
||||
return {
|
||||
...item,
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
[key]: edges.map((edge) => cleanObject(edge.node)),
|
||||
};
|
||||
});
|
||||
@ -58,6 +68,7 @@ export const cleanGraphQLResponse = (input: any) => {
|
||||
output.data = cleanedObjArray;
|
||||
} else {
|
||||
// Assign all other properties directly under the data key
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
output.data[key] = input[key];
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user