Skip to content

Commit 243c4e1

Browse files
committed
need to verify if cache class is correct
1 parent a7c21ae commit 243c4e1

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

packages/data-connect/src/cache/Cache.ts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@ import {
2828
StubDataObjectList
2929
} from './util';
3030

31-
/**
32-
* Interface for a stub result tree, with fields which are stub data objects.
33-
* @public
34-
*/
31+
/** Interface for a stub result tree, with fields which are stub data objects. */
3532
export interface StubResultTree {
3633
[alias: string]:
3734
| SelectionSet
@@ -40,10 +37,7 @@ export interface StubResultTree {
4037
| StubDataObjectList;
4138
}
4239

43-
/**
44-
* A class used to hold an entity's normalized cached values across all queries.
45-
* @public
46-
*/
40+
/** A class used to hold an entity's normalized cached values across all queries. */
4741
class BackingDataObject {
4842
/** Stable unique key identifying the entity across types. Format: TypeName|ID */
4943
readonly typedKey: string;
@@ -109,10 +103,7 @@ class BackingDataObject {
109103
}
110104
}
111105

112-
/**
113-
* A class representing the cache for query results and entity data.
114-
* @public
115-
*/
106+
/** A class representing the cache for query results and entity data. */
116107
export class Cache {
117108
/** A map of (srtCacheKey --> StubResultTree returned from that query). */
118109
private srtCache = new Map<string, StubResultTree>();
@@ -161,7 +152,7 @@ export class Cache {
161152
/**
162153
* Creates a StubResultTree based on the data returned from a query
163154
* @param data the data property of the query result
164-
* @returns
155+
* @returns the StubResultTree
165156
*/
166157
private createSrt(data: QueryData): StubResultTree {
167158
const srt: StubResultTree = {};
@@ -221,6 +212,11 @@ export class Cache {
221212
return cachedSelectionSet;
222213
}
223214

215+
/**
216+
* Caches a single field's value. If the value is a selection set, it recursively normalizes it.
217+
* @param value The field value to cache.
218+
* @returns The cached field value, which might be a StubDataObject if it was a normalizeable selection set.
219+
*/
224220
private cacheField(value: Field): Field {
225221
if (isSelectionSet(value)) {
226222
// recurse, and replace cacheable selection sets with SDOs

packages/data-connect/test/unit/Cache.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,4 +674,4 @@ export interface ListMoviesData extends StubResultTree {
674674
// eslint-disable-next-line @typescript-eslint/array-type
675675
movies: (ListMovies_Movies & Movie_Key)[];
676676
actor: ListMovies_Actor & Actor_Key;
677-
}
677+
}

0 commit comments

Comments
 (0)