I am writing to the cache with the update
function after a mutation using Apollo Client. The cache contains the obj as shown below, and it is working properly.
However, I can't find the right way to read the object in the cache. I am using readQuery
as mentioned in the docs but I can't find any examples to read objects outside the ROOT_QUERY
I have the following code in Angular
ngOnInit() {
const data = this.apollo.getClient().readQuery({
query: USER,
variables: {
id: '[email protected]',
},
});
console.log(data);
}
And the query is defined like this:
const USER = gql`
query User($id: String!) {
user(id: $id) @client {
token
}
}
`;
Not sure if I have to modify the typeDefs
or resolvers
when instantiating Apollo Client?
Thanks