1
1
go-graphql-client
2
2
=======
3
3
4
- [ ![ Build Status ] ( https://travis-ci.org /hasura/go-graphql-client.svg?branch=master )] ( https://travis-ci.org/hasura/go-graphql-client .svg?branch=master ) [ ![ GoDoc ] ( https://godoc.org/ github.com/hasura/go-graphql-client?status.svg )] ( https://pkg.go.dev/github.com/hasura/go-graphql-client )
4
+ [ ![ Unit tests ] ( https://github.com /hasura/go-graphql-client/actions/workflows/test.yml/badge .svg ) ]( https://github.com/hasura/go-graphql-client/actions/workflows/test.yml )
5
5
6
6
** Preface:** This is a fork of ` https://github.com/shurcooL/graphql ` with extended features (subscription client, named operation)
7
7
@@ -99,7 +99,7 @@ You can define this variable:
99
99
` ` ` Go
100
100
var query struct {
101
101
Me struct {
102
- Name graphql. String
102
+ Name string
103
103
}
104
104
}
105
105
` ` `
@@ -136,8 +136,8 @@ You can define this variable:
136
136
` ` ` Go
137
137
var q struct {
138
138
Human struct {
139
- Name graphql. String
140
- Height graphql. Float ` graphql:"height(unit: METER)"`
139
+ Name string
140
+ Height float64 ` graphql:"height(unit: METER)"`
141
141
} ` graphql:"human(id: \"1000\")"`
142
142
}
143
143
` ` `
@@ -162,8 +162,8 @@ However, that'll only work if the arguments are constant and known in advance. O
162
162
` ` ` Go
163
163
var q struct {
164
164
Human struct {
165
- Name graphql. String
166
- Height graphql. Float ` graphql:"height(unit: $unit)"`
165
+ Name string
166
+ Height float64 ` graphql:"height(unit: $unit)"`
167
167
} ` graphql:"human(id: $id)"`
168
168
}
169
169
` ` `
@@ -264,12 +264,12 @@ You can define this variable:
264
264
` ` ` Go
265
265
var q struct {
266
266
Hero struct {
267
- Name graphql. String
267
+ Name string
268
268
Droid struct {
269
- PrimaryFunction graphql. String
269
+ PrimaryFunction string
270
270
} ` graphql:"... on Droid"`
271
271
Human struct {
272
- Height graphql. Float
272
+ Height float64
273
273
} ` graphql:"... on Human"`
274
274
} ` graphql:"hero(episode: \"JEDI\")"`
275
275
}
@@ -280,16 +280,16 @@ Alternatively, you can define the struct types corresponding to inline fragments
280
280
` ` ` Go
281
281
type (
282
282
DroidFragment struct {
283
- PrimaryFunction graphql. String
283
+ PrimaryFunction string
284
284
}
285
285
HumanFragment struct {
286
- Height graphql. Float
286
+ Height float64
287
287
}
288
288
)
289
289
290
290
var q struct {
291
291
Hero struct {
292
- Name graphql. String
292
+ Name string
293
293
DroidFragment ` graphql:"... on Droid"`
294
294
HumanFragment ` graphql:"... on Human"`
295
295
} ` graphql:"hero(episode: \"JEDI\")"`
@@ -319,8 +319,8 @@ The GraphQL type is automatically inferred from Go type by reflection. However,
319
319
320
320
` ` ` go
321
321
type UserReviewInput struct {
322
- Review String
323
- UserID String
322
+ Review string
323
+ UserID string
324
324
}
325
325
326
326
// type alias
@@ -365,15 +365,15 @@ You can define:
365
365
` ` ` Go
366
366
var m struct {
367
367
CreateReview struct {
368
- Stars graphql. Int
369
- Commentary graphql. String
368
+ Stars int
369
+ Commentary string
370
370
} ` graphql:"createReview(episode: $ep, review: $review)"`
371
371
}
372
372
variables := map [string ]interface {}{
373
373
" ep" : starwars.Episode (" JEDI" ),
374
374
" review" : starwars.ReviewInput {
375
- Stars: graphql. Int ( 5 ) ,
376
- Commentary: graphql. String ( " This is a great movie!" ) ,
375
+ Stars: 5 ,
376
+ Commentary: " This is a great movie!" ,
377
377
},
378
378
}
379
379
` ` `
@@ -419,8 +419,8 @@ var m struct {
419
419
variables := map [string ]interface {}{
420
420
" ep" : starwars.Episode (" JEDI" ),
421
421
" review" : starwars.ReviewInput {
422
- Stars: graphql. Int ( 5 ) ,
423
- Commentary: graphql. String ( " This is a great movie!" ) ,
422
+ Stars: 5 ,
423
+ Commentary: " This is a great movie!" ,
424
424
},
425
425
}
426
426
` ` `
@@ -473,7 +473,7 @@ You can define this variable:
473
473
` ` ` Go
474
474
var subscription struct {
475
475
Me struct {
476
- Name graphql. String
476
+ Name string
477
477
}
478
478
}
479
479
` ` `
@@ -780,17 +780,17 @@ You can define:
780
780
781
781
` ` ` Go
782
782
type CreateUser struct {
783
- Login graphql. String
783
+ Login string
784
784
}
785
785
m := [][2 ]interface {}{
786
786
{" createUser(login: $login1)" , &CreateUser{}},
787
787
{" createUser(login: $login2)" , &CreateUser{}},
788
788
{" createUser(login: $login3)" , &CreateUser{}},
789
789
}
790
790
variables := map [string ]interface {}{
791
- " login1" : graphql. String ( " grihabor" ) ,
792
- " login2" : graphql. String ( " diman" ) ,
793
- " login3" : graphql. String ( " indigo" ) ,
791
+ " login1" : " grihabor" ,
792
+ " login2" : " diman" ,
793
+ " login3" : " indigo" ,
794
794
}
795
795
` ` `
796
796
0 commit comments