簡體   English   中英

GraphQL Apollo 查詢客戶端:輪詢間隔不適用於 TypeScript

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

我正在嘗試輪詢我的查詢。

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<FileCsvImportVariables>'

我清楚地看到文檔中有這樣一個選項

我在這里做錯了什么?

我在版本"react-apollo": "^3.1.1","apollo-client": "^2.6.4",

對於任何未來的路人:

不知何故這不適用於client.query但適用於react-hooks

你可以像下面一樣使用它

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