如何为 graphql-client 设置超时

问题描述 投票:0回答:1

我正在尝试用

timeout
设置
prisma-labs/graphql-request
。我已经尝试过这里描述的方式 - https://github.com/prisma-labs/graphql-request/issues/103.

const client = new GraphQLClient(config.url, {
  timeout: 30000,
  headers: {
    Authorization: `Bearer ${token}`
  }
})

我的编译器抱怨超时没有直接出现在选项界面中 - https://github.com/prisma-labs/graphql-request/blob/master/src/types.ts#L7.

我是否需要扩展 Options 接口以使用超时字段?

graphql apollo apollo-client graphql-js prisma-graphql
1个回答
0
投票

如果您通过常规 api 为您的服务调用此服务,请记住它也可能在您的网络服务器上超时,例如 express 或 fastify,请尝试增加那里的所有超时时间,例如

fastify: {
  trustProxy: true,
  connectionTimeout: 15000,
},
© www.soinside.com 2019 - 2024. All rights reserved.