Skip to content

Commit 2d576a4

Browse files
authored
chore: kickoff v1 release
2 parents 64ac769 + b1fbf5a commit 2d576a4

File tree

11 files changed

+203
-69
lines changed

11 files changed

+203
-69
lines changed

.codecov.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
coverage:
2-
branch: main
2+
branch: v1
33
status:
44
project:
55
default:

Amplify.xcodeproj/project.pbxproj

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88

99
/* Begin PBXBuildFile section */
1010
061FD5B1AF28D70F20D52407 /* Pods_Amplify_AmplifyTestConfigs_AmplifyTestCommon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FAE4710DB0051BDB010053AA /* Pods_Amplify_AmplifyTestConfigs_AmplifyTestCommon.framework */; };
11-
2104FE60284E7288007CF949 /* SchemaDrift.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2104FE5D284E7288007CF949 /* SchemaDrift.swift */; };
12-
2104FE61284E7288007CF949 /* SchemaDrift+Schema.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2104FE5E284E7288007CF949 /* SchemaDrift+Schema.swift */; };
13-
2104FE62284E7288007CF949 /* EnumDrift.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2104FE5F284E7288007CF949 /* EnumDrift.swift */; };
1411
2104FE4728490338007CF949 /* Blog8+Schema.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2104FE3F28490337007CF949 /* Blog8+Schema.swift */; };
1512
2104FE4828490338007CF949 /* MyNestedModel8.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2104FE4028490337007CF949 /* MyNestedModel8.swift */; };
1613
2104FE4928490338007CF949 /* MyCustomModel8+Schema.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2104FE4128490338007CF949 /* MyCustomModel8+Schema.swift */; };
@@ -21,6 +18,9 @@
2118
2104FE4E28490338007CF949 /* Post8+Schema.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2104FE4628490338007CF949 /* Post8+Schema.swift */; };
2219
2104FE562849115B007CF949 /* Comment8+Schema.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2104FE542849115B007CF949 /* Comment8+Schema.swift */; };
2320
2104FE572849115B007CF949 /* Comment8.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2104FE552849115B007CF949 /* Comment8.swift */; };
21+
2104FE60284E7288007CF949 /* SchemaDrift.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2104FE5D284E7288007CF949 /* SchemaDrift.swift */; };
22+
2104FE61284E7288007CF949 /* SchemaDrift+Schema.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2104FE5E284E7288007CF949 /* SchemaDrift+Schema.swift */; };
23+
2104FE62284E7288007CF949 /* EnumDrift.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2104FE5F284E7288007CF949 /* EnumDrift.swift */; };
2424
210922502359634C00CEC295 /* AnalyticsProfile.swift in Sources */ = {isa = PBXBuildFile; fileRef = 210922492359634B00CEC295 /* AnalyticsProfile.swift */; };
2525
210922522359634C00CEC295 /* AnalyticsPropertyValue.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2109224B2359634C00CEC295 /* AnalyticsPropertyValue.swift */; };
2626
210922572359693900CEC295 /* BasicAnalyticsEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 210922562359693800CEC295 /* BasicAnalyticsEvent.swift */; };
@@ -519,6 +519,7 @@
519519
97F793D827BC670B000153D6 /* CustomerMultipleSecondaryIndexV2.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97F793D727BC670B000153D6 /* CustomerMultipleSecondaryIndexV2.swift */; };
520520
97F793DA27BC6720000153D6 /* CustomerMultipleSecondaryIndexV2+Schema.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97F793D927BC6720000153D6 /* CustomerMultipleSecondaryIndexV2+Schema.swift */; };
521521
A5BD5B125AE6AAD604092274 /* Pods_Amplify_AmplifyTestConfigs_AmplifyTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5009041CDAAB46551245D381 /* Pods_Amplify_AmplifyTestConfigs_AmplifyTests.framework */; };
522+
B413D8ED2A4B64EE00638FDF /* SubscriptionSelectionSetBehavior.swift in Sources */ = {isa = PBXBuildFile; fileRef = B413D8EC2A4B64EE00638FDF /* SubscriptionSelectionSetBehavior.swift */; };
522523
B4251A0124250369007F59EF /* AuthConfirmResetPasswordRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4251A0024250369007F59EF /* AuthConfirmResetPasswordRequest.swift */; };
523524
B4251A05242503F6007F59EF /* AuthConfirmResetPasswordOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4251A04242503F6007F59EF /* AuthConfirmResetPasswordOperation.swift */; };
524525
B4251A072425047D007F59EF /* AuthChangePasswordRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4251A062425047D007F59EF /* AuthChangePasswordRequest.swift */; };
@@ -973,10 +974,6 @@
973974
0671E539A66859A57E071091 /* Pods-Amplify-AmplifyTestConfigs-AmplifyTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Amplify-AmplifyTestConfigs-AmplifyTests.release.xcconfig"; path = "Target Support Files/Pods-Amplify-AmplifyTestConfigs-AmplifyTests/Pods-Amplify-AmplifyTestConfigs-AmplifyTests.release.xcconfig"; sourceTree = "<group>"; };
974975
09D90ABD9EDED6D6B1780253 /* Pods-Amplify-AWSPluginsCore.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Amplify-AWSPluginsCore.release.xcconfig"; path = "Target Support Files/Pods-Amplify-AWSPluginsCore/Pods-Amplify-AWSPluginsCore.release.xcconfig"; sourceTree = "<group>"; };
975976
1FA86170C161C5E46E57A5F9 /* Pods-Amplify-AWSPluginsCore.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Amplify-AWSPluginsCore.debug.xcconfig"; path = "Target Support Files/Pods-Amplify-AWSPluginsCore/Pods-Amplify-AWSPluginsCore.debug.xcconfig"; sourceTree = "<group>"; };
976-
2104FE5D284E7288007CF949 /* SchemaDrift.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SchemaDrift.swift; sourceTree = "<group>"; };
977-
2104FE5E284E7288007CF949 /* SchemaDrift+Schema.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "SchemaDrift+Schema.swift"; sourceTree = "<group>"; };
978-
2104FE5F284E7288007CF949 /* EnumDrift.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EnumDrift.swift; sourceTree = "<group>"; };
979-
2104FE3D2849010D007CF949 /* schema.graphql */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = schema.graphql; sourceTree = "<group>"; };
980977
2104FE3F28490337007CF949 /* Blog8+Schema.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Blog8+Schema.swift"; sourceTree = "<group>"; };
981978
2104FE4028490337007CF949 /* MyNestedModel8.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MyNestedModel8.swift; sourceTree = "<group>"; };
982979
2104FE4128490338007CF949 /* MyCustomModel8+Schema.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "MyCustomModel8+Schema.swift"; sourceTree = "<group>"; };
@@ -987,6 +984,9 @@
987984
2104FE4628490338007CF949 /* Post8+Schema.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Post8+Schema.swift"; sourceTree = "<group>"; };
988985
2104FE542849115B007CF949 /* Comment8+Schema.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Comment8+Schema.swift"; sourceTree = "<group>"; };
989986
2104FE552849115B007CF949 /* Comment8.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Comment8.swift; sourceTree = "<group>"; };
987+
2104FE5D284E7288007CF949 /* SchemaDrift.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SchemaDrift.swift; sourceTree = "<group>"; };
988+
2104FE5E284E7288007CF949 /* SchemaDrift+Schema.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "SchemaDrift+Schema.swift"; sourceTree = "<group>"; };
989+
2104FE5F284E7288007CF949 /* EnumDrift.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EnumDrift.swift; sourceTree = "<group>"; };
990990
210922492359634B00CEC295 /* AnalyticsProfile.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AnalyticsProfile.swift; sourceTree = "<group>"; };
991991
2109224B2359634C00CEC295 /* AnalyticsPropertyValue.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AnalyticsPropertyValue.swift; sourceTree = "<group>"; };
992992
210922562359693800CEC295 /* BasicAnalyticsEvent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BasicAnalyticsEvent.swift; sourceTree = "<group>"; };
@@ -1500,6 +1500,7 @@
15001500
97F793D727BC670B000153D6 /* CustomerMultipleSecondaryIndexV2.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomerMultipleSecondaryIndexV2.swift; sourceTree = "<group>"; };
15011501
97F793D927BC6720000153D6 /* CustomerMultipleSecondaryIndexV2+Schema.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CustomerMultipleSecondaryIndexV2+Schema.swift"; sourceTree = "<group>"; };
15021502
AF4FA69A23AEB42CF7BB8336 /* Pods-Amplify-AmplifyTestConfigs-AmplifyTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Amplify-AmplifyTestConfigs-AmplifyTests.debug.xcconfig"; path = "Target Support Files/Pods-Amplify-AmplifyTestConfigs-AmplifyTests/Pods-Amplify-AmplifyTestConfigs-AmplifyTests.debug.xcconfig"; sourceTree = "<group>"; };
1503+
B413D8EC2A4B64EE00638FDF /* SubscriptionSelectionSetBehavior.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubscriptionSelectionSetBehavior.swift; sourceTree = "<group>"; };
15031504
B4251A0024250369007F59EF /* AuthConfirmResetPasswordRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthConfirmResetPasswordRequest.swift; sourceTree = "<group>"; };
15041505
B4251A04242503F6007F59EF /* AuthConfirmResetPasswordOperation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthConfirmResetPasswordOperation.swift; sourceTree = "<group>"; };
15051506
B4251A062425047D007F59EF /* AuthChangePasswordRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthChangePasswordRequest.swift; sourceTree = "<group>"; };
@@ -1965,16 +1966,6 @@
19651966
/* End PBXFrameworksBuildPhase section */
19661967

