Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
fieldPathChecklist.get(requestFieldPath),
childTypeName,
);
if (hasData || typeUnused) {
if (!hasChildFields(childField)) {
deleteChildFields(field, childField);
} else if (this._filterField(childField, fieldPathChecklist, requestFieldPath, context)) {
deleteChildFields(field, childField);
}
}
}
this._filterInlineFragments(field);
this._filterIDsAndTypeNames(field);
return !hasChildFields(field);
}
private _addFieldToNode(node: FieldNode | InlineFragmentNode, key: string): void {
if (!hasChildFields(node, key)) {
const mockAST = parse(`{${key}}`);
const queryNode = getOperationDefinitions(mockAST, QUERY)[0];
const fieldsAndTypeNames = getChildFields(queryNode, key);
if (!fieldsAndTypeNames) return;
const { fieldNode } = fieldsAndTypeNames[0];
addChildField(node, fieldNode, this._schema, key);
}
}
const { fieldNode: childField, typeName: childTypeName } = fieldsAndTypeNames[i];
const childFieldName = getName(childField);
if (childFieldName === this._typeIDKey || childFieldName === TYPE_NAME_KEY) continue;
const { requestFieldPath } = CacheManager._getFieldKeysAndPaths(childField, {
requestFieldPath: ancestorRequestFieldPath,
});
const { hasData, typeUnused } = CacheManager._checkFieldPathChecklist(
fieldPathChecklist.get(requestFieldPath),
childTypeName,
);
if (hasData || typeUnused) {
if (!hasChildFields(childField)) {
deleteChildFields(field, childField);
} else if (this._filterField(childField, fieldPathChecklist, requestFieldPath, context)) {
deleteChildFields(field, childField);
}
}
}
this._filterInlineFragments(field);
this._filterIDsAndTypeNames(field);
return !hasChildFields(field);
}
private async _analyzeField(
field: FieldNode,
cachedAncestorFieldData: CachedAncestorFieldData,
cachedResponseData: CachedResponseData,
options: RequestOptions,
context: RequestContext,
): Promise {
if (hasChildFields(field)) {
await this._analyzeParentField(field, cachedAncestorFieldData, cachedResponseData, options, context);
} else {
await CacheManager._analyzeLeafField(field, cachedAncestorFieldData, cachedResponseData, options, context);
}
}
const result = await this._checkCacheEntry(REQUEST_FIELD_PATHS, hashedRequestFieldCacheKey, options, context);
if (result) {
fieldData = this._mergeObjects(result.entry, fieldData);
}
await this._setCacheEntry(
REQUEST_FIELD_PATHS,
hashedRequestFieldCacheKey,
fieldData,
{ cacheHeaders: { cacheControl: cacheability.printCacheControl() }, tag: options.tag },
options,
context,
);
if (hasChildFields(field)) {
if (isEntity) {
set(data, responseDataPath, { __cacheKey: `${REQUEST_FIELD_PATHS}::${hashedRequestFieldCacheKey}` });
} else {
unset(data, responseDataPath);
}
}
}
}