Skip to content

Commit 0d164bc

Browse files
authored
Remove unused contentMap field from persistent queue. Fixes #33. (#169)
1 parent 7ad94fa commit 0d164bc

File tree

5 files changed

+180
-44
lines changed

5 files changed

+180
-44
lines changed

AWSAppSyncClient/AWSSQLLiteNormalizedCache.swift

-4
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ public final class AWSMutationCache {
3535
private let id = Expression<Int64>("_id")
3636
private let recordIdentifier = Expression<CacheKey>("recordIdentifier")
3737
private let data = Expression<Data>("data")
38-
private let contentMap = Expression<String>("contentMap")
3938
private let recordState = Expression<String>("recordState")
4039
private let timestamp = Expression<Date>("timestamp")
4140
private let s3Bucket = Expression<String?>("s3Bucket")
@@ -56,7 +55,6 @@ public final class AWSMutationCache {
5655
table.column(id, primaryKey: .autoincrement)
5756
table.column(recordIdentifier, unique: true)
5857
table.column(data)
59-
table.column(contentMap)
6058
table.column(recordState)
6159
table.column(timestamp)
6260
table.column(s3Bucket)
@@ -75,7 +73,6 @@ public final class AWSMutationCache {
7573
let insert = mutationRecords.insert(
7674
recordIdentifier <- record.recordIdentitifer,
7775
data <- record.data!,
78-
contentMap <- record.contentMap!.description,
7976
recordState <- record.recordState.rawValue,
8077
timestamp <- record.timestamp,
8178
s3Bucket <- s3Object.bucket,
@@ -89,7 +86,6 @@ public final class AWSMutationCache {
8986
let insert = mutationRecords.insert(
9087
recordIdentifier <- record.recordIdentitifer,
9188
data <- record.data!,
92-
contentMap <- record.contentMap!.description,
9389
recordState <- record.recordState.rawValue,
9490
timestamp <- record.timestamp,
9591
operationString <- record.operationString!)

AWSAppSyncIntegrationTests/ConsoleResources/appsync-integrationtests-cloudformation.yaml

+36
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ Resources:
128128
129129
deletePostUsingParameters(id: ID!): Post
130130
131+
testMutationWithoutParameters: Boolean
131132
}
132133
133134
type Post {
@@ -363,6 +364,16 @@ Resources:
363364
Ref: AWS::Region
364365
UseCallerCredentials: FALSE
365366

367+
NoneDatasource:
368+
Type: AWS::AppSync::DataSource
369+
Properties:
370+
Type: NONE
371+
Name: none
372+
ApiId:
373+
Fn::GetAtt:
374+
- GraphQLApi
375+
- ApiId
376+
ServiceRoleArn: !GetAtt DynamoDBRole.Arn
366377

367378
#########################################################
368379
# AWS AppSync Resolvers
@@ -434,6 +445,31 @@ Resources:
434445
#end
435446
$util.toJson($ctx.result.items)
436447
448+
TestMutationWithoutParametersResolver:
449+
Type: AWS::AppSync::Resolver
450+
Properties:
451+
ApiId: !GetAtt GraphQLApi.ApiId
452+
TypeName: "Mutation"
453+
FieldName: "testMutationWithoutParameters"
454+
DataSourceName: !GetAtt NoneDatasource.Name
455+
RequestMappingTemplate: |
456+
#**
457+
Resolvers with None data sources can locally publish events
458+
that fire subscriptions without hitting a backend data source.
459+
The value of 'payload' after the template has been evaluated
460+
will be directly forwarded to the response.
461+
*#
462+
{
463+
"version": "2017-02-28",
464+
"payload": {
465+
"body": "${context.arguments.body}",
466+
"from": "${context.identity.username}",
467+
"to": "${context.arguments.to}",
468+
"sentAt": "$util.time.nowISO8601()"
469+
}
470+
}
471+
ResponseMappingTemplate: "$util.toJson(true)"
472+
437473
ListPostsDeltaResolver:
438474
Type: "AWS::AppSync::Resolver"
439475
Properties:

AWSAppSyncTestCommon/AppSyncTestAPI.swift

+75-40
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import AWSAppSync
55
public struct CreatePostWithFileInput: GraphQLMapConvertible {
66
public var graphQLMap: GraphQLMap
77

8-
public init(author: String, title: String, content: String, url: Optional<String?> = nil, ups: Optional<Int?> = nil, downs: Optional<Int?> = nil, file: S3ObjectInput) {
8+
public init(author: String, title: String, content: String, url: String? = nil, ups: Int? = nil, downs: Int? = nil, file: S3ObjectInput) {
99
graphQLMap = ["author": author, "title": title, "content": content, "url": url, "ups": ups, "downs": downs, "file": file]
1010
}
1111

@@ -36,27 +36,27 @@ public struct CreatePostWithFileInput: GraphQLMapConvertible {
3636
}
3737
}
3838

39-
public var url: Optional<String?> {
39+
public var url: String? {
4040
get {
41-
return graphQLMap["url"] as! Optional<String?>
41+
return graphQLMap["url"] as! String?
4242
}
4343
set {
4444
graphQLMap.updateValue(newValue, forKey: "url")
4545
}
4646
}
4747

48-
public var ups: Optional<Int?> {
48+
public var ups: Int? {
4949
get {
50-
return graphQLMap["ups"] as! Optional<Int?>
50+
return graphQLMap["ups"] as! Int?
5151
}
5252
set {
5353
graphQLMap.updateValue(newValue, forKey: "ups")
5454
}
5555
}
5656

57-
public var downs: Optional<Int?> {
57+
public var downs: Int? {
5858
get {
59-
return graphQLMap["downs"] as! Optional<Int?>
59+
return graphQLMap["downs"] as! Int?
6060
}
6161
set {
6262
graphQLMap.updateValue(newValue, forKey: "downs")
@@ -158,7 +158,7 @@ public enum DeltaAction: RawRepresentable, Equatable, JSONDecodable, JSONEncodab
158158
public struct CreatePostWithoutFileInput: GraphQLMapConvertible {
159159
public var graphQLMap: GraphQLMap
160160

161-
public init(author: String, title: String, content: String, url: Optional<String?> = nil, ups: Optional<Int?> = nil, downs: Optional<Int?> = nil) {
161+
public init(author: String, title: String, content: String, url: String? = nil, ups: Int? = nil, downs: Int? = nil) {
162162
graphQLMap = ["author": author, "title": title, "content": content, "url": url, "ups": ups, "downs": downs]
163163
}
164164

@@ -189,27 +189,27 @@ public struct CreatePostWithoutFileInput: GraphQLMapConvertible {
189189
}
190190
}
191191

192-
public var url: Optional<String?> {
192+
public var url: String? {
193193
get {
194-
return graphQLMap["url"] as! Optional<String?>
194+
return graphQLMap["url"] as! String?
195195
}
196196
set {
197197
graphQLMap.updateValue(newValue, forKey: "url")
198198
}
199199
}
200200

201-
public var ups: Optional<Int?> {
201+
public var ups: Int? {
202202
get {
203-
return graphQLMap["ups"] as! Optional<Int?>
203+
return graphQLMap["ups"] as! Int?
204204
}
205205
set {
206206
graphQLMap.updateValue(newValue, forKey: "ups")
207207
}
208208
}
209209

210-
public var downs: Optional<Int?> {
210+
public var downs: Int? {
211211
get {
212-
return graphQLMap["downs"] as! Optional<Int?>
212+
return graphQLMap["downs"] as! Int?
213213
}
214214
set {
215215
graphQLMap.updateValue(newValue, forKey: "downs")
@@ -220,7 +220,7 @@ public struct CreatePostWithoutFileInput: GraphQLMapConvertible {
220220
public struct UpdatePostWithFileInput: GraphQLMapConvertible {
221221
public var graphQLMap: GraphQLMap
222222

223-
public init(id: GraphQLID, author: Optional<String?> = nil, title: Optional<String?> = nil, content: Optional<String?> = nil, url: Optional<String?> = nil, ups: Optional<Int?> = nil, downs: Optional<Int?> = nil, file: S3ObjectInput) {
223+
public init(id: GraphQLID, author: String? = nil, title: String? = nil, content: String? = nil, url: String? = nil, ups: Int? = nil, downs: Int? = nil, file: S3ObjectInput) {
224224
graphQLMap = ["id": id, "author": author, "title": title, "content": content, "url": url, "ups": ups, "downs": downs, "file": file]
225225
}
226226

@@ -233,54 +233,54 @@ public struct UpdatePostWithFileInput: GraphQLMapConvertible {
233233
}
234234
}
235235

236-
public var author: Optional<String?> {
236+
public var author: String? {
237237
get {
238-
return graphQLMap["author"] as! Optional<String?>
238+
return graphQLMap["author"] as! String?
239239
}
240240
set {
241241
graphQLMap.updateValue(newValue, forKey: "author")
242242
}
243243
}
244244

245-
public var title: Optional<String?> {
245+
public var title: String? {
246246
get {
247-
return graphQLMap["title"] as! Optional<String?>
247+
return graphQLMap["title"] as! String?
248248
}
249249
set {
250250
graphQLMap.updateValue(newValue, forKey: "title")
251251
}
252252
}
253253

254-
public var content: Optional<String?> {
254+
public var content: String? {
255255
get {
256-
return graphQLMap["content"] as! Optional<String?>
256+
return graphQLMap["content"] as! String?
257257
}
258258
set {
259259
graphQLMap.updateValue(newValue, forKey: "content")
260260
}
261261
}
262262

263-
public var url: Optional<String?> {
263+
public var url: String? {
264264
get {
265-
return graphQLMap["url"] as! Optional<String?>
265+
return graphQLMap["url"] as! String?
266266
}
267267
set {
268268
graphQLMap.updateValue(newValue, forKey: "url")
269269
}
270270
}
271271

272-
public var ups: Optional<Int?> {
272+
public var ups: Int? {
273273
get {
274-
return graphQLMap["ups"] as! Optional<Int?>
274+
return graphQLMap["ups"] as! Int?
275275
}
276276
set {
277277
graphQLMap.updateValue(newValue, forKey: "ups")
278278
}
279279
}
280280

281-
public var downs: Optional<Int?> {
281+
public var downs: Int? {
282282
get {
283-
return graphQLMap["downs"] as! Optional<Int?>
283+
return graphQLMap["downs"] as! Int?
284284
}
285285
set {
286286
graphQLMap.updateValue(newValue, forKey: "downs")
@@ -300,7 +300,7 @@ public struct UpdatePostWithFileInput: GraphQLMapConvertible {
300300
public struct UpdatePostWithoutFileInput: GraphQLMapConvertible {
301301
public var graphQLMap: GraphQLMap
302302

303-
public init(id: GraphQLID, author: Optional<String?> = nil, title: Optional<String?> = nil, content: Optional<String?> = nil, url: Optional<String?> = nil, ups: Optional<Int?> = nil, downs: Optional<Int?> = nil) {
303+
public init(id: GraphQLID, author: String? = nil, title: String? = nil, content: String? = nil, url: String? = nil, ups: Int? = nil, downs: Int? = nil) {
304304
graphQLMap = ["id": id, "author": author, "title": title, "content": content, "url": url, "ups": ups, "downs": downs]
305305
}
306306

@@ -313,54 +313,54 @@ public struct UpdatePostWithoutFileInput: GraphQLMapConvertible {
313313
}
314314
}
315315

316-
public var author: Optional<String?> {
316+
public var author: String? {
317317
get {
318-
return graphQLMap["author"] as! Optional<String?>
318+
return graphQLMap["author"] as! String?
319319
}
320320
set {
321321
graphQLMap.updateValue(newValue, forKey: "author")
322322
}
323323
}
324324

325-
public var title: Optional<String?> {
325+
public var title: String? {
326326
get {
327-
return graphQLMap["title"] as! Optional<String?>
327+
return graphQLMap["title"] as! String?
328328
}
329329
set {
330330
graphQLMap.updateValue(newValue, forKey: "title")
331331
}
332332
}
333333

334-
public var content: Optional<String?> {
334+
public var content: String? {
335335
get {
336-
return graphQLMap["content"] as! Optional<String?>
336+
return graphQLMap["content"] as! String?
337337
}
338338
set {
339339
graphQLMap.updateValue(newValue, forKey: "content")
340340
}
341341
}
342342

343-
public var url: Optional<String?> {
343+
public var url: String? {
344344
get {
345-
return graphQLMap["url"] as! Optional<String?>
345+
return graphQLMap["url"] as! String?
346346
}
347347
set {
348348
graphQLMap.updateValue(newValue, forKey: "url")
349349
}
350350
}
351351

352-
public var ups: Optional<Int?> {
352+
public var ups: Int? {
353353
get {
354-
return graphQLMap["ups"] as! Optional<Int?>
354+
return graphQLMap["ups"] as! Int?
355355
}
356356
set {
357357
graphQLMap.updateValue(newValue, forKey: "ups")
358358
}
359359
}
360360

361-
public var downs: Optional<Int?> {
361+
public var downs: Int? {
362362
get {
363-
return graphQLMap["downs"] as! Optional<Int?>
363+
return graphQLMap["downs"] as! Int?
364364
}
365365
set {
366366
graphQLMap.updateValue(newValue, forKey: "downs")
@@ -3145,6 +3145,41 @@ public final class DeletePostUsingParametersMutation: GraphQLMutation {
31453145
}
31463146
}
31473147

3148+
public final class TestMutationWithoutParametersMutation: GraphQLMutation {
3149+
public static let operationString =
3150+
"mutation TestMutationWithoutParameters {\n testMutationWithoutParameters\n}"
3151+
3152+
public init() {
3153+
}
3154+
3155+
public struct Data: GraphQLSelectionSet {
3156+
public static let possibleTypes = ["Mutation"]
3157+
3158+
public static let selections: [GraphQLSelection] = [
3159+
GraphQLField("testMutationWithoutParameters", type: .scalar(Bool.self)),
3160+
]
3161+
3162+
public var snapshot: Snapshot
3163+
3164+
public init(snapshot: Snapshot) {
3165+
self.snapshot = snapshot
3166+
}
3167+
3168+
public init(testMutationWithoutParameters: Bool? = nil) {
3169+
self.init(snapshot: ["__typename": "Mutation", "testMutationWithoutParameters": testMutationWithoutParameters])
3170+
}
3171+
3172+
public var testMutationWithoutParameters: Bool? {
3173+
get {
3174+
return snapshot["testMutationWithoutParameters"] as? Bool
3175+
}
3176+
set {
3177+
snapshot.updateValue(newValue, forKey: "testMutationWithoutParameters")
3178+
}
3179+
}
3180+
}
3181+
}
3182+
31483183
public final class GetPostQuery: GraphQLQuery {
31493184
public static let operationString =
31503185
"query GetPost($id: ID!) {\n getPost(id: $id) {\n __typename\n id\n author\n title\n content\n url\n ups\n downs\n file {\n __typename\n bucket\n key\n region\n }\n createdDate\n aws_ds\n }\n}"

0 commit comments

Comments
 (0)