Documentation
¶
Overview ¶
Package graphql provides Golem's bounded caller-only GraphQL transport. The generated application supplies the identity-aware executor; this package owns HTTP, request isolation, principal extraction, limits, and safe errors.
Index ¶
- func CustomArgumentValue[T any](arguments []CustomArgument, name string) (T, bool)
- func ResolvePreparedField[T any](ctx context.Context, parent PreparedObject) (T, error)
- func ResolvePreparedRoot[T any](ctx context.Context) (T, error)
- func ResolvePreparedSubscriptionRoot[T any](ctx context.Context) (<-chan T, error)
- type BeginCaller
- type CallerAnalyticsExecution
- type CallerCustomExecution
- type CallerEventExecution
- type CallerExecution
- type CallerMutationExecution
- type ComputedArgument
- type ComputedBatchFunc
- type ComputedBatchParent
- type ComputedBatchResult
- type ComputedBinding
- func BindBatchedComputed(extensionID string, cacheKey ComputedCacheKeyFunc, batch ComputedBatchFunc) (ComputedBinding, error)
- func BindComputed(extensionID string, resolve ComputedResolveFunc) (ComputedBinding, error)
- func BindGeneratedBatchedComputed[M any, K comparable, A, R any](extensionID string, descriptor golem.ModelDescriptor[M], ...) (ComputedBinding, error)
- func BindGeneratedComputed[M, A, R any](extensionID string, descriptor golem.ModelDescriptor[M], ...) (ComputedBinding, error)
- type ComputedCacheKeyFunc
- type ComputedRequest
- type ComputedResolveFunc
- type Config
- type CustomArgument
- type CustomArgumentDecoder
- type CustomBinding
- func BindCustomMutation[C, A, R any](spec CustomBindingSpec, decode CustomArgumentDecoder[A], ...) (CustomBinding, error)
- func BindCustomQuery[C, A, R any](spec CustomBindingSpec, decode CustomArgumentDecoder[A], ...) (CustomBinding, error)
- func BindGeneratedCustomMutationContract[C, A, R any](bundle golem.SchemaBundle, spec CustomBindingSpec, ...) (CustomBinding, error)
- func BindGeneratedCustomMutationModelContract[M, C, A, R any](bundle golem.SchemaBundle, spec CustomBindingSpec, _ golem.ModelDescriptor[M], ...) (CustomBinding, error)
- func BindGeneratedCustomQueryContract[C, A, R any](bundle golem.SchemaBundle, spec CustomBindingSpec, ...) (CustomBinding, error)
- func BindGeneratedCustomQueryModelContract[M, C, A, R any](bundle golem.SchemaBundle, spec CustomBindingSpec, _ golem.ModelDescriptor[M], ...) (CustomBinding, error)
- type CustomBindingSpec
- type CustomCallerCapability
- type CustomOperation
- type CustomRegistry
- type CustomResult
- type CustomResultEncoder
- type Error
- type EventStream
- type Executor
- type GeneratedCustomArgumentConversion
- func GeneratedCustomMutationInputArgument[M any](descriptor golem.ModelDescriptor[M], kind golem.RuntimeMutationInputKind) GeneratedCustomArgumentConversion
- func GeneratedCustomPredicateArgument[M any](descriptor golem.ModelDescriptor[M]) GeneratedCustomArgumentConversion
- func GeneratedCustomSelectorArgument[M any](descriptor golem.ModelDescriptor[M]) GeneratedCustomArgumentConversion
- type GeneratedEvent
- type GeneratedExecutorConfig
- type Limits
- type Operation
- type PreparedInput
- type PreparedObject
- type Request
- type Response
- type ResponseStream
- type Server
- func (server *Server[P]) ContractFingerprint() golem.SchemaDigest
- func (server *Server[P]) Execute(ctx context.Context, principal P, request Request) (response Response)
- func (server *Server[P]) Handler() http.Handler
- func (server *Server[P]) SDL() string
- func (server *Server[P]) Shutdown(ctx context.Context) (resultErr error)
- type SubscriptionExecutor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CustomArgumentValue ¶
func CustomArgumentValue[T any](arguments []CustomArgument, name string) (T, bool)
func ResolvePreparedField ¶
func ResolvePreparedField[T any](ctx context.Context, parent PreparedObject) (T, error)
ResolvePreparedField is used only by generated gqlgen object resolvers. The parent contains occurrence-aware response names, so aliases and repeated relation selections remain independent.
func ResolvePreparedRoot ¶
ResolvePreparedRoot is used only by generated gqlgen root resolvers. It returns the value which Golem already compiled, authorized, and executed for the current response occurrence.
func ResolvePreparedSubscriptionRoot ¶
ResolvePreparedSubscriptionRoot presents one already prepared event through gqlgen's native subscription resolver contract. The protocol loop invokes a fresh executable response handler per event, so this channel contains exactly one value and never owns the long-lived application event stream.
Types ¶
type BeginCaller ¶
type BeginCaller[P any] func(context.Context, P) (CallerExecution, error)
type CallerAnalyticsExecution ¶
type CallerAnalyticsExecution interface {
ExecuteFrozenAnalytics(context.Context, golem.FrozenAnalyticsRequest) ([][]golem.RuntimeAnalyticsCell, error)
}
CallerAnalyticsExecution is required only when the selected operation contains an explicitly generated P6 analytics root.
type CallerCustomExecution ¶
type CallerCustomExecution struct {
// contains filtered or unexported fields
}
func (*CallerCustomExecution) Execute ¶
func (execution *CallerCustomExecution) Execute(ctx context.Context, operation CustomOperation, name string, arguments map[string]any) (CustomResult, error)
Execute invokes the matched generated resolver exactly once. Mutation execution deliberately adds no implicit transaction and performs no replay.
type CallerEventExecution ¶
type CallerEventExecution interface {
SubscribeFrozenEvents(context.Context, golem.FrozenReadRequest, bool) (EventStream, error)
}
CallerEventExecution is the generated caller-only capability used by P7. System and transaction clients deliberately do not implement it.
type CallerExecution ¶
type CallerExecution interface {
ExecuteFrozenRead(context.Context, golem.FrozenReadRequest) ([]golem.RuntimeModelRow, error)
}
CallerExecution is the caller-only runtime capability accepted by generated GraphQL. *runtime.Caller implements it directly; System deliberately does not. One instance is created and shared by all roots in one operation.
type CallerMutationExecution ¶
type CallerMutationExecution interface {
ExecuteFrozenMutation(context.Context, golem.RuntimeMutationRequest) (golem.RuntimeMutationResult, error)
}
CallerMutationExecution is the caller-only mutation capability consumed by generated GraphQL. runtime.CallerMutationExecution implements it; System deliberately cannot.
type ComputedArgument ¶
ComputedArgument is one already-coerced argument supplied to generated application glue. Value has the exact declared Go scalar/list representation.
type ComputedBatchFunc ¶
type ComputedBatchFunc func(context.Context, []ComputedBatchParent, []ComputedArgument) (map[string]ComputedBatchResult, error)
type ComputedBatchParent ¶
type ComputedBatchParent struct {
// contains filtered or unexported fields
}
func (ComputedBatchParent) CacheKey ¶
func (value ComputedBatchParent) CacheKey() string
func (ComputedBatchParent) Parent ¶
func (value ComputedBatchParent) Parent() golem.RuntimeModelRow
type ComputedBatchResult ¶
type ComputedBinding ¶
type ComputedBinding struct {
// contains filtered or unexported fields
}
ComputedBinding is an opaque generated binding. Constructors are the only way to create one, keeping the executor-facing capability closed and small.
func BindBatchedComputed ¶
func BindBatchedComputed(extensionID string, cacheKey ComputedCacheKeyFunc, batch ComputedBatchFunc) (ComputedBinding, error)
func BindComputed ¶
func BindComputed(extensionID string, resolve ComputedResolveFunc) (ComputedBinding, error)
func BindGeneratedBatchedComputed ¶
func BindGeneratedBatchedComputed[M any, K comparable, A, R any](extensionID string, descriptor golem.ModelDescriptor[M], key golem.ScalarColumn[M, K], loader func(context.Context, []K, A) (map[K]R, error), codec func(K) (string, error)) (ComputedBinding, error)
BindGeneratedBatchedComputed performs one typed loader invocation per runtime batch and erases only the Row model witness from object results.
func BindGeneratedComputed ¶
func BindGeneratedComputed[M, A, R any](extensionID string, descriptor golem.ModelDescriptor[M], resolver func(context.Context, golem.Row[M], A) (R, error)) (ComputedBinding, error)
BindGeneratedComputed is the generated-code bridge from a statically checked model method to the closed runtime binding. Its type parameters are inferred from the method value, so generated code never has to reconstruct an Args type name from source text.
type ComputedCacheKeyFunc ¶
type ComputedRequest ¶
type ComputedRequest struct {
Parent golem.RuntimeModelRow
Arguments []ComputedArgument
}
ComputedRequest contains only the masked dependency row and typed arguments. It deliberately carries no caller, database, system, or transaction handle.
type ComputedResolveFunc ¶
type ComputedResolveFunc func(context.Context, ComputedRequest) (any, error)
type Config ¶
type Config[P any] struct { PrincipalFromContext func(context.Context) (P, bool) Limits Limits Introspection bool ContractFingerprint golem.SchemaDigest ReportInternalError func(context.Context, error) ExecutableSchema gqlgengraphql.ExecutableSchema EventLimits events.Limits Observer observe.Observer Provider golem.Provider WebSocketInit func(context.Context, json.RawMessage) (context.Context, error) }
type CustomArgument ¶
type CustomArgument struct {
// contains filtered or unexported fields
}
CustomArgument is one already-coerced exact value in declaration order. Generated glue converts it into the statically known application Args field.
func (CustomArgument) Name ¶
func (argument CustomArgument) Name() string
func (CustomArgument) Value ¶
func (argument CustomArgument) Value() any
type CustomArgumentDecoder ¶
type CustomArgumentDecoder[A any] func([]CustomArgument) (A, error)
type CustomBinding ¶
type CustomBinding struct {
// contains filtered or unexported fields
}
CustomBinding is opaque generated glue. Its invocation receives exactly the caller object supplied for this execution; no System/DB/Tx/raw-SQL channel is present in the registry API. Explicit transactions remain methods on Caller.
func BindCustomMutation ¶
func BindCustomMutation[C, A, R any](spec CustomBindingSpec, decode CustomArgumentDecoder[A], resolver func(context.Context, C, A) (R, error), encode CustomResultEncoder[R]) (CustomBinding, error)
func BindCustomQuery ¶
func BindCustomQuery[C, A, R any](spec CustomBindingSpec, decode CustomArgumentDecoder[A], resolver func(context.Context, C, A) (R, error), encode CustomResultEncoder[R]) (CustomBinding, error)
func BindGeneratedCustomMutationContract ¶
func BindGeneratedCustomMutationContract[C, A, R any](bundle golem.SchemaBundle, spec CustomBindingSpec, resolver func(context.Context, C, A) (R, error), conversions ...GeneratedCustomArgumentConversion) (CustomBinding, error)
func BindGeneratedCustomMutationModelContract ¶
func BindGeneratedCustomMutationModelContract[M, C, A, R any](bundle golem.SchemaBundle, spec CustomBindingSpec, _ golem.ModelDescriptor[M], resolver func(context.Context, C, A) (R, error), conversions ...GeneratedCustomArgumentConversion) (CustomBinding, error)
func BindGeneratedCustomQueryContract ¶
func BindGeneratedCustomQueryContract[C, A, R any](bundle golem.SchemaBundle, spec CustomBindingSpec, resolver func(context.Context, C, A) (R, error), conversions ...GeneratedCustomArgumentConversion) (CustomBinding, error)
The Contract variants are emitted by golem generate. They recursively normalize typed Go results against the canonical result tree before the strict custom registry validates them; no JSON or floating conversion is used as a shortcut.
func BindGeneratedCustomQueryModelContract ¶
func BindGeneratedCustomQueryModelContract[M, C, A, R any](bundle golem.SchemaBundle, spec CustomBindingSpec, _ golem.ModelDescriptor[M], resolver func(context.Context, C, A) (R, error), conversions ...GeneratedCustomArgumentConversion) (CustomBinding, error)
type CustomBindingSpec ¶
CustomBindingSpec is emitted from one statically interpreted AttachedMethod. The runtime registry matches every field against canonical ContractIR before any resolver becomes callable.
type CustomCallerCapability ¶
type CustomCallerCapability interface {
GolemGraphQLCallerCapability()
}
CustomCallerCapability is implemented by runtime Caller and by the generated application Caller wrapper. System, DB, and transaction handles do not implement it and therefore cannot be installed into custom execution.
type CustomOperation ¶
type CustomOperation string
CustomOperation is the closed public custom-root vocabulary.
const ( CustomQuery CustomOperation = "query" CustomMutation CustomOperation = "mutation" )
type CustomRegistry ¶
type CustomRegistry struct {
// contains filtered or unexported fields
}
CustomRegistry is immutable process-wide binding metadata. ForCaller creates a request-scoped execution carrying only the generated caller value.
func NewCustomRegistry ¶
func NewCustomRegistry(bundle golem.SchemaBundle, supplied ...CustomBinding) (*CustomRegistry, error)
func (*CustomRegistry) ForCaller ¶
func (registry *CustomRegistry) ForCaller(caller CustomCallerCapability) (*CallerCustomExecution, error)
type CustomResult ¶
type CustomResult struct {
// contains filtered or unexported fields
}
func (CustomResult) Value ¶
func (result CustomResult) Value() any
type CustomResultEncoder ¶
type Error ¶
type Error struct {
Message string `json:"message"`
Path []any `json:"path,omitempty"`
Extensions map[string]any `json:"extensions"`
}
func PresentError ¶
func PresentError(ctx context.Context, err error, path []any, report func(context.Context, error)) Error
PresentError maps Golem's transport-neutral public failures without exposing wrapped policy, SQL, driver, file, or stack details. Unknown failures are reported through the trusted callback and presented as INTERNAL_SERVER_ERROR.
type EventStream ¶
type EventStream interface {
Recv(context.Context) (GeneratedEvent, error)
Close() error
}
func AdaptGeneratedEventStream ¶
func AdaptGeneratedEventStream[E any](source golem.EventStream[E], adapt func(E) (GeneratedEvent, error)) (EventStream, error)
type Executor ¶
func NewGeneratedExecutor ¶
func NewGeneratedExecutor[P any](config GeneratedExecutorConfig[P]) (Executor[P], error)
type GeneratedCustomArgumentConversion ¶
func GeneratedCustomMutationInputArgument ¶
func GeneratedCustomMutationInputArgument[M any](descriptor golem.ModelDescriptor[M], kind golem.RuntimeMutationInputKind) GeneratedCustomArgumentConversion
func GeneratedCustomPredicateArgument ¶
func GeneratedCustomPredicateArgument[M any](descriptor golem.ModelDescriptor[M]) GeneratedCustomArgumentConversion
func GeneratedCustomSelectorArgument ¶
func GeneratedCustomSelectorArgument[M any](descriptor golem.ModelDescriptor[M]) GeneratedCustomArgumentConversion
type GeneratedEvent ¶
type GeneratedEvent struct {
// contains filtered or unexported fields
}
func NewGeneratedEvent ¶
func NewGeneratedEvent(metadata golem.EventMetadata, identity []any, entity *golem.RuntimeModelRow) (GeneratedEvent, error)
type GeneratedExecutorConfig ¶
type GeneratedExecutorConfig[P any] struct { Bundle golem.SchemaBundle Limits Limits BeginCaller BeginCaller[P] ComputedBindings []ComputedBinding CustomBindings []CustomBinding ReportInternalError func(context.Context, error) }
type Limits ¶
type Limits struct {
MaxRequestBytes, MaxVariableBytes, MaxTokens, MaxASTNodes, MaxFragments int
MaxDepth, MaxSelectedFields, MaxAliases, MaxInputDepth, MaxInputNodes int
MaxListItems, MaxComplexity, MaxPageSize, MaxResolverConcurrency, MaxComputedBatchSize int
MaxGroups int
}
func NormalizeLimits ¶
type Operation ¶
type Operation struct {
Document *ast.QueryDocument
Definition *ast.OperationDefinition
Variables map[string]any
}
type PreparedInput ¶
PreparedInput is the gqlgen-only typed wrapper for already validated input objects. Golem binds the original operation AST before this representation is decoded, so generated resolvers never treat it as backend authority.
type PreparedObject ¶
PreparedObject is the generated executable's opaque view of one already authorized and selected Golem result object. Generated resolvers are the only intended consumers. Values remain in their exact, provider-neutral wire representation; in particular, they are never JSON-round-tripped.
type ResponseStream ¶
type Server ¶
type Server[P any] struct { // contains filtered or unexported fields }
func (*Server[P]) ContractFingerprint ¶
func (server *Server[P]) ContractFingerprint() golem.SchemaDigest
func (*Server[P]) Execute ¶
func (server *Server[P]) Execute(ctx context.Context, principal P, request Request) (response Response)
Execute applies the same parse, validation, coercion, limit, isolation, and panic boundary used by Handler without re-resolving an already trusted principal. It is the direct-execution surface used by tests and embedding.