Documentation
¶
Index ¶
- Constants
- func GetAvailableFormatters() []string
- func GetConfigPath() string
- func GetConfigPathForDir(configDir string) string
- func GetDefaultPath() string
- func GetGraphQLSchemaPathForConfigInDir(configName, configDir string) string
- func GetJSONSchemaPathForConfigInDir(configName, configDir string) string
- func GetSchemaPath() string
- func GetSchemaPathForConfig(configName string) string
- func GetSchemaPathForConfigInDir(configName, configDir string) string
- func GetSchemasDir() string
- func RegisterFormatter(name string, factory FormatterFactory)
- func SDLToIntrospection(sdl string) (interface{}, error)
- func SaveGraphQLSchema(schema *Response, filePath string) error
- func SaveSchema(result *Response, path string) error
- func SaveSchemaDual(result *Response, configName, configDir string) error
- func SchemaExists(path string) bool
- func Version() string
- type Analyzer
- func (a *Analyzer) FindField(rootType, fieldName string) (*FieldDescription, error)
- func (a *Analyzer) FindType(typeName string) (*TypeDescription, error)
- func (a *Analyzer) GetFieldDescription(rootType string, fieldObj map[string]interface{}) (*FieldDescription, error)
- func (a *Analyzer) GetSummary() (*Summary, error)
- func (a *Analyzer) GetTypeDescription(typeName string) (*TypeDescription, error)
- type Client
- func (c *Client) Execute(query string, variables map[string]interface{}, operationName string) (*Response, error)
- func (c *Client) ExecuteWithFiles(query string, variables map[string]interface{}, operationName string, ...) (*Response, error)
- func (c *Client) FetchSDL() (string, error)
- func (c *Client) Introspect() (*Response, error)
- func (c *Client) SetAuth(username, password string)
- func (c *Client) SetHeaders(headers map[string]string)
- func (c *Client) Subscribe(ctx context.Context, query string, variables map[string]interface{}, ...) (<-chan *SubscriptionMessage, <-chan error, error)
- type Config
- func (c *Config) Create(name string) error
- func (c *Config) Delete(name string) error
- func (c *Config) GetCurrent() *ConfigEntry
- func (c *Config) Save(configDir string) error
- func (c *Config) SetCurrent(name string) error
- func (c *Config) SetValue(name, key, value string) error
- func (c *Config) Validate() []string
- type ConfigEntry
- type DescribeTypeInput
- type DescribeTypeOutput
- type EnumValue
- type ErrorInfo
- type ExecuteQueryInput
- type ExecuteQueryOutput
- type FieldDescription
- type FieldSummary
- type Formatter
- type FormatterFactory
- type FormatterRegistry
- type Input
- func (i *Input) LoadHeaders(headers []string) map[string]string
- func (i *Input) LoadQuery(query, queryFile string) (string, error)
- func (i *Input) LoadVariables(vars, varsFile string) (map[string]interface{}, error)
- func (i *Input) ParseFiles(files []string) (map[string]string, error)
- func (i *Input) ParseFilesFromList(filesListPath string) ([]string, error)
- type Introspect
- type JSONFormatter
- func (f *JSONFormatter) FormatJSON(data interface{}) error
- func (f *JSONFormatter) FormatResponse(response *Response, mode string) error
- func (f *JSONFormatter) FormatStructured(data interface{}, quiet bool) error
- func (f *JSONFormatter) FormatStructuredError(err error, code string, quiet bool) error
- func (f *JSONFormatter) FormatStructuredErrorWithContext(err error, code string, errorType string, context map[string]interface{}, ...) error
- func (f *JSONFormatter) SetErrorOutput(writer io.Writer)
- func (f *JSONFormatter) SetOutput(writer io.Writer)
- func (f *JSONFormatter) WriteToFile(data interface{}, filename string) error
- type ListTypesInput
- type ListTypesOutput
- type MetaInfo
- type OperationInfo
- type OperationType
- type Response
- type SDKServer
- type SSEEvent
- type SSEMessage
- type SSEReader
- type SSESubscriptionClient
- type Schema
- type StructuredOutput
- type SubscriptionClient
- func (c *SubscriptionClient) Close() error
- func (c *SubscriptionClient) Connect(ctx context.Context) error
- func (c *SubscriptionClient) Subscribe(ctx context.Context, query string, variables map[string]interface{}, ...) (<-chan *SubscriptionMessage, <-chan error, error)
- func (c *SubscriptionClient) Unsubscribe(ctx context.Context, subscriptionID string) error
- type SubscriptionMessage
- type Summary
- type TableFormatter
- func (f *TableFormatter) FormatResponse(response *Response, mode string) error
- func (f *TableFormatter) FormatStructured(data interface{}, quiet bool) error
- func (f *TableFormatter) FormatStructuredError(err error, code string, quiet bool) error
- func (f *TableFormatter) FormatStructuredErrorWithContext(err error, code string, errorType string, context map[string]interface{}, ...) error
- func (f *TableFormatter) SetErrorOutput(writer io.Writer)
- func (f *TableFormatter) SetOutput(writer io.Writer)
- type TypeDescription
- type VersionInput
- type VersionOutput
- type YAMLFormatter
- func (f *YAMLFormatter) FormatResponse(response *Response, mode string) error
- func (f *YAMLFormatter) FormatStructured(data interface{}, quiet bool) error
- func (f *YAMLFormatter) FormatStructuredError(err error, code string, quiet bool) error
- func (f *YAMLFormatter) FormatStructuredErrorWithContext(err error, code string, errorType string, context map[string]interface{}, ...) error
- func (f *YAMLFormatter) SetErrorOutput(writer io.Writer)
- func (f *YAMLFormatter) SetOutput(writer io.Writer)
Constants ¶
const ( // Configuration errors ErrorCodeConfigLoad = "CONFIG_LOAD_ERROR" ErrorCodeConfigNotFound = "CONFIG_NOT_FOUND" ErrorCodeConfigCreate = "CONFIG_CREATE_ERROR" ErrorCodeConfigSave = "CONFIG_SAVE_ERROR" ErrorCodeConfigDelete = "CONFIG_DELETE_ERROR" ErrorCodeConfigValidate = "CONFIG_VALIDATE_ERROR" // Input validation errors ErrorCodeInputValidation = "INPUT_VALIDATION_ERROR" ErrorCodeQueryLoad = "QUERY_LOAD_ERROR" ErrorCodeVariablesLoad = "VARIABLES_LOAD_ERROR" ErrorCodeFilesParse = "FILES_PARSE_ERROR" ErrorCodeFilesListParse = "FILES_LIST_PARSE_ERROR" // GraphQL execution errors ErrorCodeGraphQLExecution = "GRAPHQL_EXECUTION_ERROR" ErrorCodeGraphQLErrors = "GRAPHQL_ERRORS" ErrorCodeNetworkError = "NETWORK_ERROR" ErrorCodeAuthError = "AUTH_ERROR" // Schema errors ErrorCodeSchemaLoad = "SCHEMA_LOAD_ERROR" ErrorCodeSchemaIntrospect = "SCHEMA_INTROSPECT_ERROR" ErrorCodeSchemaSave = "SCHEMA_SAVE_ERROR" // System errors ErrorCodeSystemError = "SYSTEM_ERROR" ErrorCodeFileNotFound = "FILE_NOT_FOUND" ErrorCodePermissionDenied = "PERMISSION_DENIED" )
Common error codes for AI agents
const ( SSEMessageTypeNext = "next" SSEMessageTypeError = "error" SSEMessageTypeComplete = "complete" )
SSE message types for graphql-sse protocol
const ( MessageTypeConnectionInit = "connection_init" MessageTypeConnectionAck = "connection_ack" MessageTypePing = "ping" MessageTypePong = "pong" MessageTypeSubscribe = "subscribe" MessageTypeNext = "next" MessageTypeError = "error" MessageTypeComplete = "complete" )
GraphQL WebSocket Protocol Messages (graphql-transport-ws)
Variables ¶
This section is empty.
Functions ¶
func GetAvailableFormatters ¶
func GetAvailableFormatters() []string
GetAvailableFormatters returns all available formatter names
func GetConfigPath ¶
func GetConfigPath() string
GetConfigPath returns the path to the main configuration file. This is typically config.json in the default configuration directory.
func GetConfigPathForDir ¶
GetConfigPathForDir returns the path to the configuration file in a specific directory.
func GetDefaultPath ¶
func GetDefaultPath() string
Public path functions GetDefaultPath returns the default configuration directory path for the current OS. On Linux: ~/.config/gqlt On macOS: ~/Library/Application Support/gqlt On Windows: %APPDATA%/gqlt
func GetGraphQLSchemaPathForConfigInDir ¶
GetGraphQLSchemaPathForConfigInDir returns the path to the GraphQL SDL schema file for a specific configuration in a specific directory.
func GetJSONSchemaPathForConfigInDir ¶
GetJSONSchemaPathForConfigInDir returns the path to the JSON schema file for a specific configuration in a specific directory.
func GetSchemaPath ¶
func GetSchemaPath() string
GetSchemaPath returns the path to the default schema file. This is typically schema.json in the default configuration directory.
func GetSchemaPathForConfig ¶
GetSchemaPathForConfig returns the path to the schema file for a specific configuration. This is typically schemas/{configName}.json in the default configuration directory.
func GetSchemaPathForConfigInDir ¶
GetSchemaPathForConfigInDir returns the path to the schema file for a specific configuration in a specific directory.
func GetSchemasDir ¶
func GetSchemasDir() string
GetSchemasDir returns the path to the schemas directory. This is typically schemas/ in the default configuration directory.
func RegisterFormatter ¶
func RegisterFormatter(name string, factory FormatterFactory)
RegisterFormatter registers a custom formatter with the default registry
func SDLToIntrospection ¶ added in v0.6.0
SDLToIntrospection converts SDL schema text to introspection JSON format
func SaveGraphQLSchema ¶
SaveGraphQLSchema saves the schema as GraphQL SDL
func SaveSchema ¶
SaveSchema saves schema to a single file
func SaveSchemaDual ¶
SaveSchemaDual saves schema in both JSON and GraphQL formats
Types ¶
type Analyzer ¶
type Analyzer struct {
// contains filtered or unexported fields
}
Analyzer handles GraphQL schema analysis and provides utilities for exploring and understanding GraphQL schemas. It can extract type information, field details, and generate human-readable descriptions of schema elements.
func LoadAnalyzerFromFile ¶
LoadAnalyzerFromFile creates a new schema analyzer by loading a schema from a JSON file. The file should contain a GraphQL introspection response in JSON format.
Example:
analyzer, err := gqlt.LoadAnalyzerFromFile("schema.json")
if err != nil {
log.Fatal(err)
}
func NewAnalyzer ¶
NewAnalyzer creates a new schema analyzer from a GraphQL introspection response. The schema parameter should be the result of a GraphQL introspection query.
Example:
analyzer, err := gqlt.NewAnalyzer(introspectionResponse)
if err != nil {
log.Fatal(err)
}
func (*Analyzer) FindField ¶
func (a *Analyzer) FindField(rootType, fieldName string) (*FieldDescription, error)
FindField finds a field in a root type
func (*Analyzer) FindType ¶
func (a *Analyzer) FindType(typeName string) (*TypeDescription, error)
FindType finds a type by name
func (*Analyzer) GetFieldDescription ¶
func (a *Analyzer) GetFieldDescription(rootType string, fieldObj map[string]interface{}) (*FieldDescription, error)
GetFieldDescription gets a field description
func (*Analyzer) GetSummary ¶
GetSummary returns a summary of the schema
func (*Analyzer) GetTypeDescription ¶
func (a *Analyzer) GetTypeDescription(typeName string) (*TypeDescription, error)
GetTypeDescription gets a type description by name
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents a GraphQL client that can execute queries, mutations, and subscriptions against a GraphQL endpoint. It handles authentication, headers, and HTTP communication.
func NewClient ¶
NewClient creates a new GraphQL client for the specified endpoint. The headers parameter can be nil or contain additional HTTP headers to send with requests.
Example:
client := gqlt.NewClient("https://api.example.com/graphql", map[string]string{
"Authorization": "Bearer token",
})
func (*Client) Execute ¶
func (c *Client) Execute(query string, variables map[string]interface{}, operationName string) (*Response, error)
Execute executes a GraphQL query, mutation, or subscription against the configured endpoint. The query parameter contains the GraphQL operation string, variables contains any variables to be passed to the operation, and operationName specifies which operation to execute (useful when the query contains multiple operations).
Example:
response, err := client.Execute(
`query GetUser($id: ID!) { user(id: $id) { name email } }`,
map[string]interface{}{"id": "123"},
"GetUser",
)
func (*Client) ExecuteWithFiles ¶
func (c *Client) ExecuteWithFiles(query string, variables map[string]interface{}, operationName string, files map[string]string) (*Response, error)
ExecuteWithFiles executes a GraphQL operation with file uploads using multipart/form-data. This method is used for GraphQL operations that require file uploads, such as mutations with Upload scalar types. The files parameter maps field names to file paths.
Example:
response, err := client.ExecuteWithFiles(
`mutation UploadFile($file: Upload!) { uploadFile(file: $file) { id } }`,
map[string]interface{}{"file": nil}, // File will be provided via files parameter
"UploadFile",
map[string]string{"file": "/path/to/file.jpg"},
)
func (*Client) FetchSDL ¶ added in v0.6.0
FetchSDL attempts to fetch the GraphQL schema in SDL format from common endpoint paths
func (*Client) Introspect ¶
Introspect performs GraphQL introspection to get the schema
func (*Client) SetAuth ¶
SetAuth sets basic authentication for the client using the provided username and password. This will add an Authorization header with Basic authentication to all requests.
Example:
client.SetAuth("username", "password")
func (*Client) SetHeaders ¶
SetHeaders sets additional HTTP headers for the client. These headers will be sent with all subsequent requests.
Example:
client.SetHeaders(map[string]string{
"Authorization": "Bearer token",
"X-Custom-Header": "value",
})
func (*Client) Subscribe ¶ added in v0.8.0
func (c *Client) Subscribe(ctx context.Context, query string, variables map[string]interface{}, operationName string) (<-chan *SubscriptionMessage, <-chan error, error)
Subscribe establishes a GraphQL subscription over WebSocket and returns channels for messages and errors. The subscription runs until the context is cancelled, an error occurs, or the server closes the connection.
Example:
client := gqlt.NewClient("wss://api.example.com/graphql", nil)
messages, errors, err := client.Subscribe(ctx,
`subscription { userCreated { id name } }`,
nil,
"UserCreated",
)
if err != nil {
log.Fatal(err)
}
for msg := range messages {
fmt.Printf("Received: %+v\n", msg)
}
type Config ¶
type Config struct {
Current string `json:"current"` // active config name (defaults to "default")
Configs map[string]ConfigEntry `json:"configs"` // named configurations
}
Config represents the main configuration structure that manages multiple named configurations. It allows switching between different GraphQL endpoints and their associated settings.
func GetDefaultConfig ¶
func GetDefaultConfig() *Config
GetDefaultConfig returns a default configuration
func Load ¶
Load reads a configuration file from the specified config directory. If configDir is empty, it searches in standard locations (current directory, then default path). Returns a Config struct with the loaded configuration or an error if loading fails.
Example:
config, err := gqlt.Load("/path/to/config")
if err != nil {
log.Fatal(err)
}
func (*Config) GetCurrent ¶
func (c *Config) GetCurrent() *ConfigEntry
GetCurrent returns the current active configuration entry. If the current configuration doesn't exist, it falls back to the "default" configuration, or creates a default entry if no configurations exist.
Example:
current := config.GetCurrent()
fmt.Printf("Current endpoint: %s\n", current.Endpoint)
func (*Config) Save ¶
Save writes the configuration to the specified config directory. Creates the directory if it doesn't exist and writes the configuration as JSON.
Example:
err := config.Save("/path/to/config")
if err != nil {
log.Fatal(err)
}
func (*Config) SetCurrent ¶
SetCurrent sets the current active configuration
type ConfigEntry ¶
type ConfigEntry struct {
Endpoint string `json:"endpoint"` // GraphQL endpoint URL
Headers map[string]string `json:"headers"` // HTTP headers to send with requests
Auth struct {
Token string `json:"token,omitempty"` // Bearer token for authentication
Username string `json:"username,omitempty"` // Username for basic authentication
Password string `json:"password,omitempty"` // Password for basic authentication
APIKey string `json:"api_key,omitempty"` // API key for authentication
} `json:"auth"`
Comment string `json:"_comment,omitempty"` // AI-friendly documentation
}
ConfigEntry represents a single configuration for a GraphQL endpoint. It contains the endpoint URL, headers, authentication credentials, default output format, and optional documentation.
func (*ConfigEntry) GetHeaders ¶ added in v0.2.0
func (e *ConfigEntry) GetHeaders() map[string]string
GetHeaders returns the HTTP headers for this configuration entry, including computed authentication headers based on stored credentials.
type DescribeTypeInput ¶ added in v0.4.0
type DescribeTypeInput struct {
TypeName string `json:"typeName" jsonschema:"The GraphQL type name to describe"`
Endpoint string `json:"endpoint,omitempty" jsonschema:"GraphQL endpoint URL (required if schemaFile not provided)"`
SchemaFile string `json:"schemaFile,omitempty" jsonschema:"Local schema file path (JSON or SDL format, alternative to endpoint)"`
Headers map[string]string `json:"headers,omitempty" jsonschema:"HTTP headers to include (only used with endpoint)"`
NoCache bool `json:"noCache,omitempty" jsonschema:"Skip cache and force fresh schema introspection (only used with endpoint)"`
}
DescribeTypeInput defines the input schema for the describe_type tool
type DescribeTypeOutput ¶ added in v0.4.0
type DescribeTypeOutput struct {
TypeInfo string `json:"type_info" jsonschema:"Information about the GraphQL type"`
}
DescribeTypeOutput defines the output schema for the describe_type tool
type EnumValue ¶
type EnumValue struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
}
EnumValue represents an enum value
type ErrorInfo ¶
type ErrorInfo struct {
Code string `json:"code"`
Message string `json:"message"`
Details string `json:"details,omitempty"`
Type string `json:"type,omitempty"`
Context map[string]interface{} `json:"context,omitempty"`
}
ErrorInfo provides structured error information
type ExecuteQueryInput ¶ added in v0.4.0
type ExecuteQueryInput struct {
Query string `json:"query" jsonschema:"The GraphQL query string"`
Variables map[string]interface{} `json:"variables,omitempty" jsonschema:"Variables to pass to the query"`
OperationName string `json:"operationName,omitempty" jsonschema:"The operation name to execute"`
Endpoint string `json:"endpoint" jsonschema:"GraphQL endpoint URL (ws:// or wss:// for subscriptions)"`
Headers map[string]string `json:"headers,omitempty" jsonschema:"HTTP headers to include"`
Files map[string]string `` /* 130-byte string literal not displayed */
Timeout string `` /* 126-byte string literal not displayed */
MaxMessages int `` /* 137-byte string literal not displayed */
}
ExecuteQueryInput defines the input schema for the execute_query tool
type ExecuteQueryOutput ¶ added in v0.4.0
type ExecuteQueryOutput struct {
Data interface{} `json:"data" jsonschema:"The GraphQL response data"`
Errors interface{} `json:"errors,omitempty" jsonschema:"Any GraphQL errors"`
ElapsedMs int64 `json:"elapsed_ms" jsonschema:"Query execution time in milliseconds"`
}
ExecuteQueryOutput defines the output schema for the execute_query tool
type FieldDescription ¶
type FieldDescription struct {
RootType string `json:"rootType"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Type string `json:"type"`
Arguments []FieldSummary `json:"arguments,omitempty"`
}
FieldDescription represents a field description
type FieldSummary ¶
type FieldSummary struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Type string `json:"type"`
Signature string `json:"signature"`
DefaultValue string `json:"defaultValue,omitempty"`
Arguments []FieldSummary `json:"arguments,omitempty"`
}
FieldSummary represents a field summary
type Formatter ¶
type Formatter interface {
FormatStructured(data interface{}, quiet bool) error
FormatStructuredError(err error, code string, quiet bool) error
FormatStructuredErrorWithContext(err error, code string, errorType string, context map[string]interface{}, quiet bool) error
FormatResponse(response *Response, mode string) error
SetOutput(writer io.Writer)
SetErrorOutput(writer io.Writer)
}
Formatter defines the interface for output formatting. Implementations can format data as JSON, table, YAML, or other formats.
func NewFormatter ¶
NewFormatter creates a new formatter using the default registry Returns the default JSON formatter if the requested format is not found
type FormatterFactory ¶
type FormatterFactory func() Formatter
FormatterFactory creates a new formatter instance. This function type is used to register formatters in the registry.
type FormatterRegistry ¶
type FormatterRegistry struct {
// contains filtered or unexported fields
}
FormatterRegistry manages available formatters and provides a way to register and retrieve formatters by name.
func NewFormatterRegistry ¶
func NewFormatterRegistry() *FormatterRegistry
NewFormatterRegistry creates a new formatter registry with default formatters (JSON, Table, YAML) already registered.
Example:
registry := gqlt.NewFormatterRegistry()
formatter, err := registry.Get("json")
func (*FormatterRegistry) Get ¶
func (r *FormatterRegistry) Get(format string) (Formatter, error)
Get creates a new formatter instance for the specified format
func (*FormatterRegistry) List ¶
func (r *FormatterRegistry) List() []string
List returns all registered formatter names
func (*FormatterRegistry) Register ¶
func (r *FormatterRegistry) Register(name string, factory FormatterFactory)
Register adds a new formatter to the registry
type Input ¶
type Input struct{}
Input handles input operations for loading queries, variables, headers, and files. It provides utilities for parsing and loading various types of input data.
func NewInput ¶
func NewInput() *Input
NewInput creates a new input handler instance.
Example:
input := gqlt.NewInput()
query, err := input.LoadQuery("", "query.graphql")
func (*Input) LoadHeaders ¶
LoadHeaders parses header strings into a map. Each header string should be in the format "Key: Value".
Example:
headers := input.LoadHeaders([]string{
"Authorization: Bearer token",
"Content-Type: application/json",
})
func (*Input) LoadQuery ¶
LoadQuery loads a GraphQL query from a string or file. If query is provided, it returns the query string directly. If queryFile is provided, it reads and returns the file contents. If both are provided, query takes precedence.
Example:
query, err := input.LoadQuery("", "query.graphql")
if err != nil {
log.Fatal(err)
}
func (*Input) LoadVariables ¶
LoadVariables loads GraphQL variables from a JSON string or file. If vars is provided, it parses the JSON string directly. If varsFile is provided, it reads and parses the file contents. If both are provided, vars takes precedence.
Example:
variables, err := input.LoadVariables(`{"id": "123"}`, "")
if err != nil {
log.Fatal(err)
}
func (*Input) ParseFiles ¶
ParseFiles parses file upload specifications
type Introspect ¶
type Introspect struct {
// contains filtered or unexported fields
}
Introspect handles GraphQL schema introspection operations. It provides utilities for introspecting GraphQL schemas and saving them to files.
func NewIntrospect ¶
func NewIntrospect(client *Client) *Introspect
NewIntrospect creates a new introspection handler for the specified client.
Example:
client := gqlt.NewClient("https://api.example.com/graphql", nil)
introspect := gqlt.NewIntrospect(client)
func (*Introspect) IntrospectSchema ¶
func (i *Introspect) IntrospectSchema() (*Response, error)
IntrospectSchema performs GraphQL introspection to get the schema from the endpoint. Returns a Response containing the complete GraphQL schema information.
Example:
schema, err := introspect.IntrospectSchema()
if err != nil {
log.Fatal(err)
}
func (*Introspect) SaveSchema ¶
func (i *Introspect) SaveSchema(schema *Response, filePath string) error
SaveSchema saves a schema response to a JSON file. The file will contain the complete introspection response in formatted JSON.
Example:
err := introspect.SaveSchema(schema, "schema.json")
if err != nil {
log.Fatal(err)
}
type JSONFormatter ¶
type JSONFormatter struct {
// contains filtered or unexported fields
}
JSONFormatter implements Formatter for JSON output
func (*JSONFormatter) FormatJSON ¶
func (f *JSONFormatter) FormatJSON(data interface{}) error
FormatJSON formats data as JSON with indentation
func (*JSONFormatter) FormatResponse ¶
func (f *JSONFormatter) FormatResponse(response *Response, mode string) error
FormatResponse formats a GraphQL response as compact JSON
func (*JSONFormatter) FormatStructured ¶
func (f *JSONFormatter) FormatStructured(data interface{}, quiet bool) error
FormatStructured formats data as structured JSON output
func (*JSONFormatter) FormatStructuredError ¶
func (f *JSONFormatter) FormatStructuredError(err error, code string, quiet bool) error
FormatStructuredError formats an error as structured output
func (*JSONFormatter) FormatStructuredErrorWithContext ¶
func (f *JSONFormatter) FormatStructuredErrorWithContext(err error, code string, errorType string, context map[string]interface{}, quiet bool) error
FormatStructuredErrorWithContext formats an error with additional context
func (*JSONFormatter) SetErrorOutput ¶
func (f *JSONFormatter) SetErrorOutput(writer io.Writer)
SetErrorOutput sets the error output writer for the formatter
func (*JSONFormatter) SetOutput ¶
func (f *JSONFormatter) SetOutput(writer io.Writer)
SetOutput sets the output writer for the formatter
func (*JSONFormatter) WriteToFile ¶
func (f *JSONFormatter) WriteToFile(data interface{}, filename string) error
WriteToFile writes data to a file
type ListTypesInput ¶ added in v0.4.0
type ListTypesInput struct {
Endpoint string `json:"endpoint,omitempty" jsonschema:"GraphQL endpoint URL (required if schemaFile not provided)"`
SchemaFile string `json:"schemaFile,omitempty" jsonschema:"Local schema file path (JSON or SDL format, alternative to endpoint)"`
Filter string `json:"filter,omitempty" jsonschema:"Optional regex pattern to filter type names (e.g., 'Input.*', '.*Type', 'User.*')"`
Kind string `json:"kind,omitempty" jsonschema:"Optional type kind filter (OBJECT, ENUM, SCALAR, UNION, INPUT_OBJECT, INTERFACE)"`
Headers map[string]string `json:"headers,omitempty" jsonschema:"HTTP headers to include (only used with endpoint)"`
NoCache bool `json:"noCache,omitempty" jsonschema:"Skip cache and force fresh schema introspection (only used with endpoint)"`
}
ListTypesInput defines the input schema for the list_types tool
type ListTypesOutput ¶ added in v0.4.0
type ListTypesOutput struct {
TypeNames []string `json:"type_names" jsonschema:"List of matching type names"`
Count int `json:"count" jsonschema:"Total number of matching types"`
}
ListTypesOutput defines the output schema for the list_types tool
type MetaInfo ¶
type MetaInfo struct {
Command string `json:"command,omitempty"`
Timestamp string `json:"timestamp,omitempty"`
Duration string `json:"duration,omitempty"`
Config string `json:"config,omitempty"`
Endpoint string `json:"endpoint,omitempty"`
Operation string `json:"operation,omitempty"`
Variables map[string]interface{} `json:"variables,omitempty"`
}
MetaInfo provides metadata about the operation
type OperationInfo ¶ added in v0.8.0
type OperationInfo struct {
Type OperationType
Name string
}
OperationInfo contains information about a GraphQL operation
func DetectOperationType ¶ added in v0.8.0
func DetectOperationType(query string, operationName string) (*OperationInfo, error)
DetectOperationType parses a GraphQL document and detects the operation type. If operationName is provided, it finds that specific operation. If operationName is empty and there's only one operation, it uses that one. Returns an error if the operation can't be determined or doesn't exist.
type OperationType ¶ added in v0.8.0
type OperationType string
OperationType represents the type of a GraphQL operation
const ( OperationTypeQuery OperationType = "query" OperationTypeMutation OperationType = "mutation" OperationTypeSubscription OperationType = "subscription" )
type Response ¶
type Response struct {
Data interface{} `json:"data"`
Errors []interface{} `json:"errors,omitempty"`
Extensions map[string]interface{} `json:"extensions,omitempty"`
}
Response represents a GraphQL response containing data, errors, and extensions. The Data field contains the actual response data, Errors contains any GraphQL errors, and Extensions contains additional metadata from the server.
type SDKServer ¶ added in v0.4.0
type SDKServer struct {
// contains filtered or unexported fields
}
SDKServer wraps the official MCP SDK server with gqlt functionality
func NewSDKServer ¶ added in v0.4.0
NewSDKServer creates a new MCP server using the official SDK
type SSEMessage ¶ added in v0.8.0
type SSEMessage struct {
Type string `json:"type"`
ID string `json:"id,omitempty"`
Payload map[string]interface{} `json:"payload,omitempty"`
}
SSEMessage represents a message received from SSE subscription
type SSEReader ¶ added in v0.8.0
type SSEReader struct {
// contains filtered or unexported fields
}
SSEReader reads Server-Sent Events from an io.Reader
func NewSSEReader ¶ added in v0.8.0
NewSSEReader creates a new SSE reader
type SSESubscriptionClient ¶ added in v0.8.0
type SSESubscriptionClient struct {
// contains filtered or unexported fields
}
SSESubscriptionClient handles GraphQL subscriptions over Server-Sent Events
func NewSSESubscriptionClient ¶ added in v0.8.0
func NewSSESubscriptionClient(url string, headers map[string]string) *SSESubscriptionClient
NewSSESubscriptionClient creates a new SSE subscription client
func (*SSESubscriptionClient) Subscribe ¶ added in v0.8.0
func (c *SSESubscriptionClient) Subscribe(ctx context.Context, query string, variables map[string]interface{}, operationName string) (<-chan *SubscriptionMessage, <-chan error, error)
Subscribe starts a subscription and returns channels for messages and errors
type StructuredOutput ¶
type StructuredOutput struct {
Success bool `json:"success"`
Data interface{} `json:"data,omitempty"`
Error *ErrorInfo `json:"error,omitempty"`
Meta *MetaInfo `json:"meta,omitempty"`
}
StructuredOutput represents a structured response for AI agents
type SubscriptionClient ¶ added in v0.8.0
type SubscriptionClient struct {
// contains filtered or unexported fields
}
SubscriptionClient handles GraphQL subscriptions over WebSocket
func NewSubscriptionClient ¶ added in v0.8.0
func NewSubscriptionClient(url string, headers map[string]string) *SubscriptionClient
NewSubscriptionClient creates a new WebSocket subscription client
func (*SubscriptionClient) Close ¶ added in v0.8.0
func (c *SubscriptionClient) Close() error
Close closes the WebSocket connection
func (*SubscriptionClient) Connect ¶ added in v0.8.0
func (c *SubscriptionClient) Connect(ctx context.Context) error
Connect establishes a WebSocket connection and performs the connection handshake
func (*SubscriptionClient) Subscribe ¶ added in v0.8.0
func (c *SubscriptionClient) Subscribe(ctx context.Context, query string, variables map[string]interface{}, operationName string) (<-chan *SubscriptionMessage, <-chan error, error)
Subscribe sends a subscription request and returns a channel of messages
func (*SubscriptionClient) Unsubscribe ¶ added in v0.8.0
func (c *SubscriptionClient) Unsubscribe(ctx context.Context, subscriptionID string) error
Unsubscribe sends a complete message to stop the subscription
type SubscriptionMessage ¶ added in v0.8.0
type SubscriptionMessage struct {
Data interface{} `json:"data,omitempty"`
Errors []interface{} `json:"errors,omitempty"`
}
SubscriptionMessage represents a message received from a subscription
type Summary ¶
type Summary struct {
TotalTypes int `json:"totalTypes"`
QueryType string `json:"queryType,omitempty"`
MutationType string `json:"mutationType,omitempty"`
SubscriptionType string `json:"subscriptionType,omitempty"`
}
Summary represents a schema summary
type TableFormatter ¶
type TableFormatter struct {
// contains filtered or unexported fields
}
TableFormatter implements Formatter for table output
func (*TableFormatter) FormatResponse ¶
func (f *TableFormatter) FormatResponse(response *Response, mode string) error
FormatResponse formats a GraphQL response
func (*TableFormatter) FormatStructured ¶
func (f *TableFormatter) FormatStructured(data interface{}, quiet bool) error
FormatStructured formats data as structured table output
func (*TableFormatter) FormatStructuredError ¶
func (f *TableFormatter) FormatStructuredError(err error, code string, quiet bool) error
FormatStructuredError formats an error as structured table output
func (*TableFormatter) FormatStructuredErrorWithContext ¶
func (f *TableFormatter) FormatStructuredErrorWithContext(err error, code string, errorType string, context map[string]interface{}, quiet bool) error
FormatStructuredErrorWithContext formats an error with additional context
func (*TableFormatter) SetErrorOutput ¶
func (f *TableFormatter) SetErrorOutput(writer io.Writer)
SetErrorOutput sets the error output writer for the formatter
func (*TableFormatter) SetOutput ¶
func (f *TableFormatter) SetOutput(writer io.Writer)
SetOutput sets the output writer for the formatter
type TypeDescription ¶
type TypeDescription struct {
Name string `json:"name"`
Kind string `json:"kind"`
Description string `json:"description,omitempty"`
Fields []FieldSummary `json:"fields,omitempty"`
InputFields []FieldSummary `json:"inputFields,omitempty"`
EnumValues []EnumValue `json:"enumValues,omitempty"`
}
TypeDescription represents a type description
type VersionInput ¶ added in v0.5.3
type VersionInput struct {
}
VersionInput defines the input schema for the version tool
type VersionOutput ¶ added in v0.5.3
type VersionOutput struct {
Version string `json:"version" jsonschema:"The current version of gqlt"`
}
VersionOutput defines the output schema for the version tool
type YAMLFormatter ¶
type YAMLFormatter struct {
// contains filtered or unexported fields
}
YAMLFormatter implements Formatter for YAML output
func (*YAMLFormatter) FormatResponse ¶
func (f *YAMLFormatter) FormatResponse(response *Response, mode string) error
FormatResponse formats a GraphQL response
func (*YAMLFormatter) FormatStructured ¶
func (f *YAMLFormatter) FormatStructured(data interface{}, quiet bool) error
FormatStructured formats data as structured YAML output
func (*YAMLFormatter) FormatStructuredError ¶
func (f *YAMLFormatter) FormatStructuredError(err error, code string, quiet bool) error
FormatStructuredError formats an error as structured YAML output
func (*YAMLFormatter) FormatStructuredErrorWithContext ¶
func (f *YAMLFormatter) FormatStructuredErrorWithContext(err error, code string, errorType string, context map[string]interface{}, quiet bool) error
FormatStructuredErrorWithContext formats an error with additional context
func (*YAMLFormatter) SetErrorOutput ¶
func (f *YAMLFormatter) SetErrorOutput(writer io.Writer)
SetErrorOutput sets the error output writer for the formatter
func (*YAMLFormatter) SetOutput ¶
func (f *YAMLFormatter) SetOutput(writer io.Writer)
SetOutput sets the output writer for the formatter