Created
May 8, 2018 12:04
-
-
Save obcode/a8d1a5632d3e69df24e02c4afacf39e1 to your computer and use it in GitHub Desktop.
GraphQL Query Golang
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"net/http" | |
"bytes" | |
"io/ioutil" | |
) | |
func main() { | |
url := "https://api.github.com/graphql" | |
fmt.Println("URL:>", url) | |
jsonStr, _ := ioutil.ReadFile("query.json") | |
req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonStr)) | |
req.Header.Set("Authorization", "token hier_das_token_einfügen") | |
req.Header.Set("Content-Type", "application/json") | |
client := &http.Client{} | |
resp, err := client.Do(req) | |
if err != nil { | |
panic(err) | |
} | |
defer resp.Body.Close() | |
fmt.Println("response Status:", resp.Status) | |
fmt.Println("response Headers:", resp.Header) | |
body, _ := ioutil.ReadAll(resp.Body) | |
fmt.Println("response Body:", string(body)) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"query": "{organization(login:\"ob-vss-ss18\") {repositories(first: 100) {edges {node {name}}}}}"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment