4655 batch endpoints on the rest api (#5411)
- add POST rest/batch/<OBJECT> endpoint - rearrange rest api code with Twenty quality standard - unify REST API error format - Added PATCH verb to update objects - In openapi schema, we replaced PUT with PATCH verb to comply with REST standard - fix openApi schema to match the REST api ### Batch Create  ### Replace PUT by PATCH in open Api  ### Error format unification   
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
// https://gist.github.com/ManUtopiK/469aec75b655d6a4d912aeb3b75af3c9
|
||||
export const cleanGraphQLResponse = (input: any) => {
|
||||
if (!input) return null;
|
||||
const output = {};
|
||||
const isObject = (obj: any) => {
|
||||
return obj !== null && typeof obj === 'object' && !Array.isArray(obj);
|
||||
};
|
||||
|
||||
Object.keys(input).forEach((key) => {
|
||||
if (input[key] && input[key].edges) {
|
||||
output[key] = input[key].edges.map((edge) =>
|
||||
cleanGraphQLResponse(edge.node),
|
||||
);
|
||||
} else if (isObject(input[key])) {
|
||||
output[key] = cleanGraphQLResponse(input[key]);
|
||||
} else if (key !== '__typename') {
|
||||
output[key] = input[key];
|
||||
}
|
||||
});
|
||||
|
||||
return output;
|
||||
};
|
||||
Reference in New Issue
Block a user