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
Implementation create, read, update and delete on Go
3
+
Implement create, read, update and delete on Go.
4
4
5
-
To run the program, go to the directory
6
-
`cd examples/crud`
5
+
To run the program:
7
6
8
-
Run the example
9
-
`go run main.go`
7
+
1. go to the directory: `cd examples/crud`
8
+
2. Run the example: `go run main.go`
10
9
11
10
## Create
11
+
12
12
`http://localhost:8080/product?query=mutation+_{create(name:"Inca Kola",info:"Inca Kola is a soft drink that was created in Peru in 1935 by British immigrant Joseph Robinson Lindley using lemon verbena (wiki)",price:1.99){id,name,info,price}}`
Copy file name to clipboardExpand all lines: examples/crud/main.go
+21-11Lines changed: 21 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -10,14 +10,34 @@ import (
10
10
"github.com/graphql-go/graphql"
11
11
)
12
12
13
+
// Product contains information about one product
13
14
typeProductstruct {
14
15
IDint64`json:"id"`
15
16
Namestring`json:"name"`
16
17
Infostring`json:"info,omitempty"`
17
18
Pricefloat64`json:"price"`
18
19
}
19
20
20
-
varproducts []Product
21
+
varproducts= []Product{
22
+
{
23
+
ID: 1,
24
+
Name: "Chicha Morada",
25
+
Info: "Chicha morada is a beverage originated in the Andean regions of Perú but is actually consumed at a national level (wiki)",
26
+
Price: 7.99,
27
+
},
28
+
{
29
+
ID: 2,
30
+
Name: "Chicha de jora",
31
+
Info: "Chicha de jora is a corn beer chicha prepared by germinating maize, extracting the malt sugars, boiling the wort, and fermenting it in large vessels (traditionally huge earthenware vats) for several days (wiki)",
32
+
Price: 5.95,
33
+
},
34
+
{
35
+
ID: 3,
36
+
Name: "Pisco",
37
+
Info: "Pisco is a colorless or yellowish-to-amber colored brandy produced in winemaking regions of Peru and Chile (wiki)",
product1:=Product{ID: 1, Name: "Chicha Morada", Info: "Chicha morada is a beverage originated in the Andean regions of Perú but is actually consumed at a national level (wiki)", Price: 7.99}
209
-
product2:=Product{ID: 2, Name: "Chicha de jora", Info: "Chicha de jora is a corn beer chicha prepared by germinating maize, extracting the malt sugars, boiling the wort, and fermenting it in large vessels (traditionally huge earthenware vats) for several days (wiki)", Price: 5.95}
210
-
product3:=Product{ID: 3, Name: "Pisco", Info: "Pisco is a colorless or yellowish-to-amber colored brandy produced in winemaking regions of Peru and Chile (wiki)", Price: 9.95}
0 commit comments