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 ¶
const NodeBatchCap = 200
NodeBatchCap mirrors hadron-server's BATCH_READ_MAX_NODES (cor:api:040): a single nodeBatch call accepts at most 200 ids and fails loud above that, so bulk reads fan out in fixed-size chunks. The server also enforces a ~1 MB response cap that can return a partial page (truncated=true) with the spillover ids in `omitted`; CollectNodeBatch re-requests those.
Variables ¶
This section is empty.
Functions ¶
func CollectNodeBatch ¶ added in v0.2.0
func CollectNodeBatch( ids []string, fetch func([]string) (*gen.NodeBatchNodeBatchNodeBatchResult, error), ) ([]*gen.NodeBatchNodeBatchNodeBatchResultNodesNode, []string, error)
CollectNodeBatch fetches full nodes for ids in cap-sized chunks, re-queuing the spillover the server drops under its response-size cap. fetch is injected rather than calling gen.NodeBatch directly so the chunking/truncation loop is unit-testable without a server and so each caller controls the field projection. Returns the nodes (input order is not preserved across chunks), the union of ids the server reported unavailable, and the first error.
Shared by the whole-corpus fan-outs (`memory export`, `spec get --prefix`).
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.