You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+96-1Lines changed: 96 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -47,7 +47,10 @@ This sample is a variation of the Full-Stack MVC Todo sample described here: [To
47
47
48
48
## Folder Structure
49
49
50
-
-`/api`: the NodeJs Azure Function code used to provide the backend API, called by the Vue.Js client
50
+
-`/api`: the NodeJs Azure Function code used to provide the backend API, called by the Vue.Js client.
51
+
-`/api/rest`: contains the Azure Function the provides REST endpoint support
52
+
-`/api/graphql`: contains the Azure Function the provides GraphQL endpoint support
53
+
-`/api/prisma`: contains the Prisma model
51
54
-`/client`: the Vue.Js client. Original source code has been taken from official Vue.js sample and adapted to call a REST or GraphQL client instead of using local storage to save and retrieve todos
52
55
53
56
## Install the dependencies
@@ -188,6 +191,98 @@ Take a look at the sample workflow in the `./github/workflow` folder to see how
188
191
189
192
After you have commited the changes to the workflow file, the CI/CD pipeline will run again automatically (You can verify it from the "Action" section of your GitHub repo). Once the pipeline has run, you should have a working website. Go to http://[your-swa-name].azurestaticapps.net, and enjoy!
190
193
194
+
### REST Endpoint
195
+
196
+
You can create, update and delete ToDos, that are then in turn stored in Azure SQL, completely via REST using the `/api/todo` endpoint. It support GET, POST, PATCH and DELETE methods. For example using cUrl:
197
+
198
+
To get all available todos
199
+
```
200
+
curl -s -X GET https://[your-swa-name].azurestaticapps.net/api/todo
201
+
```
202
+
203
+
To get a specific todo
204
+
```
205
+
curl -s -X GET https://[your-swa-name].azurestaticapps.net/api/todo/123
A sample of REST endpoint usage in a web page is available at `/client-rest.html` page.
224
+
225
+
### GraphQL Endpoint
226
+
227
+
The GraphQL endpoint is available at `https://[your-swa-name].azurestaticapps.net/api/todo/graphql` and it provides an interactive GraphQL playground. You can create, update and delete ToDos, that are then in turn stored in Azure SQL, completely via GraphQL.
228
+
229
+
To get all available todos
230
+
```
231
+
query {
232
+
todoList {
233
+
id, title, completed
234
+
}
235
+
}
236
+
```
237
+
238
+
To get a specific todo
239
+
```
240
+
query {
241
+
todo(id: 123) {
242
+
id, title, completed
243
+
}
244
+
}
245
+
```
246
+
247
+
Create a todo
248
+
```
249
+
mutation {
250
+
addTodo(title: "hello world")
251
+
{
252
+
id,
253
+
title,
254
+
completed
255
+
}
256
+
}
257
+
```
258
+
259
+
Update todo
260
+
```
261
+
mutation {
262
+
updateTodo(id: 123, title: "world, hello")
263
+
{
264
+
id,
265
+
title,
266
+
completed
267
+
}
268
+
}
269
+
```
270
+
271
+
Delete todo
272
+
```
273
+
mutation {
274
+
deleteTodo(id: 123)
275
+
{
276
+
id,
277
+
title,
278
+
completed
279
+
}
280
+
}
281
+
```
282
+
283
+
A sample of GraphQL endpoint usage in a web page is available at `/client-graphql.html` page.
284
+
285
+
191
286
## Azure Static Web App
192
287
193
288
Azure Static Web App supports a Free tier which is absolutely great so that you can try them for free, but of course don't expect great performances. Initial REST API response will be in the 500 msec area. Keep this in mind if you are planning to use them for something different than testing. If you need better performance right now and cannot when for when Azure Static Web App will be out of preview, you can always deploy the REST API using plain Azure Functions where you can have amazing scalability and performance.
0 commit comments