...

Package graphql

import "github.com/cli/shurcooL-graphql"
Overview
Index
Subdirectories

Overview ▾

type Boolean

Boolean represents true or false values.

type Boolean bool

func NewBoolean

func NewBoolean(v Boolean) *Boolean

NewBoolean is a helper to make a new *Boolean.

type Client

Client is a GraphQL client.

type Client struct {
    // contains filtered or unexported fields
}

func NewClient

func NewClient(url string, httpClient *http.Client) *Client

NewClient creates a GraphQL client targeting the specified GraphQL server URL. If httpClient is nil, then http.DefaultClient is used.

func (*Client) Mutate

func (c *Client) Mutate(ctx context.Context, m any, variables map[string]any) error

Mutate executes a single GraphQL mutation request, with a mutation derived from m, populating the response into it. Argument m should be a pointer to struct that corresponds to the GraphQL schema.

func (*Client) MutateNamed

func (c *Client) MutateNamed(ctx context.Context, queryName string, m any, variables map[string]any) error

MutateNamed is the same as Mutate but allows a name to be specified for the mutation.

func (*Client) Query

func (c *Client) Query(ctx context.Context, q any, variables map[string]any) error

Query executes a single GraphQL query request, with a query derived from q, populating the response into it. Argument q should be a pointer to struct that corresponds to the GraphQL schema.

func (*Client) QueryNamed

func (c *Client) QueryNamed(ctx context.Context, queryName string, q any, variables map[string]any) error

QueryNamed is the same as Query but allows a name to be specified for the query.

type Errors

Errors represents the "errors" array in a response from a GraphQL server. If returned via error interface, the slice is expected to contain at least 1 element.

Specification: https://spec.graphql.org/October2021/#sec-Errors.

type Errors []struct {
    Message   string
    Locations []struct {
        Line   int
        Column int
    }
    Path       []any
    Extensions map[string]any
    Type       string
}

func (Errors) Error

func (e Errors) Error() string

Error implements error interface.

type Float

Float represents signed double-precision fractional values as specified by IEEE 754.

type Float float64

func NewFloat

func NewFloat(v Float) *Float

NewFloat is a helper to make a new *Float.

type ID

ID represents a unique identifier that is Base64 obfuscated. It is often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as "VXNlci0xMA==") or integer (such as 4) input value will be accepted as an ID.

type ID any

func NewID

func NewID(v ID) *ID

NewID is a helper to make a new *ID.

type Int

Int represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.

type Int int32

func NewInt

func NewInt(v Int) *Int

NewInt is a helper to make a new *Int.

type String

String represents textual data as UTF-8 character sequences. This type is most often used by GraphQL to represent free-form human-readable text.

type String string

func NewString

func NewString(v String) *String

NewString is a helper to make a new *String.

Subdirectories

Name Synopsis
..
ident Package ident provides functions for parsing and converting identifier names between various naming convention.