Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add responseFromCache metadata to DataSourceFetchResult #380

Closed
wants to merge 1 commit into from

Conversation

Rikusor
Copy link

@Rikusor Rikusor commented Dec 5, 2024

Hello,

I tried to use the 6.4.0 version's responseFromCache metadata, in a customised solution where our approach is basically

  override async fetch<TResult>(path: string, request: DataSourceRequest = {}) {
    // Create messageId that will be used during the whole request lifecycle
    const messageId = this.getAzureMessageId();

    // Attach messageId to the request headers. Include other headers from client's request.
    request.headers = {
      ...request.headers,
      'x-message-id': messageId,
    };

    // Execute the request
    const result: DataSourceFetchResult<TResult> = await this.semaphore.withLock(() => super.fetch(path, request));

    // Only log request and response for no-depduplicated, successful requests
    if (!result.requestDeduplication.deduplicatedAgainstPreviousRequest) {
      this.logRequest(request as ApolloRequestOptions, path).finally();
      this.logResponse(request as ApolloRequestOptions, result).finally();
    }

    return result;
  }

In this implementation it would be required that I actually get this meta data part of DataSourceFetchResult -- So this can be sent to our logging platform correctly.

@smyrick Have I understood something wrong in this, and is there way for me to use your implementation here without these changes?

@Rikusor Rikusor requested a review from a team as a code owner December 5, 2024 08:59
Copy link

codesandbox-ci bot commented Dec 5, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@smyrick
Copy link
Member

smyrick commented Dec 5, 2024

@Rikusor Yep, good catch. I didn't propagate the value all the way up. To validate I added more tests and implemented the same here: #381

You can either add those to your PR if you want or we can close and merge

@Rikusor
Copy link
Author

Rikusor commented Dec 5, 2024

Thanks @smyrick will close this PR.

@Rikusor Rikusor closed this Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants