查询:
HOUSEDETAIL : gql`
query houseDetail($_id:ID){
houseDetail(_id:$_id) {
address
address1
street
phoneNumber
houseNo
}
}
`,
尝试调用apolloClient时的React中的代码:
const Page2 = compose(graphql(query.HOUSEDETAIL,{name:'houseDetail', options: (props) => ({variables: {_id:props.houseAddress._id,fetchPolicy: 'network-only'}})})) (Dashboard)
错误在浏览器控制台中显示如下:
props{"houseAddress":{},"houseDetail":{"variables":{"fetchPolicy":"network-only"},"loading":true,"networkStatus":1}}
答案 0 :(得分:1)
这似乎是一个常见问题,通常可以通过添加notifyOnNetworkStatusChange: true
在您的特定情况下:
const Page2 = compose(
graphql(
query.HOUSEDETAIL,
{
name:'houseDetail',
options: (props) => ({
variables: {
_id:props.houseAddress._id
}, // ====> this bracket was also misplaced on your example code
fetchPolicy: 'network-only',
notifyOnNetworkStatusChange: true
})
}
)
)(Dashboard)
有关notifyOnNetworkStatusChange
的更多信息可以在ReactApollo docs中找到: