feat: enable query caching by using GET instead of POST
New Pull Request Checklist
- [x] I am not disclosing a vulnerability.
- [x] I am creating this PR in reference to an issue.
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
- [x] Add changes to documentation (guides, repository pages, in-code descriptions)
Thanks for opening this pull request!
- 🎉 We are excited about your hands-on contribution!
Codecov Report
Merging #386 (7e0c992) into main (7ba4f95) will decrease coverage by
0.52%. The diff coverage is80.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%) |
:arrow_down: |
| ...urces/ParseSwift/API/API+NonParseBodyCommand.swift | 81.09% <77.77%> (-0.44%) |
:arrow_down: |
| Sources/ParseSwift/Types/Query.swift | 87.47% <80.72%> (-7.67%) |
:arrow_down: |
| 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%) |
:arrow_up: |
| Sources/ParseSwift/Objects/ParseObject.swift | 84.80% <0.00%> (-0.31%) |
:arrow_down: |
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.
@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.