Skip to content

Commit

Permalink
fix(gatsby): fix broken GraphQL resolver tracing (#29015)
Browse files Browse the repository at this point in the history
* fix(gatsby): fix broken GraphQL resolvers tracing

* end activity for sync resolvers
  • Loading branch information
vladar authored Jan 15, 2021
1 parent 90b6e3d commit 48db6ac
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions packages/gatsby/src/schema/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -566,13 +566,23 @@ export function wrappingResolver<TSource, TArgs>(
)
activity.start()
}
try {
return resolver(parent, args, context, info)
} finally {
const result = resolver(parent, args, context, info)

if (!activity) {
return result
}

const endActivity = (): void => {
if (activity) {
activity.end()
}
}
if (typeof result?.then === `function`) {
result.then(endActivity, endActivity)
} else {
endActivity()
}
return result
}
}

Expand Down

0 comments on commit 48db6ac

Please sign in to comment.