api

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package api wraps the Hadron GraphQL endpoint: a genqlient client for typed operations, a raw escape hatch for `hadron api`, and the mapping from transport/GraphQL errors to exit codes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Endpoint

func Endpoint(serverURL string) string

Endpoint joins the server base URL with the GraphQL path.

func MapError

func MapError(err error) error

MapError converts transport and GraphQL errors into CodedErrors so the root command can derive the documented exit code. Codes come from hadron-server's Apollo resolvers (extensions.code).

func NewClient

func NewClient(serverURL, token string, httpClient *http.Client) (graphql.Client, error)

NewClient returns a genqlient client for the given server, authenticating with token (may be empty for anonymous calls).

Types

type RawResult

type RawResult struct {
	Body   json.RawMessage
	Errors []rawError
}

RawResult is the verbatim GraphQL response envelope.

func RawGraphQL

func RawGraphQL(ctx context.Context, serverURL, token, query string, variables map[string]any, httpClient *http.Client) (*RawResult, error)

RawGraphQL posts an arbitrary query/mutation to the server and returns the raw response body. Used by `hadron api`. The returned error carries the mapped exit code when the response contains GraphQL errors.

func (*RawResult) Err

func (r *RawResult) Err() error

Err returns a CodedError summarizing the response's GraphQL errors, or nil when the response is error-free.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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