Skip to content

Help tracing nested resolvers #1066

Answered by 2snEM6
2snEM6 asked this question in Q&A
Oct 15, 2023 · 1 comments · 7 replies
Discussion options

You must be logged in to vote

Thank you! I ended up doing something like this

export function createSentryWrapper<T = unknown>(
  options?: SentryWrapperOptions<T>,
) {
  return <Context extends object = object>(
      resolver: GraphQLFieldResolver<unknown, Context, Record<string, unknown>>,
      fieldOptions: T,
      tracingOptions?: SentryWrapperOptions<T>,
    ): GraphQLFieldResolver<unknown, Context, Record<string, unknown>> =>
    (source, args, ctx, info) => {
      return Sentry.runWithAsyncContext(
        () => {
          const scope = Sentry.getCurrentHub().getScope();
          const transaction = scope.getTransaction();

          if (!transaction) {
            return resolver(source, args, ctx, info);

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@2snEM6
Comment options

Answer selected by hayes
@2snEM6
Comment options

@hayes
Comment options

@2snEM6
Comment options

@2snEM6
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants