【发布时间】:2022-06-18 19:24:58
【问题描述】:
我正在使用 Vue 和 Apollo,我正在做一个看起来就像下面的框的查询。
在我得到 API 响应后,我想从我的方法对象中调用一个方法。但是 Vue 并没有让我在 apollo 对象中访问它。
我想知道如何调用我的方法之一,但只有在我确定我得到该响应之后,无需使用按钮或其他东西手动触发它。
apollo: {
materials: {
query: gql`
query allMaterials($tenantId: ID, $name: String) {
tenantMaterials(tenantId: $tenantId, name: $name) {
edges {
node {
name
materialType {
name
id
}
brand
vendor
size
unit
inventory
createdAt
updatedAt
isActive
updatedBy
id
}
}
totalCount
}
}
`,
variables() {
return {
name: null
};
},
fetchPolicy: "cache-and-network",
update: response => {
return response.tenantMaterials.edges;
//I want to call a function/method after this response
},
skip: false
},
}
【问题讨论】: