【发布时间】:2019-06-05 16:37:23
【问题描述】:
我正在查询并且已经记录了结果。一切正常,但是当我想继续处理结果时,它总是“未定义”(参见第二次日志记录)。 我确定我在这里错过了一些明显的东西,但我真的很想得到你的帮助:)
render() {
let saved;
this.props.apolloClient
.watchQuery<Query>({
query: gql`
query($id: ID!) {
element(id: $id) {
children {
... on TextNote {
name
description
type
}
}
}
}
`,
variables: { id: 0 }
})
.subscribe(({ data: { element: { children } } }) => {
console.log(children); // this is the wanted result
saved = children;
});
console.log("save");
console.log(saved); // this is undefined for some reason
【问题讨论】:
标签: javascript node.js reactjs typescript graphql