I am trying to write a nested object to apollo cache but it it not working. Simple variables writes are working fine. I am using Apollo-client v2.4
// Schema
const GET_DATA_FROM_CACHE = gql `
name
address
age
`
// Reading data from cache
render() {
return (
<Query query = {GET_DATA_FROM_CACHE} fetchPolicy = {"cache-only"}>
{({ data }) => (
<View >
<Text> Name: {data.name} </Text>
</View>
)}
</Query>
)
}
// THIS WORKS as I can see the name in my Text field
client.writeData({
data: {
name: 'mr x',
age: 25
}
})
// THROWS ERROR: "cannot read property country of undefined"
client.writeData({
data: {
name: 'mr x',
address: {
country: 'y',
city: 'z'
},
age: 25
}
})