19671968
/* Begin PBXGroup section */
1968-
2104FE5C284E7263007CF949 /* SchemaDrift */ = {
1969-
isa = PBXGroup;
1970-
children = (
1971-
2104FE5F284E7288007CF949 /* EnumDrift.swift */,
1972-
2104FE5D284E7288007CF949 /* SchemaDrift.swift */,
1973-
2104FE5E284E7288007CF949 /* SchemaDrift+Schema.swift */,
1974-
);
1975-
path = SchemaDrift;
1976-
sourceTree = "<group>";
1977-
};
19781969
2104FE3B28490087007CF949 /* OptionalAssociations */ = {
19791970
isa = PBXGroup;
19801971
children = (
@@ -1992,6 +1983,16 @@
19921983
path = OptionalAssociations;
19931984
sourceTree = "<group>";
19941985
};
1986+
2104FE5C284E7263007CF949 /* SchemaDrift */ = {
1987+
isa = PBXGroup;
1988+
children = (
1989+
2104FE5F284E7288007CF949 /* EnumDrift.swift */,
1990+
2104FE5D284E7288007CF949 /* SchemaDrift.swift */,
1991+
2104FE5E284E7288007CF949 /* SchemaDrift+Schema.swift */,
1992+
);
1993+
path = SchemaDrift;
1994+
sourceTree = "<group>";
1995+
};
19951996
21092258235969D000CEC295 /* Event */ = {
19961997
isa = PBXGroup;
19971998
children = (
@@ -2045,6 +2046,7 @@
20452046
children = (
20462047
219A888423EB897700BBC5F2 /* GraphQLRequest+AnyModelWithSync.swift */,
20472048
2129BE1523948065006363A1 /* GraphQLRequest+Model.swift */,
2049+
B413D8EC2A4B64EE00638FDF /* SubscriptionSelectionSetBehavior.swift */,
20482050
);
20492051
path = GraphQLRequest;
20502052
sourceTree = "<group>";
@@ -5113,6 +5115,7 @@
51135115
21420A98237222A900FA140C /* AuthTokenProvider.swift in Sources */,
51145116
214C6226253A414E0041E96D /* AmplifyAWSServiceConfiguration+Platform.swift in Sources */,
51155117
21420A91237222A900FA140C /* AWSAuthorizationConfiguration.swift in Sources */,
5118+
B413D8ED2A4B64EE00638FDF /* SubscriptionSelectionSetBehavior.swift in Sources */,
51165119
212CE70F23E9E991007D8E71 /* ModelDecorator.swift in Sources */,
51175120
21420A97237222A900FA140C /* IAMCredentialProvider.swift in Sources */,
51185121
212CE70D23E9E991007D8E71 /* FilterDecorator.swift in Sources */,

Amplify/Categories/DataStore/Model/Internal/Schema/ModelField+Association.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,19 @@ extension ModelField {
228228
return true
229229
}
230230

231+
/// - Warning: Although this has `public` access, it is intended for internal & codegen use and should not be used
232+
/// directly by host applications. The behavior of this may change without warning. Though it is not used by host
233+
/// application making any change to these `public` types should be backward compatible, otherwise it will be a
234+
/// breaking change.
235+
public var _isBelongsToOrHasOne: Bool { // swiftlint:disable:this identifier_name
236+
switch association {
237+
case .belongsTo, .hasOne:
238+
return true
239+
case .hasMany, .none:
240+
return false
241+
}
242+
}
243+
231244
/// - Warning: Although this has `public` access, it is intended for internal & codegen use and should not be used
232245
/// directly by host applications. The behavior of this may change without warning. Though it is not used by host
233246
/// application making any change to these `public` types should be backward compatible, otherwise it will be a

AmplifyPlugins/API/Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,4 @@ SPEC CHECKSUMS:
117117

118118
PODFILE CHECKSUM: f542a7a3bf7a7e882e6ea4799c9722d5b6495208
119119

120-
COCOAPODS: 1.11.3
120+
COCOAPODS: 1.12.0

AmplifyPlugins/Core/AWSPluginsCore/Model/Decorator/ConflictResolutionDecorator.swift

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,17 @@ public struct ConflictResolutionDecorator: ModelBasedGraphQLDocumentDecorator {
1616

1717
private let version: Int?
1818
private let lastSync: Int?
19+
private let graphQLType: GraphQLOperationType
20+
private var primaryKeysOnly: Bool
1921

20-
public init(version: Int? = nil, lastSync: Int? = nil) {
22+
public init(version: Int? = nil,
23+
lastSync: Int? = nil,
24+
graphQLType: GraphQLOperationType = .mutation,
25+
primaryKeysOnly: Bool = false) {
2126
self.version = version
2227
self.lastSync = lastSync
28+
self.graphQLType = graphQLType
29+
self.primaryKeysOnly = primaryKeysOnly
2330
}
2431

2532
public func decorate(_ document: SingleDirectiveGraphQLDocument,
@@ -46,28 +53,59 @@ public struct ConflictResolutionDecorator: ModelBasedGraphQLDocumentDecorator {
4653
}
4754

4855
if let selectionSet = document.selectionSet {
49-
addConflictResolution(selectionSet: selectionSet)
56+
addConflictResolution(selectionSet: selectionSet, primaryKeysOnly: primaryKeysOnly)
5057
return document.copy(inputs: inputs, selectionSet: selectionSet)
5158
}
5259

5360
return document.copy(inputs: inputs)
5461
}
5562

63+
enum SyncMetadataFields {
64+
case full
65+
case deletedFieldOnly
66+
}
67+
5668
/// Append the correct conflict resolution fields for `model` and `pagination` selection sets.
57-
private func addConflictResolution(selectionSet: SelectionSet) {
69+
private func addConflictResolution(selectionSet: SelectionSet,
70+
primaryKeysOnly: Bool,
71+
includeSyncMetadataFields: SyncMetadataFields = .full) {
72+
var includeSyncMetadataFields = includeSyncMetadataFields
5873
switch selectionSet.value.fieldType {
5974
case .value, .embedded:
6075
break
6176
case .model:
62-
selectionSet.addChild(settingParentOf: .init(value: .init(name: "_version", fieldType: .value)))
63-
selectionSet.addChild(settingParentOf: .init(value: .init(name: "_deleted", fieldType: .value)))
64-
selectionSet.addChild(settingParentOf: .init(value: .init(name: "_lastChangedAt", fieldType: .value)))
77+
switch includeSyncMetadataFields {
78+
case .full:
79+
selectionSet.addChild(settingParentOf: .init(value: .init(name: "_version", fieldType: .value)))
80+
selectionSet.addChild(settingParentOf: .init(value: .init(name: "_deleted", fieldType: .value)))
81+
selectionSet.addChild(settingParentOf: .init(value: .init(name: "_lastChangedAt", fieldType: .value)))
82+
includeSyncMetadataFields = .deletedFieldOnly
83+
case .deletedFieldOnly:
84+
selectionSet.addChild(settingParentOf: .init(value: .init(name: "_deleted", fieldType: .value)))
85+
}
6586
case .pagination:
6687
selectionSet.addChild(settingParentOf: .init(value: .init(name: "startedAt", fieldType: .value)))
6788
}
6889

69-
selectionSet.children.forEach { child in
70-
addConflictResolution(selectionSet: child)
90+
if !primaryKeysOnly || graphQLType == .mutation {
91+
// Continue to add version fields for all levels, for backwards compatibility
92+
// Reduce the selection set only when the type is "subscription" and "query"
93+
// (specifically for syncQuery). Selection set for mutation should not be reduced
94+
// because it needs to be the full selection set to send mutation events to older
95+
// iOS clients, which do not have the reduced subscription selection set.
96+
selectionSet.children.forEach { child in
97+
addConflictResolution(selectionSet: child,
98+
primaryKeysOnly: primaryKeysOnly,
99+
includeSyncMetadataFields: .full)
100+
}
101+
} else {
102+
// Only add all the sync metadata fields once. Once this was done once, `includeSyncMetadataFields`
103+
// should be set to `.deletedFieldOnly` and passed down to the recursive call stack.
104+
selectionSet.children.forEach { child in
105+
addConflictResolution(selectionSet: child,
106+
primaryKeysOnly: primaryKeysOnly,
107+
includeSyncMetadataFields: includeSyncMetadataFields)
108+
}
71109
}
72110
}
73111
}

AmplifyPlugins/Core/AWSPluginsCore/Model/GraphQLDocument/GraphQLSubscription.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ public struct GraphQLSubscription: SingleDirectiveGraphQLDocument {
2121
self.selectionSet = selectionSet
2222
}
2323

24-
@available(*, deprecated, message: """
24+
@available(*, deprecated, message: """
2525
Init with modelType is deprecated, use init with modelSchema instead.
2626
""")
27-
public init(modelType: Model.Type) {
28-
self.init(modelSchema: modelType.schema)
27+
public init(modelType: Model.Type, primaryKeysOnly: Bool = false) {
28+
self.init(modelSchema: modelType.schema, primaryKeysOnly: primaryKeysOnly)
2929
}
3030

31-
public init(modelSchema: ModelSchema) {
32-
self.selectionSet = SelectionSet(fields: modelSchema.graphQLFields)
31+
public init(modelSchema: ModelSchema, primaryKeysOnly: Bool = false) {
32+
self.selectionSet = SelectionSet(fields: modelSchema.graphQLFields, primaryKeysOnly: primaryKeysOnly)
3333
}
3434

3535
public var operationType: GraphQLOperationType = .subscription

0 commit comments

Comments
 (0)