Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ddliu/go-gqlclient
A simple Graphql client for Golang
https://github.com/ddliu/go-gqlclient
apollo client graphql mutation query
Last synced: 15 days ago
JSON representation
A simple Graphql client for Golang
- Host: GitHub
- URL: https://github.com/ddliu/go-gqlclient
- Owner: ddliu
- License: mit
- Created: 2020-07-10T02:12:43.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-07-10T05:47:50.000Z (over 4 years ago)
- Last Synced: 2024-11-09T03:47:35.153Z (2 months ago)
- Topics: apollo, client, graphql, mutation, query
- Language: Go
- Homepage:
- Size: 3.91 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-gqlclient
A simple Graphql client for Golang.
## Install
```
go get -u github.com/ddliu/go-gqlclient
```## Usage
```go
import (
"github.com/ddliu/go-gqlclient"
"net/http"
"context"
)client = gqlclient.New(gqlclient.Options{
Endpoint: "http://server/graphql",
Header: http.Header{
"some-secret": []string{"secret string"},
},
})data, err := client.Query(context.Background(), `
query MyQuery {
post {
id
name
}
}
`, nil)print(data.String("post.0.name"))
// Unmarshal data
var posts []Post
data.Unmarshal(&posts)
```With variables:
```go
client.Query(context.Background(), `
query MyQuery($limit: Int) {
post(limit: $limit) {
id
name
}
}
`, map[string]interface{} {
"limit": 10,
})
```Check out [fractal](https://github.com/ddliu/fractal) for more information of the query result.