INNER CODE UNIT · JavaScript
deflate
gajus/graphql-deduplicator · src/deflate.js:6
const deflate = (node: NodeType, index: Object, path: $ReadOnlyArray<string>): NodeType => {
if (Array.isArray(node)) {
return node.map((childNode) => {
if (typeof childNode === 'string' || typeof childNode === 'number' || typeof childNode === 'boolean') {
return childNode;
} else {
return deflate(childNode, index, path);
}
});
} else {
// Handle null and undefined by preserving them
if (node === null || node === undefined) {
return node;
}
if (node && node.id && node.__typename) {
const route = path.join(',');