Documentation
¶
Index ¶
- func MapToModel(data map[string]interface{}, modelType reflect.Type) (interface{}, error)
- func ModelToMap(model interface{}) map[string]interface{}
- type BaseResolver
- func (br *BaseResolver) Create(ctx context.Context, input map[string]interface{}) (interface{}, error)
- func (br *BaseResolver) Delete(ctx context.Context, id string) (bool, error)
- func (br *BaseResolver) GetByID(ctx context.Context, id string) (interface{}, error)
- func (br *BaseResolver) List(ctx context.Context, limit, offset int) ([]interface{}, error)
- func (br *BaseResolver) Update(ctx context.Context, id string, input map[string]interface{}) (interface{}, error)
- type FieldInfo
- type GraphQLConfig
- type GraphQLContext
- type GraphQLIntegration
- func (gi *GraphQLIntegration) AddModel(model interface{}) error
- func (gi *GraphQLIntegration) AddModelFromName(modelName string, modelType interface{}) error
- func (gi *GraphQLIntegration) AddModelFromStruct(model interface{}) error
- func (gi *GraphQLIntegration) GenerateCompleteGraphQL(outputDir string) error
- func (gi *GraphQLIntegration) GenerateGQLGenConfig(outputDir string) error
- func (gi *GraphQLIntegration) GenerateSchema() (string, error)
- func (gi *GraphQLIntegration) GenerateSchemaFile(filename string) error
- func (gi *GraphQLIntegration) GetConfig() *GraphQLConfig
- func (gi *GraphQLIntegration) GetResolverRegistry() *ResolverRegistry
- func (gi *GraphQLIntegration) GetSchemaGenerator() *SchemaGenerator
- func (gi *GraphQLIntegration) GetServer() *SimpleGraphQLServer
- func (gi *GraphQLIntegration) RegisterResolver(modelName string, resolver Resolver)
- func (gi *GraphQLIntegration) RegisterRoutes(app *fiber.App) error
- func (gi *GraphQLIntegration) SetupServer() error
- type ModelInfo
- type RelationInfo
- type Resolver
- type ResolverRegistry
- type SchemaGenerator
- type SimpleGraphQLIntegration
- func (sgi *SimpleGraphQLIntegration) AddModel(model interface{}) error
- func (sgi *SimpleGraphQLIntegration) GenerateSchema() (string, error)
- func (sgi *SimpleGraphQLIntegration) GetConfig() *GraphQLConfig
- func (sgi *SimpleGraphQLIntegration) GetServer() *SimpleGraphQLServer
- func (sgi *SimpleGraphQLIntegration) RegisterRoutes(app *fiber.App) error
- func (sgi *SimpleGraphQLIntegration) SetupServer() error
- type SimpleGraphQLServer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MapToModel ¶
MapToModel converts a map to a model
func ModelToMap ¶
func ModelToMap(model interface{}) map[string]interface{}
ModelToMap converts a model to a map for GraphQL
Types ¶
type BaseResolver ¶
type BaseResolver struct {
// contains filtered or unexported fields
}
BaseResolver provides a base implementation for resolvers
func NewBaseResolver ¶
func NewBaseResolver(modelType reflect.Type, resolver Resolver) *BaseResolver
NewBaseResolver creates a new base resolver
func (*BaseResolver) Create ¶
func (br *BaseResolver) Create(ctx context.Context, input map[string]interface{}) (interface{}, error)
Create resolves create mutations
func (*BaseResolver) GetByID ¶
func (br *BaseResolver) GetByID(ctx context.Context, id string) (interface{}, error)
GetByID resolves single item queries
type FieldInfo ¶
type FieldInfo struct {
Name string `json:"name"`
Type string `json:"type"`
GraphQLType string `json:"graphql_type"`
Required bool `json:"required"`
Description string `json:"description"`
Tags string `json:"tags"`
}
FieldInfo represents information about a model field
type GraphQLConfig ¶
type GraphQLConfig struct {
Path string `json:"path"` // GraphQL endpoint path
Playground bool `json:"playground"` // Enable GraphQL playground
Introspection bool `json:"introspection"` // Enable introspection
ComplexityLimit int `json:"complexity_limit"` // Query complexity limit
}
GraphQLConfig holds configuration for GraphQL
func DefaultGraphQLConfig ¶
func DefaultGraphQLConfig() *GraphQLConfig
DefaultGraphQLConfig returns the default GraphQL configuration
type GraphQLContext ¶
type GraphQLContext struct {
UserID string
UserRole string
RequestID string
Data map[string]interface{}
}
GraphQLContext represents context for GraphQL operations
func (*GraphQLContext) GetData ¶
func (ctx *GraphQLContext) GetData(key string) interface{}
GetData returns custom data from context
func (*GraphQLContext) GetRequestID ¶
func (ctx *GraphQLContext) GetRequestID() string
GetRequestID returns the request ID from context
func (*GraphQLContext) GetUserID ¶
func (ctx *GraphQLContext) GetUserID() string
GetUserID returns the user ID from context
func (*GraphQLContext) GetUserRole ¶
func (ctx *GraphQLContext) GetUserRole() string
GetUserRole returns the user role from context
func (*GraphQLContext) SetData ¶
func (ctx *GraphQLContext) SetData(key string, value interface{})
SetData sets custom data in context
type GraphQLIntegration ¶
type GraphQLIntegration struct {
// contains filtered or unexported fields
}
GraphQLIntegration handles GraphQL integration with Mithril
func NewGraphQLIntegration ¶
func NewGraphQLIntegration(config *GraphQLConfig) *GraphQLIntegration
NewGraphQLIntegration creates a new GraphQL integration
func (*GraphQLIntegration) AddModel ¶
func (gi *GraphQLIntegration) AddModel(model interface{}) error
AddModel adds a model to the GraphQL schema
func (*GraphQLIntegration) AddModelFromName ¶
func (gi *GraphQLIntegration) AddModelFromName(modelName string, modelType interface{}) error
AddModelFromName adds a model by name (for dynamic model loading)
func (*GraphQLIntegration) AddModelFromStruct ¶
func (gi *GraphQLIntegration) AddModelFromStruct(model interface{}) error
AddModelFromStruct adds a model from a struct type
func (*GraphQLIntegration) GenerateCompleteGraphQL ¶
func (gi *GraphQLIntegration) GenerateCompleteGraphQL(outputDir string) error
GenerateCompleteGraphQL generates complete GraphQL setup
func (*GraphQLIntegration) GenerateGQLGenConfig ¶
func (gi *GraphQLIntegration) GenerateGQLGenConfig(outputDir string) error
GenerateGQLGenConfig generates gqlgen configuration
func (*GraphQLIntegration) GenerateSchema ¶
func (gi *GraphQLIntegration) GenerateSchema() (string, error)
GenerateSchema generates the GraphQL schema
func (*GraphQLIntegration) GenerateSchemaFile ¶
func (gi *GraphQLIntegration) GenerateSchemaFile(filename string) error
GenerateSchemaFile generates the GraphQL schema and saves it to a file
func (*GraphQLIntegration) GetConfig ¶
func (gi *GraphQLIntegration) GetConfig() *GraphQLConfig
GetConfig returns the GraphQL configuration
func (*GraphQLIntegration) GetResolverRegistry ¶
func (gi *GraphQLIntegration) GetResolverRegistry() *ResolverRegistry
GetResolverRegistry returns the resolver registry
func (*GraphQLIntegration) GetSchemaGenerator ¶
func (gi *GraphQLIntegration) GetSchemaGenerator() *SchemaGenerator
GetSchemaGenerator returns the schema generator
func (*GraphQLIntegration) GetServer ¶
func (gi *GraphQLIntegration) GetServer() *SimpleGraphQLServer
GetServer returns the GraphQL server
func (*GraphQLIntegration) RegisterResolver ¶
func (gi *GraphQLIntegration) RegisterResolver(modelName string, resolver Resolver)
RegisterResolver registers a resolver for a model
func (*GraphQLIntegration) RegisterRoutes ¶
func (gi *GraphQLIntegration) RegisterRoutes(app *fiber.App) error
RegisterRoutes registers GraphQL routes with Fiber
func (*GraphQLIntegration) SetupServer ¶
func (gi *GraphQLIntegration) SetupServer() error
SetupServer sets up the GraphQL server
type ModelInfo ¶
type ModelInfo struct {
Name string `json:"name"`
Fields []FieldInfo `json:"fields"`
Relations []RelationInfo `json:"relations"`
Directives map[string]interface{} `json:"directives"`
}
ModelInfo represents information about a model for GraphQL schema generation
type RelationInfo ¶
type RelationInfo struct {
Name string `json:"name"`
Type string `json:"type"` // "one", "many", "belongs_to", "has_many"
Target string `json:"target"` // Target model name
ForeignKey string `json:"foreign_key"`
}
RelationInfo represents information about model relations
type Resolver ¶
type Resolver interface {
// Query resolvers
GetByID(ctx context.Context, id string) (interface{}, error)
List(ctx context.Context, limit, offset int) ([]interface{}, error)
// Mutation resolvers
Create(ctx context.Context, input map[string]interface{}) (interface{}, error)
Update(ctx context.Context, id string, input map[string]interface{}) (interface{}, error)
Delete(ctx context.Context, id string) (bool, error)
}
Resolver interface defines methods for GraphQL resolvers
type ResolverRegistry ¶
type ResolverRegistry struct {
// contains filtered or unexported fields
}
ResolverRegistry manages GraphQL resolvers
func NewResolverRegistry ¶
func NewResolverRegistry() *ResolverRegistry
NewResolverRegistry creates a new resolver registry
func (*ResolverRegistry) GetAllResolvers ¶
func (rr *ResolverRegistry) GetAllResolvers() map[string]*BaseResolver
GetAllResolvers returns all registered resolvers
func (*ResolverRegistry) GetResolver ¶
func (rr *ResolverRegistry) GetResolver(modelName string) (*BaseResolver, bool)
GetResolver returns a resolver for a model
func (*ResolverRegistry) RegisterResolver ¶
func (rr *ResolverRegistry) RegisterResolver(modelName string, resolver *BaseResolver)
RegisterResolver registers a resolver for a model
type SchemaGenerator ¶
type SchemaGenerator struct {
// contains filtered or unexported fields
}
SchemaGenerator handles GraphQL schema generation
func NewSchemaGenerator ¶
func NewSchemaGenerator(config *GraphQLConfig) *SchemaGenerator
NewSchemaGenerator creates a new SchemaGenerator
func (*SchemaGenerator) AddModel ¶
func (sg *SchemaGenerator) AddModel(model interface{}) error
AddModel adds a model to the schema generator
func (*SchemaGenerator) GenerateSchema ¶
func (sg *SchemaGenerator) GenerateSchema() (string, error)
GenerateSchema generates a GraphQL schema from registered models
func (*SchemaGenerator) GetModel ¶
func (sg *SchemaGenerator) GetModel(name string) (ModelInfo, bool)
GetModel returns a specific model by name
func (*SchemaGenerator) GetModels ¶
func (sg *SchemaGenerator) GetModels() map[string]ModelInfo
GetModels returns all registered models
type SimpleGraphQLIntegration ¶
type SimpleGraphQLIntegration struct {
// contains filtered or unexported fields
}
SimpleGraphQLIntegration provides a simplified GraphQL integration
func NewSimpleGraphQLIntegration ¶
func NewSimpleGraphQLIntegration(config *GraphQLConfig) *SimpleGraphQLIntegration
NewSimpleGraphQLIntegration creates a new simple GraphQL integration
func (*SimpleGraphQLIntegration) AddModel ¶
func (sgi *SimpleGraphQLIntegration) AddModel(model interface{}) error
AddModel adds a model to the GraphQL schema
func (*SimpleGraphQLIntegration) GenerateSchema ¶
func (sgi *SimpleGraphQLIntegration) GenerateSchema() (string, error)
GenerateSchema generates the GraphQL schema
func (*SimpleGraphQLIntegration) GetConfig ¶
func (sgi *SimpleGraphQLIntegration) GetConfig() *GraphQLConfig
GetConfig returns the GraphQL configuration
func (*SimpleGraphQLIntegration) GetServer ¶
func (sgi *SimpleGraphQLIntegration) GetServer() *SimpleGraphQLServer
GetServer returns the GraphQL server
func (*SimpleGraphQLIntegration) RegisterRoutes ¶
func (sgi *SimpleGraphQLIntegration) RegisterRoutes(app *fiber.App) error
RegisterRoutes registers GraphQL routes with Fiber
func (*SimpleGraphQLIntegration) SetupServer ¶
func (sgi *SimpleGraphQLIntegration) SetupServer() error
SetupServer sets up the GraphQL server
type SimpleGraphQLServer ¶
type SimpleGraphQLServer struct {
// contains filtered or unexported fields
}
SimpleGraphQLServer provides a basic GraphQL implementation
func NewSimpleGraphQLServer ¶
func NewSimpleGraphQLServer(config *GraphQLConfig, schema string) *SimpleGraphQLServer
NewSimpleGraphQLServer creates a new simple GraphQL server
func (*SimpleGraphQLServer) GetConfig ¶
func (sgs *SimpleGraphQLServer) GetConfig() *GraphQLConfig
GetConfig returns the GraphQL configuration
func (*SimpleGraphQLServer) GetSchema ¶
func (sgs *SimpleGraphQLServer) GetSchema() string
GetSchema returns the GraphQL schema
func (*SimpleGraphQLServer) RegisterRoutes ¶
func (sgs *SimpleGraphQLServer) RegisterRoutes(app *fiber.App)
RegisterRoutes registers GraphQL routes with Fiber
func (*SimpleGraphQLServer) SetSchema ¶
func (sgs *SimpleGraphQLServer) SetSchema(schema string)
SetSchema sets the GraphQL schema