User Tools

Site Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
go:graphql [2020-05-24 21:31]
ziggi [Out]
go:graphql [2020-05-24 21:40] (current)
ziggi
Line 116: Line 116:
 </​code>​ </​code>​
  
-====Out====+===Out===
  
 <​file>​ <​file>​
Line 123: Line 123:
 </​file>​ </​file>​
  
 +
 +====Client2====
 +
 +
 +<code go client2.go>​
 +/*
 + * Copyright 2020 Oleg Borodin ​ <​borodin@unix7.org>​
 + */
 +
 +package main
 +
 +import (
 +    "​context"​
 +    "​fmt"​
 +
 +    "​github.com/​machinebox/​graphql"​
 +)
 +
 +func main() {
 +    graphqlClient := graphql.NewClient("​http://​localhost:​8080/​query"​)
 +    graphqlRequest := graphql.NewRequest(`
 +        {
 +            hello(id: 5) {
 +            }
 +        }
 +    `)
 +    var graphqlResponse interface{}
 +    if err := graphqlClient.Run(context.Background(),​ graphqlRequest,​ &​graphqlResponse);​ err != nil {
 +        panic(err)
 +    }
 +    fmt.Println(graphqlResponse)
 +}
 +</​code>​
 +
 +===Out===
 +<​file>​
 +$ ./client2
 +map[hello:​hello #id 5]
 +</​file>​
 ---- ----
 [<>] [<>]