Skip to content

Commit 1564f48

Browse files
committed
chore(readme): add link to official documentation
1 parent a8ee30d commit 1564f48

File tree

1 file changed

+85
-43
lines changed

1 file changed

+85
-43
lines changed

README.md

Lines changed: 85 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,75 @@ This project is an example of using Flutter with the AWS AppSync solution. It is
88

99
[![Demo](https://github.com/ineat/flutter-aws-appsync-sample/blob/master/media/demo.gif)](https://github.com/ineat/flutter-aws-appsync-sample/blob/master/media/demo.mp4)
1010

11-
### My AppSync Configuration
11+
AWS AppSync automatically updates web and mobile application data in real time, and offline user data is updated as soon as it is reconnected.
12+
If you use AppSync as a simple GraphQL API without the subscribe feature then it would be better to use the following plugin: :
13+
https://pub.dartlang.org/packages/graphql_flutter
14+
15+
16+
The bridge is based on the official documentation of the AppSync SDK.
17+
18+
AWS AppSync SDK Android :
19+
https://docs.aws.amazon.com/appsync/latest/devguide/building-a-client-app-android.html
20+
21+
AWS AppSync SDK iOS :
22+
https://docs.aws.amazon.com/appsync/latest/devguide/building-a-client-app-ios.html
23+
24+
If you want more information on the development of a flutter plugin here is an official link: https://flutter.io/developing-packages/
25+
26+
To make this example work, AppSync is configured with the following GraphQL schema :
27+
28+
29+
## GraphQL schema
30+
31+
The GraphQL schema:
32+
33+
```graphql
34+
type Message {
35+
id: ID!
36+
content: String!
37+
sender: String!
38+
conversationId: Int!
39+
}
40+
41+
type Mutation {
42+
newMessage(content: String!, sender: String!, conversationId: Int!): Message
43+
}
44+
45+
type Query {
46+
getMessages: [Message]
47+
}
48+
49+
type Subscription {
50+
subscribeToNewMessage(conversationId: Int!): Message
51+
@aws_subscribe(mutations: ["newMessage"])
52+
}
53+
54+
schema {
55+
query: Query
56+
mutation: Mutation
57+
}
58+
```
59+
60+
Pour créer votre schéma GraphQL pour AppSync, consulter le lien https://docs.aws.amazon.com/appsync/latest/devguide/graphql-overview.html
61+
62+
## Security
63+
64+
AppSync will be secured by API Key.
65+
66+
https://docs.aws.amazon.com/appsync/latest/devguide/security.html
67+
68+
## Data Source
69+
70+
The Data Source used by AppSync is a lambda. Here is this example here is a simplified version :
1271

13-
**Lambda called by AppSync :**
1472
```javascript
1573

1674
var incrementId = 0;
1775
var messages = [];
1876

1977
exports.handler = async (event, context, callback) => {
2078
switch (event.field) {
79+
// match with Data Template resolver
2180
case 'getMessages':
2281
getMessages(event, context, callback);
2382
break;
@@ -46,40 +105,12 @@ async function newMessage(event, context, callback) {
46105
}
47106
```
48107

49-
**Schema GraphQL in App Sync :**
50-
51-
```graphql
52-
type Message {
53-
id: ID!
54-
content: String!
55-
sender: String!
56-
conversationId: Int!
57-
}
58-
59-
type Mutation {
60-
newMessage(content: String!, sender: String!, conversationId: Int!): Message
61-
}
108+
To link the GraphQL schema methods to the lambda refer to the following link : https://docs.aws.amazon.com/appsync/latest/devguide/tutorial-lambda-resolvers.html
62109

63-
type Query {
64-
getMessages: [Message]
65-
}
66-
67-
type Subscription {
68-
subscribeToNewMessage(conversationId: Int!): Message
69-
@aws_subscribe(mutations: ["newMessage"])
70-
}
71-
72-
schema {
73-
query: Query
74-
mutation: Mutation
75-
}
76-
```
77-
78-
Settings Authorization type is : **API key**
79-
80-
Add **resolver** into query, mutation. The data source name is linked with the previously lambda.
110+
## Resolvers
81111

82112
Request template resolver for NewMessage Mutation :
113+
83114
```javascript
84115
{
85116
"version" : "2017-02-28",
@@ -92,6 +123,7 @@ Request template resolver for NewMessage Mutation :
92123
```
93124

94125
Request template resolver for GetMessages Query :
126+
95127
```javascript
96128
{
97129
"version" : "2017-02-28",
@@ -103,13 +135,20 @@ Request template resolver for GetMessages Query :
103135
}
104136
```
105137

106-
Add AppSync API URL, and API Key in the file /lib/constants.dart
138+
## Configuration sample
139+
140+
To configure AppSync in the project, modify the constants of the file /lib/constants.dart
141+
142+
```dart
143+
const AWS_APP_SYNC_ENDPOINT = "YOUR ENDPOINT"; // like https://xxx.appsync-api.eu-central-1.amazonaws.com/graphql
144+
const AWS_APP_SYNC_KEY = "YOUR API KEY";
145+
```
107146

108147
# Custom Configuration in your project
109148

110149
## 1. Android
111150

112-
Step 1: add aws android SDK classpath
151+
**_Step 1:_** add aws android SDK classpath
113152

114153

115154
```groovy
@@ -124,7 +163,7 @@ buildscript {
124163
125164
```
126165

127-
Step 2: Plugin plugin and SDK
166+
_**Step 2:**_ Plugin plugin and SDK
128167

129168
```groovy
130169
// android/app/build.gradle
@@ -139,15 +178,16 @@ dependencies {
139178
}
140179
```
141180

142-
Step 3: add schema and request GraphQL
181+
_**Step 3:**_ add schema and request GraphQL
143182

144183
Copy your files in :
145184

146185
/android/app/src/main/graphql/your.package.name/*.graphql
147186
/android/app/src/main/graphql/your.package.name/*.json
148187

149188

150-
Step 4: Configure Android Manifest
189+
_**Step 4:**_ Configure Android Manifest
190+
151191
```xml
152192

153193
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
@@ -166,7 +206,8 @@ Step 4: Configure Android Manifest
166206

167207
</manifest>
168208
```
169-
Step 5: Generation GraphQL models
209+
210+
_**Step 5:**_ Generation GraphQL models
170211

171212
Launch gradle command :
172213

@@ -177,7 +218,7 @@ Launch gradle command :
177218

178219
## 2. iOS
179220

180-
Step 1: add AWS SDK in your Podfile
221+
_**Step 1:**_ add AWS SDK in your Podfile
181222

182223
```ruby
183224
target 'Runner' do
@@ -186,14 +227,15 @@ target 'Runner' do
186227
end
187228
```
188229

189-
Step 2: Retrieve all dependencies
230+
_**Step 2:**_ Retrieve all dependencies
231+
190232
```ruby
191233
pod install
192234
```
193235

194-
Caution: Configure your deployment target at 9.0 (Runner.xcworkspace)
236+
_Caution:_ Configure your deployment target at 9.0 (Runner.xcworkspace)
195237

196-
Step 3: add schema and request GraphQL
238+
_**Step 3:**_ add schema and request GraphQL
197239

198240
Copy your files in :
199241

0 commit comments

Comments
 (0)