Files
atlantis/vendor/github.com/Laisky/graphql
dependabot[bot] 664f83f6bb Bump github.com/Laisky/graphql from 1.0.4 to 1.0.5 (#1368)
Bumps [github.com/Laisky/graphql](https://github.com/Laisky/graphql) from 1.0.4 to 1.0.5.
- [Release notes](https://github.com/Laisky/graphql/releases)
- [Commits](https://github.com/Laisky/graphql/compare/v1.0.4...v1.0.5)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-01-28 09:02:06 -08:00
..
2020-01-24 21:51:01 -08:00
2020-01-24 21:51:01 -08:00
2020-01-24 21:51:01 -08:00
2020-01-24 21:51:01 -08:00
2020-01-24 21:51:01 -08:00
2020-01-24 21:51:01 -08:00
2020-01-24 21:51:01 -08:00
2020-01-24 21:51:01 -08:00

Golang GraphQL Client

GitHub release License: MIT Commitizen friendly Go Report Card GoDoc Build Status codecov

Fully compatible with https://github.com/shurcooL/graphql v0.0.0-20181231061246-d48a9a75455f

You can simply replace github.com/shurcooL/graphql --> github.com/Laisky/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/Laisky/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("laisky.123"),
	}
	gracli := graphql.NewClient(
		"https://blog.laisky.com/graphql/query/",
		httpClient,
	)
	if err := gracli.Query(ctx, query, vars); err != nil {
		t.Fatalf("%+v", err)
	}

}