Documentation
¶
Overview ¶
Package graphql provides a GraphQL API adapter for CoreMCP. It can discover the schema via introspection and expose queries/mutations as MCP tools.
Index ¶
- func New(dsn string) (core.Source, error)
- type Field
- type FullType
- type GraphQLAdapter
- func (g *GraphQLAdapter) Close(_ context.Context) error
- func (g *GraphQLAdapter) Connect(ctx context.Context) error
- func (g *GraphQLAdapter) ExecuteProcedure(ctx context.Context, name string, params map[string]string) (*core.QueryResult, error)
- func (g *GraphQLAdapter) ExecuteQuery(ctx context.Context, query string, args ...any) (*core.QueryResult, error)
- func (g *GraphQLAdapter) GetOperations() []GraphQLOperation
- func (g *GraphQLAdapter) GetProcedures(_ context.Context) ([]core.StoredProcedure, error)
- func (g *GraphQLAdapter) GetSchema(_ context.Context) ([]core.TableSchema, error)
- func (g *GraphQLAdapter) GetSchemaDescription() string
- func (g *GraphQLAdapter) GetViews(_ context.Context) ([]core.ViewSchema, error)
- func (g *GraphQLAdapter) Name() string
- type GraphQLOperation
- type GraphQLSchema
- type InputValue
- type IntrospectionSchema
- type TypeDesc
- type TypeRef
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Field ¶
type Field struct {
Name string `json:"name"`
Description string `json:"description"`
Args []InputValue `json:"args"`
Type *TypeDesc `json:"type"`
IsDeprecated bool `json:"isDeprecated"`
DeprecationReason string `json:"deprecationReason"`
}
Field represents a field in a GraphQL type.
type FullType ¶
type FullType struct {
Kind string `json:"kind"`
Name string `json:"name"`
Description string `json:"description"`
Fields []Field `json:"fields"`
InputFields []InputValue `json:"inputFields"`
}
FullType represents a complete GraphQL type definition.
type GraphQLAdapter ¶
type GraphQLAdapter struct {
// contains filtered or unexported fields
}
GraphQLAdapter provides access to GraphQL APIs with schema introspection.
func (*GraphQLAdapter) ExecuteProcedure ¶
func (g *GraphQLAdapter) ExecuteProcedure(ctx context.Context, name string, params map[string]string) (*core.QueryResult, error)
ExecuteProcedure executes a GraphQL operation by name. Variable types are resolved from the introspected schema; falls back to String.
func (*GraphQLAdapter) ExecuteQuery ¶
func (g *GraphQLAdapter) ExecuteQuery(ctx context.Context, query string, args ...any) (*core.QueryResult, error)
ExecuteQuery runs a raw GraphQL query string.
func (*GraphQLAdapter) GetOperations ¶
func (g *GraphQLAdapter) GetOperations() []GraphQLOperation
GetOperations returns all available queries and mutations.
func (*GraphQLAdapter) GetProcedures ¶
func (g *GraphQLAdapter) GetProcedures(_ context.Context) ([]core.StoredProcedure, error)
GetProcedures returns available queries and mutations as procedures.
func (*GraphQLAdapter) GetSchema ¶
func (g *GraphQLAdapter) GetSchema(_ context.Context) ([]core.TableSchema, error)
GetSchema returns the discovered GraphQL types as "tables" for schema context.
func (*GraphQLAdapter) GetSchemaDescription ¶
func (g *GraphQLAdapter) GetSchemaDescription() string
GetSchemaDescription returns a human-readable description of the schema.
func (*GraphQLAdapter) GetViews ¶
func (g *GraphQLAdapter) GetViews(_ context.Context) ([]core.ViewSchema, error)
func (*GraphQLAdapter) Name ¶
func (g *GraphQLAdapter) Name() string
type GraphQLOperation ¶
type GraphQLOperation struct {
Name string
Type string // query, mutation, subscription
Description string
Fields []Field
ReturnType string
}
GraphQLOperation represents a discovered operation that can be exposed as an MCP tool.
type GraphQLSchema ¶
type GraphQLSchema struct {
Data struct {
Schema *IntrospectionSchema `json:"__schema"`
} `json:"data"`
}
GraphQLSchema represents the introspected GraphQL schema.
type InputValue ¶
type InputValue struct {
Name string `json:"name"`
Description string `json:"description"`
Type *TypeDesc `json:"type"`
DefaultValue *string `json:"defaultValue"`
}
InputValue represents an input value (argument or input field).
type IntrospectionSchema ¶
type IntrospectionSchema struct {
QueryType *TypeRef `json:"queryType"`
MutationType *TypeRef `json:"mutationType"`
SubscriptionType *TypeRef `json:"subscriptionType"`
Types []FullType `json:"types"`
Directives []map[string]interface{} `json:"directives"`
}
IntrospectionSchema represents the full GraphQL schema.