Skip to content

Commit 2fe7fdd

Browse files
committed
Use id in place of docId
1 parent 4eded96 commit 2fe7fdd

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

examples/server/main.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ func main() {
4848
"document": &graphql.Field{
4949
Type: documentType,
5050
Args: graphql.FieldConfigArgument{
51-
"docId": &graphql.ArgumentConfig{
51+
"id": &graphql.ArgumentConfig{
5252
Type: graphql.Int,
5353
},
5454
},
5555
Resolve: func(p graphql.ResolveParams) (interface{}, error) {
56-
docID := p.Args["docId"].(int)
57-
return documents[docID], nil
56+
id := p.Args["id"].(int)
57+
return documents[id], nil
5858
},
5959
},
6060
},
@@ -68,7 +68,7 @@ func main() {
6868
"updateDocument": &graphql.Field{
6969
Type: documentType,
7070
Args: graphql.FieldConfigArgument{
71-
"docId": &graphql.ArgumentConfig{
71+
"id": &graphql.ArgumentConfig{
7272
Type: graphql.Int,
7373
},
7474
"title": &graphql.ArgumentConfig{
@@ -80,17 +80,17 @@ func main() {
8080
},
8181
Resolve: func(p graphql.ResolveParams) (interface{}, error) {
8282

83-
docID := p.Args["docId"].(int)
84-
documents[docID].Title = p.Args["title"].(string)
85-
documents[docID].Title = p.Args["title"].(string)
83+
id := p.Args["id"].(int)
84+
documents[id].Title = p.Args["title"].(string)
85+
documents[id].Title = p.Args["title"].(string)
8686

8787
for _, subscriptions := range subscriptionManager.Subscriptions() {
8888
for _, subscription := range subscriptions {
8989

9090
// JSON interface is float64
91-
var subdocID int = int(subscription.Variables["docId"].(float64))
91+
var subID int = int(subscription.Variables["id"].(float64))
9292

93-
if docID == subdocID {
93+
if id == subID {
9494

9595
params := graphql.Params{
9696
Schema: schema,
@@ -110,7 +110,7 @@ func main() {
110110
}
111111
}
112112

113-
return documents[docID], nil
113+
return documents[id], nil
114114
},
115115
},
116116
},
@@ -124,13 +124,13 @@ func main() {
124124
"documentUpdates": &graphql.Field{
125125
Type: documentType,
126126
Args: graphql.FieldConfigArgument{
127-
"docId": &graphql.ArgumentConfig{
127+
"id": &graphql.ArgumentConfig{
128128
Type: graphql.Int,
129129
},
130130
},
131131
Resolve: func(p graphql.ResolveParams) (interface{}, error) {
132-
docID := p.Args["docId"].(int)
133-
return documents[docID], nil
132+
id := p.Args["id"].(int)
133+
return documents[id], nil
134134
},
135135
},
136136
},

0 commit comments

Comments
 (0)