apollographql / apollo-ios

📱  A strongly-typed, caching GraphQL client for iOS, written in Swift.
https://www.apollographql.com/docs/ios/
MIT License
3.89k stars 728 forks source link

How to write cache after mutations #3440

Closed guendev closed 2 months ago

guendev commented 2 months ago

Question

I am looking to implement cache management after a mutation, but I couldn’t find relevant documentation or examples for this use case in Apollo iOS.

Here’s what I am trying to achieve (similar to how I would do it in JavaScript with Apollo):

Steps in JavaScript:

  1. Query: MeQuery returns null.
  2. Perform: SignUp mutation returns { token: string, user: User }.
  3. Write: Update the MeQuery cache with data from the SignUp mutation.
  4. Recall: Re-execute MeQuery to reflect the updated cache.
AnthonyMDev commented 2 months ago

Hi @guendev, documentation for local cache mutations can be found here. If you still have specific questions after reading those docs, please feel free to reply here with them.

github-actions[bot] commented 2 months ago

Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo iOS usage and allow us to serve you better.