Documentation
¶
Overview ¶
Package graphgateway provides the graph-gateway component for exposing graph operations via HTTP.
Package graphgateway provides the graph-gateway component for exposing graph operations via HTTP protocols including GraphQL and MCP.
Overview ¶
The graph-gateway component serves as the external access layer for the knowledge graph. It provides HTTP endpoints for querying entities, triples, and graph analytics, as well as submitting mutations via NATS.
Component Interface ¶
This component implements the semstreams component framework:
- component.Discoverable (6 methods): Meta, InputPorts, OutputPorts, ConfigSchema, Health, DataFlow
- component.LifecycleComponent (3 methods): Initialize, Start, Stop
- gateway.Gateway (1 method): RegisterHTTPHandlers
Communication Patterns ¶
Inputs:
- HTTP requests on /graphql: GraphQL queries and mutations
- HTTP requests on /mcp: Model Context Protocol operations
Outputs:
- NATS requests to graph.mutation.*: Mutations forwarded to graph-ingest
Internal Reads (via QueryManager):
- ENTITY_STATES: Entity data
- OUTGOING_INDEX, INCOMING_INDEX: Graph traversal
- ALIAS_INDEX, PREDICATE_INDEX: Lookups
- EMBEDDINGS_CACHE: Vector similarity (semantic tier)
- COMMUNITY_INDEX: Clustering results (semantic tier)
- ANOMALY_INDEX: Structural anomalies for inference endpoints
HTTP Endpoints ¶
GraphQL (/graphql):
- Query entities, triples, and relationships
- Perform graph traversals and analytics
- Submit mutations (forwarded to graph-ingest via NATS)
MCP (/mcp):
- Model Context Protocol for LLM tool integration
- Provides structured graph operations for AI agents
Inference (/inference/*):
- List pending anomalies for human review
- Get anomaly details and submit review decisions
- View inference statistics
Playground (/ when enabled):
- Interactive GraphQL IDE for development
Configuration ¶
Key configuration options:
- graphql_path: GraphQL endpoint path (default: /graphql)
- mcp_path: MCP endpoint path (default: /mcp)
- bind_address: HTTP server address (default: localhost:8080)
- enable_playground: Enable GraphQL playground (default: false)
Tiered Deployment ¶
The graph-gateway component is typically required in all tiers as the external access point. In production, it should be deployed behind a load balancer with appropriate authentication.
Usage ¶
// Register the component
registry := component.NewRegistry()
graphgateway.Register(registry)
// Create via factory
comp, err := graphgateway.CreateGraphGateway(configJSON, deps)
if err != nil {
log.Fatal(err)
}
// Register HTTP handlers
mux := http.NewServeMux()
comp.(gateway.Gateway).RegisterHTTPHandlers("/api", mux)
// Lifecycle management
comp.Initialize()
comp.Start(ctx)
defer comp.Stop(5 * time.Second)
Index ¶
- func CreateGraphGateway(rawConfig json.RawMessage, deps component.Dependencies) (component.Discoverable, error)
- func Register(registry *component.Registry) error
- type Component
- func (c *Component) ConfigSchema() component.ConfigSchema
- func (c *Component) DataFlow() component.FlowMetrics
- func (c *Component) Health() component.HealthStatus
- func (c *Component) Initialize() error
- func (c *Component) InputPorts() []component.Port
- func (c *Component) Meta() component.Metadata
- func (c *Component) OpenAPISpec() *service.OpenAPISpec
- func (c *Component) OutputPorts() []component.Port
- func (c *Component) RegisterHTTPHandlers(prefix string, mux *http.ServeMux)
- func (c *Component) Start(ctx context.Context) error
- func (c *Component) Stop(timeout time.Duration) error
- type Config
- type GraphQLRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateGraphGateway ¶
func CreateGraphGateway(rawConfig json.RawMessage, deps component.Dependencies) (component.Discoverable, error)
CreateGraphGateway is the factory function for creating graph-gateway components
Types ¶
type Component ¶
type Component struct {
// contains filtered or unexported fields
}
Component implements the graph-gateway gateway
func (*Component) ConfigSchema ¶
func (c *Component) ConfigSchema() component.ConfigSchema
ConfigSchema returns the configuration schema
func (*Component) DataFlow ¶
func (c *Component) DataFlow() component.FlowMetrics
DataFlow returns current data flow metrics
func (*Component) Health ¶
func (c *Component) Health() component.HealthStatus
Health returns current health status
func (*Component) Initialize ¶
Initialize validates configuration and sets up ports (no I/O)
func (*Component) InputPorts ¶
InputPorts returns input port definitions. Reads directly from config so ports are available before Initialize().
func (*Component) OpenAPISpec ¶
func (c *Component) OpenAPISpec() *service.OpenAPISpec
OpenAPISpec implements gateway.OpenAPIProvider interface.
func (*Component) OutputPorts ¶
OutputPorts returns output port definitions. Reads directly from config so ports are available before Initialize().
func (*Component) RegisterHTTPHandlers ¶
RegisterHTTPHandlers registers HTTP handlers with the provided mux
type Config ¶
type Config struct {
Ports *component.PortConfig `json:"ports" schema:"type:ports,description:Port configuration,category:basic"`
GraphQLPath string `json:"graphql_path" schema:"type:string,description:GraphQL endpoint path,category:basic"`
MCPPath string `json:"mcp_path" schema:"type:string,description:MCP endpoint path,category:basic"`
BindAddress string `json:"bind_address" schema:"type:string,description:HTTP server bind address,category:basic"`
EnablePlayground bool `json:"enable_playground" schema:"type:bool,description:Enable GraphQL playground,category:basic"`
EnableInferenceAPI bool `json:"enable_inference_api" schema:"type:bool,description:Enable inference API for anomaly review,category:basic"`
QueryTimeout time.Duration `json:"query_timeout" schema:"type:duration,description:Query timeout duration,category:basic"`
DomainExamplesPath string `` /* 127-byte string literal not displayed */
EnableEmbeddingClassifier bool `` /* 141-byte string literal not displayed */
}
Config holds configuration for graph-gateway component
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a valid default configuration
func (*Config) ApplyDefaults ¶
func (c *Config) ApplyDefaults()
ApplyDefaults sets default values for configuration
type GraphQLRequest ¶
type GraphQLRequest struct {
Query string `json:"query"`
Variables map[string]any `json:"variables,omitempty"`
}
GraphQLRequest represents the request body for GraphQL queries.