diff --git a/src/utilities/policies/pagination.ts b/src/utilities/policies/pagination.ts index 0afe6d0b757..66f3429558c 100644 --- a/src/utilities/policies/pagination.ts +++ b/src/utilities/policies/pagination.ts @@ -118,16 +118,14 @@ export function relayStylePagination( }, merge(existing = makeEmptyData(), incoming, { args, isReference, readField }) { - const incomingEdges = incoming.edges || []; - if (incomingEdges.length) { - incomingEdges.forEach(edge => { - if (isReference(edge)) { - // In case edge is a Reference, we read out its cursor field - // and store it as an extra property of the Reference object. - edge.cursor = readField("cursor", edge); - } - }); - } + const incomingEdges = incoming.edges ? incoming.edges.map(edge => { + if (isReference(edge = { ...edge })) { + // In case edge is a Reference, we read out its cursor field and + // store it as an extra property of the Reference object. + edge.cursor = readField("cursor", edge); + } + return edge; + }) : []; if (incoming.pageInfo) { // In case we did not request the cursor field for edges in this