Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private async _handleRequest(
request: string,
options: ServerRequestOptions,
context: MaybeRequestContext,
): Promise {
const { _cacheMetadata, ...otherProps } = await this._client.request(request, options, context);
const response: MaybeRequestResultWithDehydratedCacheMetadata = { ...otherProps };
if (_cacheMetadata) response._cacheMetadata = dehydrateCacheMetadata(_cacheMetadata);
return response;
}
private async _setQueryResponseCacheEntry(
hash: string,
{ cacheMetadata, data }: ResponseData,
options: RequestOptions,
context: RequestContext,
): Promise {
const dehydratedCacheMetadata = dehydrateCacheMetadata(cacheMetadata);
const cacheControl = CacheManager._getOperationCacheControl(cacheMetadata, context.operation);
await this._setCacheEntry(
QUERY_RESPONSES,
hash,
{ cacheMetadata: dehydratedCacheMetadata, data },
{ cacheHeaders: { cacheControl }, tag: options.tag },
options,
context,
);
}
async function handleRequest(
request: string,
method: MethodNames,
options: RequestOptions,
context: MessageContext,
client: Client,
): Promise {
const { _cacheMetadata, ...otherProps } = await client.request(request, options, context);
const result: MaybeRequestResultWithDehydratedCacheMetadata = { ...otherProps };
if (_cacheMetadata) result._cacheMetadata = dehydrateCacheMetadata(_cacheMetadata);
postMessage({ context, method, result, type: GRAPHQL_BOX });
}
Object.keys(requests).map(async requestHash => {
const request = requests[requestHash];
const { _cacheMetadata, ...otherProps } = await this._client.request(request, options, context);
responses[requestHash] = { ...otherProps };
if (_cacheMetadata) responses[requestHash]._cacheMetadata = dehydrateCacheMetadata(_cacheMetadata);
}),
);
forAwaitEach(subscribeResult, ({ _cacheMetadata, ...otherProps }: MaybeRequestResult) => {
const result: MaybeRequestResultWithDehydratedCacheMetadata = { ...otherProps };
if (_cacheMetadata) result._cacheMetadata = dehydrateCacheMetadata(_cacheMetadata);
postMessage({ context, method, result, type: GRAPHQL_BOX });
});
}