Skip to content

Commit

Permalink
Add index to the generateClientObjectClientID
Browse files Browse the repository at this point in the history
Reviewed By: captbaritone

Differential Revision: D39835997

fbshipit-source-id: fc4473de7f47f5b2c7aec2b0ea4e92ff99358a11
  • Loading branch information
alunyov authored and facebook-github-bot committed Sep 30, 2022
1 parent 55b829b commit 9d6d99b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 6 additions & 1 deletion packages/relay-runtime/store/ClientID.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,13 @@ function generateUniqueClientID(): DataID {
function generateClientObjectClientID(
typename: string,
localId: string,
index?: number,
): DataID {
return `${PREFIX}${typename}:${localId}`;
let key = `${PREFIX}${typename}:${localId}`;
if (index != null) {
key += ':' + index;
}
return key;
}

module.exports = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,14 +460,15 @@ class LiveResolverCache implements ResolverCache {
// @outputType payload.
const outputTypeDataID = generateClientObjectClientID(
normalizationInfo.concreteType,
`${resolverDataID}:${ii}`,
resolverDataID,
ii,
);
const source = normalizeOutputTypeValue(
outputTypeDataID,
currentValue,
variables,
normalizationInfo,
this._store.__getNormalizationOptions([`${field.path}.${ii}`]),
this._store.__getNormalizationOptions([field.path, String(ii)]),
);

// If, the `target` source (the current store)
Expand Down

0 comments on commit 9d6d99b

Please sign in to comment.