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

feat: enable query caching by using GET instead of POST #386

Merged
merged 11 commits into from
Aug 17, 2022

Conversation

cbaker6
Copy link
Contributor

@cbaker6 cbaker6 commented Aug 3, 2022

New Pull Request Checklist

Issue Description

All queries currently use POST requests, preventing the ability to leverage the cache policies available in the SDK.

Related issue: #382

Approach

Enable all queries to use GET requests by default so queries are cached. Developers can change the default request behavior for all queries by setting usingPostForQuery = true to not cache any of the queries. Setting usingPostForQuery = true can be useful when using the Swift SDK on the server-side as many developers will not want the server caching queries.

TODOs before merging

  • Add tests
  • Add entry to changelog
  • Add changes to documentation (guides, repository pages, in-code descriptions)

@parse-github-assistant
Copy link

parse-github-assistant bot commented Aug 3, 2022

Thanks for opening this pull request!

  • 🎉 We are excited about your hands-on contribution!

@cbaker6 cbaker6 linked an issue Aug 3, 2022 that may be closed by this pull request
3 tasks
@cbaker6 cbaker6 marked this pull request as draft August 3, 2022 21:43
@codecov
Copy link

codecov bot commented Aug 3, 2022

Codecov Report

Merging #386 (7e0c992) into main (7ba4f95) will decrease coverage by 0.52%.
The diff coverage is 80.99%.

@@            Coverage Diff             @@
##             main     #386      +/-   ##
==========================================
- Coverage   89.66%   89.13%   -0.53%     
==========================================
  Files         155      156       +1     
  Lines       14125    14528     +403     
==========================================
+ Hits        12665    12950     +285     
- Misses       1460     1578     +118     
Impacted Files Coverage Δ
Sources/ParseSwift/API/API.swift 99.35% <ø> (-0.03%) ⬇️
...urces/ParseSwift/API/API+NonParseBodyCommand.swift 81.09% <77.77%> (-0.44%) ⬇️
Sources/ParseSwift/Types/Query.swift 87.47% <80.72%> (-7.67%) ⬇️
Sources/ParseSwift/API/API+Command.swift 89.21% <100.00%> (ø)
Sources/ParseSwift/Extensions/Dictionary.swift 100.00% <100.00%> (ø)
Sources/ParseSwift/Parse.swift 98.79% <100.00%> (+0.02%) ⬆️
Sources/ParseSwift/Objects/ParseObject.swift 84.80% <0.00%> (-0.31%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@cbaker6
Copy link
Contributor Author

cbaker6 commented Aug 4, 2022

@aliasad106 you can try out this branch for query cache. It should work without any changes needed on your end as long as you didn't change the default cache policy of the SDK. I've tested it with some of the query code in Playgrounds and it seems to work.

I still need to add test cases to ensure this doesn't break in the future and to fix the code coverage.

@cbaker6 cbaker6 marked this pull request as ready for review August 17, 2022 15:05
@cbaker6 cbaker6 merged commit 0c5d7f6 into parse-community:main Aug 17, 2022
@cbaker6 cbaker6 deleted the cache branch August 17, 2022 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enable queries to use caching policies
1 participant