我正在使用 Apollo 和 GraphQL 进行 Angular 项目。我有一个突变,它更新了一个帐户列表,其中包含与之相关的相关详细信息。成功突变后,我使用 refetchqueries 查询 API 以获取更新的帐户列表。一切正常,直到这部分。
this.apollo.mutate({
mutation: mutationCreateNewAccount,
variables: {
accountNumber: this.accountNumber,
accountType: this.accountType,
routingNumber: this.routingNumber,
nameOfAcountHolder: this.name
},
refetchQueries: [{
query: queryAccounts,
variables: { accountNumber: this.accountNumber }
}]}).subscribe(({ data }) => console.log(data),
Run Code Online (Sandbox Code Playgroud)
订阅的“数据”从突变返回响应,但有没有办法使用“queryAccounts”返回的数据,它也作为此突变的一部分运行?
在反应中似乎有一种方法可以做到这一点,但我没有成功在 Angular 中做类似的事情。