generates something mostly plausiblegit add .
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
Generate the schemas by getting a token from [GitHub](https://github.com/settings/tokens/new) (no scopes needed), then:
|
||||
```
|
||||
npm install -g graphql-introspection-json-to-sdl
|
||||
curl -H "Authorization: bearer <your token>" https://api.github.com/graphql >example/schema.json
|
||||
graphql-introspection-json-to-sdl example/schema.json >example/schema.graphql
|
||||
```
|
||||
TODO: something better
|
||||
+13
-4
@@ -6,12 +6,14 @@ import (
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/vektah/gqlparser/gqlerror"
|
||||
)
|
||||
|
||||
type GetViewerResponse = struct {
|
||||
Viewer struct {
|
||||
Name string `json:"name"`
|
||||
} `json:"viewer"`
|
||||
Name *string
|
||||
}
|
||||
}
|
||||
|
||||
// GetViewer gets the current user's name.
|
||||
@@ -42,11 +44,18 @@ query GetViewer {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
retval := GetViewerResponse{}
|
||||
var retval struct {
|
||||
Data GetViewerResponse `json:"data"`
|
||||
Errors gqlerror.List `json:"errors"`
|
||||
}
|
||||
err = json.Unmarshal(body, &retval)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &retval, nil
|
||||
if len(retval.Errors) > 0 {
|
||||
return nil, retval.Errors
|
||||
}
|
||||
|
||||
return &retval.Data, nil
|
||||
}
|
||||
|
||||
+23338
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user