Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No way to clear client cache #36

Closed
michaeleconomy opened this issue Jun 14, 2018 · 9 comments
Closed

No way to clear client cache #36

michaeleconomy opened this issue Jun 14, 2018 · 9 comments
Assignees
Labels
closing-soon-if-no-response This issue will be closed in 7 days unless further comments are made. feature-request New feature requests requesting info Further information is needed before this is actionable

Comments

@michaeleconomy
Copy link

Ok, so i'm struggling with this case:

i have a query that does "get info about the current user". It doesn't take an id as a parameter, instead depends on the users context.identity.cognitoIdentityId (iam auth).

The problem i have is: if you do that call, i believe it is caching the response, then if i sign out and sign back in (as a different user), i get the old user's information when i do the same call.

Perhaps i can play with the cache keys (so it contains the user id in it)? - i'm not sure how to set this:
appSyncClient?.apolloClient?.cacheKeyForObject = { $0["id"] }

I didn't see documentation for this method, but maybe i'm missing it?

Alternatively - it would be great to just expose appSyncClient.store.clearCache (i think this is a thing here: https://github.com/apollographql/apollo-ios/blob/master/Sources/Apollo/ApolloStore.swift)

Sorry if i'm not making sense - I'll be happy to go into more detail if needed.

@michaeleconomy
Copy link
Author

Alternatively, if there was a way to disable caching entirely, that would work also - I'd want to do caching at a higher level anyway - so request caching doesn't make sense in my use case.

@rohandubal
Copy link
Contributor

Hello @michaeleconomy

Thanks for reporting this. I will take the part of adding clearStore as an API as a feature request to the team.

Regarding your use-case, you can achieve this by scoping the cache to individual users and delete the database file once a user signs out.

Example: https://github.com/aws-samples/aws-mobile-appsync-events-starter-ios/blob/master/EventsApp/AppDelegate.swift#L20 Here we are explicitly setting the database path. We can delete the file and create a new one for every user.

Hope that helps.

Thanks,
Rohan

@rohandubal rohandubal added the feature-request New feature requests label Jul 2, 2018
@joelmbell
Copy link
Contributor

+1 on this feature request

@rohandubal rohandubal self-assigned this Sep 21, 2018
@frankmuellr frankmuellr assigned rohandubal and unassigned rohandubal Oct 2, 2018
@larryonoff
Copy link
Contributor

+1

@connorpower
Copy link

+1

1 similar comment
@shawnmmatthews
Copy link

+1

@larryonoff
Copy link
Contributor

PR #141 is already in master!

@palpatim
Copy link
Contributor

This is released on 2.9.2. Please let us know if you have any issues.

@palpatim palpatim added requesting info Further information is needed before this is actionable closing-soon-if-no-response This issue will be closed in 7 days unless further comments are made. labels Jan 18, 2019
@stale
Copy link

stale bot commented Jan 28, 2019

This issue has been automatically closed because of inactivity. Please open a new issue if are still encountering problems.

@stale stale bot closed this as completed Jan 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closing-soon-if-no-response This issue will be closed in 7 days unless further comments are made. feature-request New feature requests requesting info Further information is needed before this is actionable
Projects
None yet
Development

No branches or pull requests

8 participants