Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
CacheManager._setCachedResponseData(
{ cacheability, data },
cachedResponseData,
keysAndPaths,
{ dataTypeName: get(data, TYPE_NAME_KEY), fieldTypeName: typeName },
options,
context,
);
if (!isObjectLike(data)) return;
const objectLikeData = data as PlainObjectMap | any[];
const promises: Array> = [];
iterateChildFields(
field,
objectLikeData,
(childField: FieldNode, childTypeName: string | undefined, childIndex?: number) => {
promises.push(
this._analyzeField(
childField,
{ index: childIndex, requestFieldCacheKey, requestFieldPath, typeName: childTypeName, ...cachedFieldData },
{ ...cachedResponseData, data: cachedResponseData.data[propNameOrIndex] },
options,
context,
),
);
},
);
await Promise.all(promises);
field: FieldNode,
ancestorKeysAndPaths: AncestorKeysAndPaths,
{ cacheMetadata, data }: ResponseData,
options: RequestOptions,
context: RequestContext,
): void {
const { requestFieldPath: ancestorRequestFieldPath } = ancestorKeysAndPaths;
const keysAndPaths = CacheManager._getFieldKeysAndPaths(field, ancestorKeysAndPaths);
const { requestFieldPath, responseDataPath } = keysAndPaths;
const fieldData = get(data, responseDataPath, null);
if (!isObjectLike(fieldData)) return;
const objectLikeFieldData = fieldData as PlainObjectMap | any[];
this._setFieldTypeCacheDirective(cacheMetadata, { ancestorRequestFieldPath, requestFieldPath }, context);
iterateChildFields(
field,
objectLikeFieldData,
(childField: FieldNode, typeName: string | undefined, childIndex?: number) => {
this._setFieldCacheability(
childField,
{ index: childIndex, requestFieldPath, responseDataPath },
{ cacheMetadata, data },
options,
context,
);
},
);
}
private async _parseFieldDataEntityAndRequestFieldPathCacheEntryData(
field: FieldNode,
ancestorKeysAndPaths: AncestorKeysAndPaths,
{ cacheMetadata, dataEntityData, requestFieldPathData }: ResponseDataForCaching,
options: RequestOptions,
context: RequestContext,
): Promise {
const keysAndPaths = CacheManager._getFieldKeysAndPaths(field, ancestorKeysAndPaths);
const { requestFieldCacheKey, requestFieldPath, responseDataPath } = keysAndPaths;
const fieldData = get(requestFieldPathData, responseDataPath, null);
if (!isObjectLike(fieldData)) return;
const objectLikeFieldData = fieldData as PlainObjectMap | any[];
const promises: Array> = [];
iterateChildFields(
field,
objectLikeFieldData,
(childField: FieldNode, typeName: string | undefined, childIndex?: number) => {
promises.push(
this._parseFieldDataEntityAndRequestFieldPathCacheEntryData(
childField,
{ index: childIndex, requestFieldCacheKey, requestFieldPath, responseDataPath },
{ cacheMetadata, dataEntityData, requestFieldPathData },
options,
context,
),
);
},
);
await Promise.all(promises);