Skip to content

Commit cb2dafd

Browse files
committed
refactor(global): add comment for describe methods
1 parent 1564f48 commit cb2dafd

File tree

4 files changed

+44
-1
lines changed

4 files changed

+44
-1
lines changed

ios/Runner/AppSyncPlugin.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ import Flutter
1111
import AWSCore
1212
import AWSAppSync
1313

14+
/*
15+
* Plugin to call GraphQL requests generated from the schema
16+
*/
1417
public class AppSyncPlugin: NSObject, FlutterPlugin {
1518

1619
static let CHANNEL_NAME = "com.ineat.appsync"
@@ -19,6 +22,7 @@ public class AppSyncPlugin: NSObject, FlutterPlugin {
1922
static let SUBSCRIBE_NEW_MESSAGE = "subscribeNewMessage"
2023
static let SUBSCRIBE_NEW_MESSAGE_RESULT = "subscribeNewMessageResult"
2124

25+
// Client AWS AppSync for call GraphQL requests
2226
var appSyncClient: AWSAppSyncClient?
2327

2428
let channel: FlutterMethodChannel
@@ -35,6 +39,13 @@ public class AppSyncPlugin: NSObject, FlutterPlugin {
3539

3640
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
3741
prepareClient(call: call)
42+
onPerformMethodCall(call: call, result: result)
43+
}
44+
45+
/**
46+
* Handle type method. Call task for run GraphQL request
47+
*/
48+
private func onPerformMethodCall(call: FlutterMethodCall, result: @escaping FlutterResult) {
3849
switch call.method {
3950
case AppSyncPlugin.QUERY_GET_ALL_MESSAGES:
4051
GetAllMessages(client: appSyncClient!).exec(flutterMethodCall: call, flutterResult: result)
@@ -47,6 +58,9 @@ public class AppSyncPlugin: NSObject, FlutterPlugin {
4758
}
4859
}
4960

61+
/**
62+
* Create AWS AppSync Client if not exist
63+
*/
5064
private func prepareClient(call: FlutterMethodCall) {
5165
let args = call.arguments as! Dictionary<String, Any>
5266
let endpoint = args["endpoint"] as! String

ios/Runner/tasks/GetAllMessages.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ import Foundation
1010
import AWSCore
1111
import AWSAppSync
1212

13+
/*
14+
* Task for execute the query GetAllMessages in GraphQL file
15+
* query GetMessages {
16+
* getMessages {
17+
* id
18+
* content
19+
* sender
20+
* }
21+
* }
22+
*/
1323
class GetAllMessages {
1424

1525
private let client: AWSAppSyncClient
@@ -19,7 +29,6 @@ class GetAllMessages {
1929
}
2030

2131
public func exec(flutterMethodCall: FlutterMethodCall, flutterResult: @escaping FlutterResult) {
22-
let args = flutterMethodCall.arguments as! Dictionary<String,Any?>
2332
let query = GetMessagesQuery()
2433
self.client.fetch(query: query, cachePolicy: .fetchIgnoringCacheData) { (result, error) in
2534
if let error = error as? AWSAppSyncClientError {

ios/Runner/tasks/NewMessage.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ import Foundation
1010
import AWSCore
1111
import AWSAppSync
1212

13+
/*
14+
* Task for execute the mutation NewMessage in GraphQL file
15+
* mutation NewMessage($content: String!, $sender: String!) {
16+
* newMessage(content: $content, sender: $sender) {
17+
* id
18+
* content
19+
* sender
20+
* }
21+
* }
22+
*/
1323
class NewMessage {
1424

1525
private let client: AWSAppSyncClient

ios/Runner/tasks/SubscriptionToNewMessage.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ import Foundation
1010
import AWSCore
1111
import AWSAppSync
1212

13+
/*
14+
* Task for execute the subscription SubscribeToNewMessage in GraphQL file
15+
* subscription SubscribeToNewMessage {
16+
* subscribeToNewMessage {
17+
* id
18+
* content
19+
* sender
20+
* }
21+
* }
22+
*/
1323
class SubscriptionToNewMessage {
1424

1525
private let client: AWSAppSyncClient

0 commit comments

Comments
 (0)