add basic query struct, support 1.12

This commit is contained in:
Ben Kraft
2019-12-23 19:35:38 -05:00
parent a23b0e3756
commit efa9ccd122
5 changed files with 65 additions and 10 deletions
+3 -2
View File
@@ -16,8 +16,8 @@ type GetViewerResponse = struct {
// GetViewer gets the current user's name.
func GetViewer(ctx context.Context) (*GetViewerResponse, error) {
req, err := http.NewRequestWithContext(
ctx, http.MethodPost,
req, err := http.NewRequest(
http.MethodPost,
`https://api.github.com/graphql`,
strings.NewReader(`
"GetViewer gets the current user's name."
@@ -31,6 +31,7 @@ query GetViewer {
return nil, err
}
req = req.WithContext(ctx)
resp, err := http.DefaultClient.Do(req)
if err != nil {
return nil, err
+2 -2
View File
@@ -1,6 +1,6 @@
"GetViewer gets the current user's name."
query GetUser($login: String!) {
User: user(login: $login) {
query GetViewer {
Viewer: viewer {
Name: name
}
}