Apollo客户端不返回空查询结果

时间:2020-06-24 10:07:43

标签: angular observable apollo-client

如何强制watchQuery valueChanges返回空结果? 当我订阅它时,如果查询结果为空,它将永远不会返回,但是我需要检查服务器数据库中是否存在数据。如何获得空结果响应?

数据服务(ds)中的定义

watchQry(qry: DocumentNode, vars?: R): Observable<ApolloQueryResult<Query>> {
    return this.apollo.watchQuery<Query>({ query: qry, variables: vars}).valueChanges;
  }

用法

this.ds.watchQry(query{sqlsToDo(sql_id:3){sql_id sql_text}})
      .subscribe(result => {
        this.sql = result.data && result.data.sqlsToDo;
        this.loading = result.loading;
        this.error = result.errors;
})

游乐场工程 [1]:https://i.stack.imgur.com/Sg72H.png

这无济于事

return this.apollo.watchQuery<Query>({ query: qry, variables: vars, fetchPolicy: 'network-only'}).
      valueChanges;

0 个答案:

没有答案