Skip to content

Commit

Permalink
Fix issue with too many resolvers
Browse files Browse the repository at this point in the history
  • Loading branch information
robertherber committed Jul 24, 2024
1 parent 54bcd50 commit 179ffcd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/smart-keys-love.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@zemble/graphql": patch
---

Fix issue with too many resolvers in useServerTiming
10 changes: 8 additions & 2 deletions packages/graphql/utils/useServerTiming.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,15 @@ export const useServerTiming = (): EnvelopPlugin<Pick<Zemble.GraphQLContext, 'ho
// eslint-disable-next-line functional/immutable-data
opCounts[fieldName] = opCounts[fieldName] ? opCounts[fieldName]! + 1 : 1

const uniqueName = `${fieldName}-${opCounts[fieldName]}`
if (opCounts[fieldName] > 2) {
return () => {}
}

const more = opCounts[fieldName] > 1 ? '++' : ''

const uniqueName = `${fieldName}-${opCounts[fieldName]}${more}`

startTime(c, uniqueName, fieldName)
startTime(c, uniqueName, fieldName + more)

return () => {
endTime(c, uniqueName)
Expand Down

0 comments on commit 179ffcd

Please sign in to comment.