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

Allow passing in operationContext when fetching persisted queries #7643

Open
smyrick opened this issue Jul 13, 2023 · 0 comments
Open

Allow passing in operationContext when fetching persisted queries #7643

smyrick opened this issue Jul 13, 2023 · 0 comments

Comments

@smyrick
Copy link
Member

smyrick commented Jul 13, 2023

tl;dr I want to be able to call my distributed APQ cache with the trace id from the GraphQL HTTP request

A customer is adding a Redis cluster to their pipeline for APQ requests. Today it is not possible to access the operationContext while making a fetch to Redis because the call to .get only passes in the simple key.

query = await internals.persistedQueries.cache.get(queryHash);

This by design due to the simple nature of @apollo/utils.keyvaluecache which only accepts the key for .get calls.

However, inside the context in the requestContext we store a DataDog span that we would like to activate and create a custom DD span to have metrics for the request to the redis cluster.

Since we are not able to continue the span with the same trace id from the request the spans look like this and are detached from the GraphQL request:

image (1)


Instead we would like to be able to read the trace id from the request context which means we need some way of passing extra info to the .get call. Some small tweaks to the existing package like this could work but open for feedback

export interface KeyValueCache<V = string> {
  get(key: string): Promise<V | undefined>;
  // Optional new method so it is not breaking
  get?(key: string, options?: {}): Promise<V | undefined>;
  set(key: string, value: V, options?: KeyValueCacheSetOptions): Promise<void>;
  delete(key: string): Promise<boolean | void>;
}
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

No branches or pull requests

1 participant