-
Notifications
You must be signed in to change notification settings - Fork 202
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
fix(Model): retrieve correct associated target name #965
Conversation
Codecov Report
@@ Coverage Diff @@
## main #965 +/- ##
==========================================
+ Coverage 55.54% 55.57% +0.02%
==========================================
Files 634 634
Lines 18373 18401 +28
==========================================
+ Hits 10206 10227 +21
- Misses 8167 8174 +7
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
AmplifyPlugins/DataStore/AWSDataStoreCategoryPlugin/Storage/SQLite/SQLStatement+Condition.swift
Show resolved
Hide resolved
Amplify/Categories/DataStore/Model/Internal/Schema/ModelSchema.swift
Outdated
Show resolved
Hide resolved
AmplifyPlugins/Core/AWSPluginsCore/Model/GraphQLRequest/GraphQLRequest+Model.swift
Outdated
Show resolved
Hide resolved
AmplifyPlugins/Core/AWSPluginsCore/Model/Support/QueryPredicate+GraphQL.swift
Show resolved
Hide resolved
AmplifyPlugins/Core/AWSPluginsCore/Model/Support/QueryPredicate+GraphQL.swift
Outdated
Show resolved
Hide resolved
AmplifyPlugins/Core/AWSPluginsCore/Model/Support/QueryPredicate+GraphQL.swift
Outdated
Show resolved
Hide resolved
AmplifyPlugins/Core/AWSPluginsCore/Model/Support/QueryPredicate+GraphQL.swift
Outdated
Show resolved
Hide resolved
AmplifyPlugins/Core/AWSPluginsCore/Model/Support/QueryPredicate+GraphQL.swift
Outdated
Show resolved
Hide resolved
AmplifyPlugins/Core/AWSPluginsCoreTests/Model/GraphQLDocument/GraphQLListQueryTests.swift
Outdated
Show resolved
Hide resolved
AmplifyPlugins/Core/AWSPluginsCore/Model/Support/QueryPredicate+GraphQL.swift
Outdated
Show resolved
Hide resolved
AmplifyPlugins/Core/AWSPluginsCore/Model/Support/QueryPredicate+GraphQL.swift
Outdated
Show resolved
Hide resolved
AmplifyPlugins/Core/AWSPluginsCoreTests/Model/Support/QueryPredicateGraphQLTests.swift
Show resolved
Hide resolved
AmplifyPlugins/Core/AWSPluginsCore/Model/Support/QueryPredicate+GraphQL.swift
Outdated
Show resolved
Hide resolved
...WSDataStoreCategoryPluginIntegrationTests/Connection/DataStoreConnectionScenario1Tests.swift
Show resolved
Hide resolved
...WSDataStoreCategoryPluginIntegrationTests/Connection/DataStoreConnectionScenario4Tests.swift
Show resolved
Hide resolved
...WSDataStoreCategoryPluginIntegrationTests/Connection/DataStoreConnectionScenario5Tests.swift
Show resolved
Hide resolved
...WSDataStoreCategoryPluginIntegrationTests/Connection/DataStoreConnectionScenario5Tests.swift
Show resolved
Hide resolved
AmplifyPlugins/DataStore/AWSDataStoreCategoryPluginTests/Core/SQLStatementTests.swift
Show resolved
Hide resolved
looks like there's an extension on ModelField+Schema that already generates the columnName |
248fad6
to
cc1b492
Compare
AmplifyPlugins/Core/AWSPluginsCore/Model/Support/QueryPredicate+GraphQL.swift
Outdated
Show resolved
Hide resolved
Amplify/Categories/DataStore/Model/Collection/List+LazyLoad.swift
Outdated
Show resolved
Hide resolved
AmplifyPlugins/Core/AWSPluginsCore/Model/Support/ModelSchema+Extension.swift
Outdated
Show resolved
Hide resolved
AmplifyPlugins/Core/AWSPluginsCore/Model/Support/ModelSchema+Extension.swift
Outdated
Show resolved
Hide resolved
AmplifyPlugins/Core/AWSPluginsCore/Model/Support/QueryPredicate+GraphQL.swift
Outdated
Show resolved
Hide resolved
AmplifyPlugins/Core/AWSPluginsCore/Model/Support/QueryPredicate+GraphQL.swift
Outdated
Show resolved
Hide resolved
AmplifyPlugins/Core/AWSPluginsCore/Model/Support/QueryPredicate+GraphQL.swift
Outdated
Show resolved
Hide resolved
AmplifyPlugins/Core/AWSPluginsCore/Model/Support/QueryPredicate+GraphQL.swift
Show resolved
Hide resolved
AmplifyPlugins/Core/AWSPluginsCore/Model/Support/QueryPredicate+GraphQL.swift
Outdated
Show resolved
Hide resolved
AmplifyPlugins/Core/AWSPluginsCore/Model/Support/QueryPredicate+GraphQL.swift
Outdated
Show resolved
Hide resolved
AmplifyPlugins/DataStore/AWSDataStoreCategoryPluginTests/Core/SQLStatementTests.swift
Outdated
Show resolved
Hide resolved
AmplifyPlugins/DataStore/AWSDataStoreCategoryPlugin/Storage/SQLite/SQLStatement+Condition.swift
Show resolved
Hide resolved
AmplifyPlugins/DataStore/AWSDataStoreCategoryPluginTests/Core/SQLStatementTests.swift
Outdated
Show resolved
Hide resolved
AmplifyPlugins/Core/AWSPluginsCore/Model/Support/QueryPredicate+GraphQL.swift
Outdated
Show resolved
Hide resolved
AmplifyPlugins/Core/AWSPluginsCore/Model/Support/QueryPredicate+GraphQL.swift
Outdated
Show resolved
Hide resolved
preconditionFailure( | ||
"Could not find QueryPredicateOperation or QueryPredicateGroup for \(String(describing: self))") |
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.
no action needed just a thought exercise.. If developers use QueryPredicateConstant.all
then it will fail. Is there a way for developers to get into this state?
- Calling API directly with a predicate
.all
and app will crash. This is probably okay since it is not supported to use.all
- Is there a scenario which is calling into DataStore, and then it gets synced to the API and fail here? If so, this may be a bigger concern, what should API do when they see a predicate that is ".all"?
Secondly, precondionFailure affects live apps as well. In one of my latest PR's, I've started using assert(false, "message")
instead so that it crashes only during debug builds, and not on release builds
@@ -47,11 +70,27 @@ public struct GraphQLFilterConverter { | |||
/// Extension to translate a `QueryPredicate` into a GraphQL query variables object | |||
extension QueryPredicate { | |||
|
|||
/// - Warning: Although this has `public` access, it is intended for internal use and should not be used directly | |||
/// by host applications. The behavior of this may change without warning. | |||
public func graphQLFilter(for modelSchema: ModelSchema?) -> GraphQLFilter { |
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.
add doc comment for the public API, i see up above
/// Extension to translate a `QueryPredicate` into a GraphQL query variables object
perhaps this information can be on top of the method as well. just a suggestion since i recall the discussion regarding adding doc comment and warning, etc. something like
/// Retrieve the GraphQL representation of the `QueryPredicate`. This translates the `QueryPredicate` into a
/// JSON object, useful for passing as the "filter" or "condition" input of the GraphQL variables. For example
/// <Query Predicate example to JSON string>
///
/// - Warning: Although this has `public` access, it is intended for internal use and should not be used directly
/// by host applications. The behavior of this may change without warning.
Issue #, if available:
Alternative of fixing: #512
Description of changes:
An alternative for this PR which was reverted: #885
Moved
func modelName(forField: fieldName)
toAmplifyPluginsCore
so that both API and DataStore can reuse the logic.QueryPredicate
, the correct columnName forbelongsTo
andhasOne
field can be retrieved frommodelSchema.association
. In this case, CLI change is not required.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.