graphql

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package graphql translates a GraphQL schema into callable operations.

The translation differs from REST in one fundamental way, and that decides the design: in REST, calling an endpoint returns a whole document; in GraphQL, **the caller chooses what comes back**. There is no "call it and see what arrives" — without a field selection the server rejects the request.

So each Query/Mutation field becomes a tool whose selection WE assemble: the scalar fields of the return type, descending while it is worth it. An optional argument lets the model ask for something else when the default does not fit. The common alternative — exposing one `graphql(query)` tool and letting the model write the whole query — hands it work the schema already answers, and that is where this kind of integration usually goes wrong.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Operations

func Operations(_ context.Context, doc *spec.Document, o Options) ([]core.Operation, error)

Operations translates the whole schema: every Query and Mutation field becomes a tool.

Types

type Options

type Options struct {
	Endpoint string // where queries go (required: the schema does not say)
	Auth     auth.Applier
	Client   *http.Client
	Headers  map[string]string
	Depth    int // how deep the automatic selection descends; 0 uses the default
}

Options are decisions made by whoever starts the server.

Jump to

Keyboard shortcuts

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