简体   繁体   English

GraphQL Apollo 查询客户端:轮询间隔不适用于 TypeScript

[英]GraphQL Apollo Query client: Poll interval not working with TypeScript

I'm trying to poll for a query that I have.我正在尝试轮询我的查询。

client.query<gql.FileCsvImport, gql.FileCsvImportVariables>({
      variables: { id: this.state.importId },
      query: CSV_IMPORT,
      pollInterval: 500,
    })

However I get the following error message但是我收到以下错误消息

Object literal may only specify known properties, and 'pollInterval' does not exist in type 'QueryOptions<FileCsvImportVariables>'

I clearly see that there is such an option in the docs我清楚地看到文档中有这样一个选项

What am I doing wrong here?我在这里做错了什么?

I'm on version "react-apollo": "^3.1.1", and "apollo-client": "^2.6.4",我在版本"react-apollo": "^3.1.1","apollo-client": "^2.6.4",

For any future passerby:对于任何未来的路人:

Somehow this doesn't work with client.query But works with react-hooks不知何故这不适用于client.query但适用于react-hooks

You can use it like below你可以像下面一样使用它

const { loading, error, data } = useQuery(CSV_IMPORT, {
      variables: { id: this.state.importId },
      pollInterval: 500,
    })

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM