Skip to content

Get queries execution time #4774

Answered by Alarid
Alarid asked this question in Q&A
Jan 6, 2023 · 1 comments · 6 replies
Discussion options

You must be logged in to vote

I don't have any "api layer" here cause I'm requesting my GraphqlQL endpoint directly. Just to clarify, your other option would be to do something like this ?

useQuery({
  queryKey: ['myQueryKey'],
  queryFn: () => {
    const start = performance.now()
    const res = await graphQLClient.request(MyGraphQLQuery)
    const time = performance.now() - start
    // do something with "time"
    return res
  }
})

I guess it could work, but doesn't it mean I'd have to handle error cases myself with try / catch ?

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@Alarid
Comment options

Answer selected by Alarid
@TkDodo
Comment options

@Alarid
Comment options

@areindl
Comment options

@Alarid
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
3 participants