Skip to content

Commit

Permalink
Ensure frozen incoming.pageInfo object not modified.
Browse files Browse the repository at this point in the history
Quick follow-up to #7224.
  • Loading branch information
benjamn committed Oct 27, 2020
1 parent e67dae8 commit 9a53d3e
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/utilities/policies/pagination.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { __rest } from "tslib";

import { FieldPolicy, Reference } from '../../cache';
import { mergeDeep } from '../common/mergeDeep';

type KeyArgs = FieldPolicy<any>["keyArgs"];

Expand Down Expand Up @@ -152,11 +153,19 @@ export function relayStylePagination<TNode = Reference>(
// pageInfo.{start,end}Cursor to {first,last}Edge.cursor.
const firstCursor = firstEdge && firstEdge.cursor;
if (firstCursor && !startCursor) {
pageInfo.startCursor = firstCursor;
incoming = mergeDeep(incoming, {
pageInfo: {
startCursor: firstCursor,
},
});
}
const lastCursor = lastEdge && lastEdge.cursor;
if (lastCursor && !endCursor) {
pageInfo.endCursor = lastCursor;
incoming = mergeDeep(incoming, {
pageInfo: {
endCursor: lastCursor,
},
});
}
}

Expand Down

0 comments on commit 9a53d3e

Please sign in to comment.