I have an Apollo Angular Client application. I write to the store:
const userQuery = this.userGql.document;
this.apollo.getClient().writeQuery({
query: userQuery,
data: { user: result.data.login.user },
});
This works. I then retrieve the user from the cache and display the data:
this.user = this.apollo.getClient().readQuery({
query: this.userGql.document,
}).user;
This also works. However, the entire time my cache in Google Chrome Devtools looks like this:
Why is this empty? I'd like to view my cache state debugging. Also, when I go to GraphiQL tab, and select get from cache, it queries the API (I can tell because I don't pass a token and it rejects the request with an unauthenticated error).
Edit, I did set connectToDevTools
to true just in case:
export function createApollo(httpLink: HttpLink) {
return {
link: httpLink.create({ uri }),
cache: new InMemoryCache({
dataIdFromObject: object => {
switch (object.__typename) {
case 'user':
return object['username'];
}
},
}),
connectToDevTools: true,
};
}