How to use the @graphql-box/helpers.dehydrateCacheMetadata function in @graphql-box/helpers

To help you get started, we’ve selected a few @graphql-box/helpers examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github badbatch / graphql-box / packages / server / src / main / index.ts View on Github external
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;
  }
github badbatch / graphql-box / packages / cache-manager / src / main / index.ts View on Github external
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,
    );
  }
github badbatch / graphql-box / packages / worker-client / src / register-worker / index.ts View on Github external
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 });
}
github badbatch / graphql-box / packages / server / src / main / index.ts View on Github external
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);
      }),
    );
github badbatch / graphql-box / packages / worker-client / src / register-worker / index.ts View on Github external
forAwaitEach(subscribeResult, ({ _cacheMetadata, ...otherProps }: MaybeRequestResult) => {
      const result: MaybeRequestResultWithDehydratedCacheMetadata = { ...otherProps };
      if (_cacheMetadata) result._cacheMetadata = dehydrateCacheMetadata(_cacheMetadata);
      postMessage({ context, method, result, type: GRAPHQL_BOX });
    });
  }