Documentation
ยถ
Overview ยถ
Package rocket provides developer-friendly GraphQL patterns for Go Bringing a modern, DX-focused approach to GraphQL development in Golang
Index ยถ
- Constants
- Variables
- func Handler(schema *Schema) httphandler.HandlerFunc
- func PlaygroundHandler(endpoint string) httphandler.HandlerFunc
- func PlaygroundHandlerWithType(endpoint string, playgroundType PlaygroundType) httphandler.HandlerFunc
- func WebSocketHandler(schema *Schema) httphandler.HandlerFunc
- type Config
- type EntityResolveFn
- type Error
- type FederationConfig
- type FieldResolveFn
- type ModuleResolvers
- type PlaygroundType
- type ResolveInfo
- type ResolveParams
- type ResolverRegistry
- type Result
- type Schema
- func (s *Schema) Execute(ctx context.Context, query string, variables map[string]interface{}, ...) *Result
- func (s *Schema) ExecuteSubscription(ctx context.Context, query string, variables map[string]interface{}, ...) (<-chan interface{}, error)
- func (s *Schema) GetContextBuilder() func(r *httphandler.Request) context.Context
- type SchemaCompiler
- type SubscriptionResolveFn
Constants ยถ
const (
DefaultPreserveOrder = true
)
Config defaults
Variables ยถ
var NewResolverRegistry = registry.NewResolverRegistry
NewResolverRegistry creates a new registry by merging module resolvers Re-exported from internal/registry for public API
var NewSchemaCompiler = compiler.NewSchemaCompiler
NewSchemaCompiler creates a new schema compiler Re-exported from internal/compiler for public API
Functions ยถ
func Handler ยถ
func Handler(schema *Schema) httphandler.HandlerFunc
Handler creates an HTTP handler for GraphQL requests Works with both net/http and Gin (via gin.WrapH)
func PlaygroundHandler ยถ
func PlaygroundHandler(endpoint string) httphandler.HandlerFunc
PlaygroundHandler creates an HTTP handler that serves a GraphQL playground Uses Apollo Sandbox by default (most modern and stable)
func PlaygroundHandlerWithType ยถ
func PlaygroundHandlerWithType(endpoint string, playgroundType PlaygroundType) httphandler.HandlerFunc
PlaygroundHandlerWithType creates a playground handler with a specific type
func WebSocketHandler ยถ added in v0.3.0
func WebSocketHandler(schema *Schema) httphandler.HandlerFunc
WebSocketHandler creates a WebSocket handler for GraphQL subscriptions This implements the graphql-ws protocol for real-time subscriptions
Types ยถ
type Config ยถ
type Config struct {
SchemaPath string // Path to the compiled schema.graphql file
EnablePlayground bool // Enable GraphQL playground (default: false)
ContextBuilder func(r *httphandler.Request) context.Context // Optional: Build custom context per-request (Apollo-style pattern)
Federation FederationConfig // Federation configuration
}
Config holds configuration for building a GraphQL schema
type EntityResolveFn ยถ added in v0.6.0
type EntityResolveFn = types.EntityResolveFn
EntityResolveFn is a function that resolves an entity from its representation Used for GraphQL Federation __resolveReference Re-exported from internal/types for public API
type FederationConfig ยถ added in v0.6.0
type FederationConfig struct {
Enabled bool // Enable GraphQL Federation support
ServiceName string // Optional: Name of this subgraph (for debugging/tracing)
}
FederationConfig holds federation-specific configuration
type FieldResolveFn ยถ
type FieldResolveFn = types.FieldResolveFn
FieldResolveFn is a function that resolves a field value Re-exported from internal/types for public API
type ModuleResolvers ยถ
type ModuleResolvers = types.ModuleResolvers
ModuleResolvers is the interface that all module resolvers must implement Re-exported from internal/types for public API
type PlaygroundType ยถ
type PlaygroundType string
PlaygroundType determines which playground interface to use
const ( PlaygroundTypeApolloSandbox PlaygroundType = PlaygroundType(rockethttp.PlaygroundTypeApolloSandbox) PlaygroundTypeGraphiQL PlaygroundType = PlaygroundType(rockethttp.PlaygroundTypeGraphiQL) PlaygroundTypePlayground PlaygroundType = PlaygroundType(rockethttp.PlaygroundTypePlayground) )
type ResolveInfo ยถ
type ResolveInfo = types.ResolveInfo
ResolveInfo contains metadata about the field being resolved Re-exported from internal/types for public API
type ResolveParams ยถ
type ResolveParams = types.ResolveParams
ResolveParams contains all the information for resolving a field Re-exported from internal/types for public API
type ResolverRegistry ยถ
type ResolverRegistry = registry.ResolverRegistry
ResolverRegistry holds all resolvers stitched together Re-exported from internal/registry for public API
type Result ยถ
Result represents the result of a GraphQL operation Re-exported from internal/types for public API
type Schema ยถ
type Schema struct {
// contains filtered or unexported fields
}
Schema represents a compiled and executable GraphQL schema
func BuildSchema ยถ
func BuildSchema(config Config, modules ...ModuleResolvers) (*Schema, error)
BuildSchema builds an executable GraphQL schema from .graphql file and module resolvers This is the main entry point for Rocket
func (*Schema) Execute ยถ
func (s *Schema) Execute(ctx context.Context, query string, variables map[string]interface{}, operationName string) *Result
Execute executes a GraphQL query/mutation Field order is always preserved for better developer experience
func (*Schema) ExecuteSubscription ยถ added in v0.3.0
func (s *Schema) ExecuteSubscription(ctx context.Context, query string, variables map[string]interface{}, operationName string) (<-chan interface{}, error)
ExecuteSubscription executes a GraphQL subscription and returns a channel of results This method is called by the WebSocket handler
func (*Schema) GetContextBuilder ยถ added in v0.4.0
func (s *Schema) GetContextBuilder() func(r *httphandler.Request) context.Context
GetContextBuilder returns the context builder function if configured This is used by the HTTP handler to build per-request context (Apollo-style pattern)
type SchemaCompiler ยถ
type SchemaCompiler = compiler.SchemaCompiler
SchemaCompiler compiles multiple .graphql files into a single schema Re-exported from internal/compiler for public API
type SubscriptionResolveFn ยถ added in v0.3.0
type SubscriptionResolveFn = types.SubscriptionResolveFn
SubscriptionResolveFn is a function that resolves a subscription field It returns a channel that emits values over time Re-exported from internal/types for public API