I’m trying to set timeout
with prisma-labs/graphql-request
. I’ve tried the way described here – https://github.com/prisma-labs/graphql-request/issues/103.
const client = new GraphQLClient(config.url, {
timeout: 30000,
headers: {
Authorization: `Bearer ${token}`
}
})
My compiler complains as timeout is not directly present in Options interface – https://github.com/prisma-labs/graphql-request/blob/master/src/types.ts#L7.
Should I need to extend the Options interface to use timeout field?
6
You could extend it, might be worthwhile doing a
setTimeout()
if you're just wanting to wait 30 seconds before initializing the client/GraphQLClient.Nov 14, 2019 at 21:44
At that, I find it interesting that you were doing the exact syntax in the issue that was supposed to work!
Nov 14, 2019 at 21:44
Its not a wait before initializing client. I meant the timeout while fetching the API call result. Ex: if it takes more than 5 secs, I might want to stop the execution and free resources and show error page to user.
Nov 14, 2019 at 22:19
Ahh gotcha, makes sense, thanks for the clarity!
Nov 14, 2019 at 22:20
Yes, it's compile time error as well.
Nov 14, 2019 at 22:33