apollo-link-state icon indicating copy to clipboard operation
apollo-link-state copied to clipboard

How to read Data one object from array of objects from cache.

Open AGurindapalli opened this issue 6 years ago • 1 comments

How to read S1 from the from the cache? I have stored the data in cache like this.

cache

Here is my Apollo-Client ap_client

If i'm reading using Fragment's like below i'm getting data as null

c

AGurindapalli avatar Jan 28 '19 09:01 AGurindapalli

You have to use the query within the function instead of the getCacheKey.

const storyQuery = gql`
  query {
    story @client {
      storyKey1
      storyKey2
    }
  }
`;

const { story } = cache.readQuery({ query: storyQuery });
......

RealSilo avatar Feb 07 '19 20:02 RealSilo