【问题标题】:GraphQL Apollo Query client: Poll interval not working with TypeScriptGraphQL Apollo 查询客户端:轮询间隔不适用于 TypeScript
【发布时间】:2020-03-31 08:06:32
【问题描述】:

我正在尝试poll 查询我的问题。

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

但是我收到以下错误消息

Object literal may only specify known properties, and 'pollInterval' does not exist in type 'QueryOptions&lt;FileCsvImportVariables&gt;'

我清楚地看到docs中有这样一个选项

我在这里做错了什么?

我使用的是"react-apollo": "^3.1.1","apollo-client": "^2.6.4", 版本

【问题讨论】:

  • 使用 apollo boost 包 npm install apollo-boost @apollo/react-hooks graphql。让我知道这是否有效
  • 是的,终于走上了这条路。现在使用钩子。

标签: reactjs typescript graphql react-apollo apollo-client


【解决方案1】:

对于任何未来的路人:

不知何故,这不适用于 client.query 但适用于 react-hooks

你可以像下面这样使用它

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

【讨论】:

    猜你喜欢
    • 2020-06-14
    • 2016-08-31
    • 1970-01-01
    • 2019-11-02
    • 2017-09-04
    • 2018-03-25
    • 2020-10-25
    • 2021-07-04
    • 2018-07-08
    相关资源
    最近更新 更多