-
Notifications
You must be signed in to change notification settings - Fork 227
fix(DataStore): support for QueryPredicateConstant.all for graphql queries #1013
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
Conversation
|
are there other ways for the developer to get into this state?
|
Codecov Report
@@ Coverage Diff @@
## main #1013 +/- ##
==========================================
+ Coverage 56.71% 60.50% +3.78%
==========================================
Files 634 535 -99
Lines 18395 14650 -3745
==========================================
- Hits 10433 8864 -1569
+ Misses 7962 5786 -2176
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report at Codecov.
|
The requirement to return let syncExpression = DataStoreSyncExpression.syncExpression(TVSeries.schema) {
let rating = UserDefaults.standard.integer(forKey: "preferredRating")
guard rating > 0 else {
return QueryPredicateConstant.all
}
return TVSeries.keys.rating >= 4
}
let config = DataStoreConfiguration.custom(syncExpressions: [syncExpression])There's also an example of this kind of use case found in Android DataStore: Sync data to cloud docs |
I believe passing in
In the case of
Delete with predicate on a model type is currently not exposed to customer. we expose
See @Kilo-Loco 's response |
AmplifyPlugins/Core/AWSPluginsCore/Model/Support/QueryPredicate+GraphQL.swift
Show resolved
Hide resolved
nice catch, opened #1014 |
Unless this is implemented, it seems like it should be crashing the app during development time if |
|
Thanks for clarifying @Kilo-Loco @wooj2 |
| func graphQLFilter(for modelSchema: ModelSchema?) -> GraphQLFilter { | ||
| if self == .all { | ||
| return [:] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just thinking whether the return value should just be nil and the method return GraphQLFilter? type. I think keeping it GraphQLFilter is fine since FilterDecorator should be checking if the filter is empty anyways, just to be safe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm I think it would be useful to change if we had a use case of detecting nil vs an empty GraphQLFilter. In this case, of QueryPredicateConstant.all, i think that returning [:] is an accurate representation of .all -- that is, there is no filter -- so at this point, i'm not seeing a strong case for changing this to an optional.
Customers will experience a crash in the event they define a sync query with the
.allconstant. For example:This code change remedies this by using
[:]as the filter value -- effectively disabling the selective sync expression.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.