# README
Golang GraphQL Client
Fully compatible with https://github.com/shurcooL/graphql v0.0.0-20181231061246-d48a9a75455f
You can simply replace github.com/shurcooL/graphql
--> github.com/joshuarose/graphql
to access new features.
New Features
Cache friendly
use HTTP GET when request graphql query, use HTTP POST when request graphql mutation.
Set Headers & Cookies
cli := NewClient(
"url",
httpClient,
graphql.WithCookie("cookieName", "cookieVal"),
graphql.WithHeader("headerName", "headerVal"),
)
Usage
package test
import (
"context"
"net/http"
"testing"
"github.com/joshuarose/graphql"
)
type gcpLockQuery struct {
Lock struct {
Name graphql.String `graphql:"name"`
ExpiresAt graphql.String `graphql:"expires_at"`
} `graphql:"Lock(name: $name)"`
}
func TestQueryWithHTTPGet(t *testing.T) {
ctx := context.Background()
httpClient := http.DefaultClient
query := new(gcpLockQuery)
vars := map[string]interface{}{
"name": graphql.String("joshuarose.123"),
}
gracli := graphql.NewClient(
"https://blog.joshuarose.com/graphql/query/",
httpClient,
)
if err := gracli.Query(ctx, query, vars); err != nil {
t.Fatalf("%+v", err)
}
}
# Functions
NewAWSDateTime is a helper to make a new *AWSDateTime.
NewBoolean is a helper to make a new *Boolean.
NewClient creates a GraphQL client targeting the specified GraphQL server URL.
NewClient creates a GraphQL client targeting the specified GraphQL server URL.
NewDeviceType is a helper to make a new *DeviceType.
NewFloat is a helper to make a new *Float.
NewID is a helper to make a new *ID.
NewInt is a helper to make a new *Int.
NewString is a helper to make a new *String.
WithCookie set graphql client cookie.
WithHeader set graphql client header.
# Interfaces
No description provided by the author
No description provided by the author
No description provided by the author
# Type aliases
No description provided by the author
ClientOptFunc graphql client option.
No description provided by the author
No description provided by the author
No description provided by the author