messing with formatting in README
This commit is contained in:
@@ -25,11 +25,8 @@ This is a proof-of-concept of a GraphQL client that does the same sort of thing:
|
|||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
TODO: make this actually complete enough to be usable!
|
|
||||||
TODO: clean up and link to godoc
|
|
||||||
|
|
||||||
To send a query
|
|
||||||
```graphql
|
```graphql
|
||||||
|
# queries.graphql
|
||||||
query getViewer {
|
query getViewer {
|
||||||
viewer {
|
viewer {
|
||||||
MyName: name
|
MyName: name
|
||||||
@@ -37,20 +34,21 @@ query getViewer {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
put it in a file `queries.graphql`, then run `genql` to create `generated.go` with a function `getViewer`. Then, in another file, call it like this:
|
|
||||||
|
|
||||||
```go
|
```go
|
||||||
|
// generated.go (auto-generated):
|
||||||
|
type getViewerResponse struct { ... }
|
||||||
|
func getViewer(ctx context.Context, client *graphql.Client) (*getViewerResponse, error) { ... }
|
||||||
|
|
||||||
|
// your code (error handling omitted for brevity)
|
||||||
graphqlClient := graphql.NewClient("https://example.com/graphql", http.DefaultClient)
|
graphqlClient := graphql.NewClient("https://example.com/graphql", http.DefaultClient)
|
||||||
viewerResp, err := getViewer(context.Background(), graphqlClient)
|
viewerResp, _ := getViewer(context.Background(), graphqlClient)
|
||||||
if err != nil {
|
|
||||||
fmt.Println("oh no: ", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
fmt.Println("you are", *viewerResp.Viewer.MyName)
|
fmt.Println("you are", *viewerResp.Viewer.MyName)
|
||||||
```
|
```
|
||||||
|
|
||||||
For a complete working example, see `example/`.
|
For a complete working example, see `example/`.
|
||||||
|
|
||||||
|
TODO: maybe make this example slightly more complete; clean up and link to godoc
|
||||||
|
|
||||||
## Major TODOs
|
## Major TODOs
|
||||||
|
|
||||||
Query structures to support:
|
Query structures to support:
|
||||||
|
|||||||
Reference in New Issue
Block a user