Help us shape the future of Go! Take the 2026 Go Developer Survey

client

package
v1.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrStopSubscription = errors.New("stop subscription")

ErrStopSubscription ends a subscription without an error when a handler returns it.

Functions

This section is empty.

Types

type Client

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

func New

func New(baseURL, apiKey string, options ...Option) *Client

func (*Client) Query

func (c *Client) Query(ctx context.Context, query string, variables map[string]interface{}, result interface{}) error

func (*Client) Subscribe added in v1.5.0

func (c *Client) Subscribe(ctx context.Context, query string, variables map[string]interface{}, handle func(json.RawMessage) error) error

Subscribe runs a GraphQL subscription and calls handle with the data of each event. It returns nil when the server completes, ctx ends, or handle returns ErrStopSubscription. The client timeout applies to the handshake only.

type GraphQLError

type GraphQLError struct {
	Message string `json:"message"`
	Path    []any  `json:"path,omitempty"`
}

type GraphQLRequest

type GraphQLRequest struct {
	Query     string                 `json:"query"`
	Variables map[string]interface{} `json:"variables,omitempty"`
}

type GraphQLResponse

type GraphQLResponse struct {
	Data   json.RawMessage `json:"data"`
	Errors []GraphQLError  `json:"errors,omitempty"`
}

type Option added in v1.4.0

type Option func(*Client)

func WithDryRun added in v1.4.0

func WithDryRun(enabled bool) Option

func WithTimeout added in v1.4.0

func WithTimeout(timeout time.Duration) Option

func WithTrace added in v1.4.0

func WithTrace(trace func(string, string, int, time.Duration)) Option

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL