appsyncgraphql

package module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package appsyncgraphql routes native Lambda AppSync GraphQL invocations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AWSDate

func AWSDate(now time.Time, timezoneOffset ...float64) (string, error)

func AWSDateTime

func AWSDateTime(now time.Time, timezoneOffset ...float64) (string, error)

func AWSTime

func AWSTime(now time.Time, timezoneOffset ...float64) (string, error)

func AWSTimestamp

func AWSTimestamp(now time.Time) int64

AWSTimestamp floors seconds since the Unix epoch, including negative instants. Scalar helpers take an explicit clock value to keep applications deterministic.

func MakeID

func MakeID() (string, error)

MakeID returns a cryptographically random RFC 4122 version 4 identifier.

Types

type BatchOptions

type BatchOptions struct {
	Individual   bool
	ThrowOnError bool
}

BatchOptions defaults to aggregate execution, as in TypeScript. Individual selects sequential per-event execution; failures become null unless ThrowOnError.

type Event

type Event = map[string]any

Event retains unknown fields in a JSON-decoded AppSync event.

type ExceptionHandler

type ExceptionHandler func(context.Context, error) (any, error)

type Handler

type Handler func(ctx context.Context, input, event any) (any, error)

Handler receives arguments and the complete event. Aggregate batch handlers receive the complete event slice in both positions. Context is never replaced.

type InvalidBatchResponseException

type InvalidBatchResponseException struct {
	Message string
	Cause   error
}

InvalidBatchResponseException reports a non-array aggregate result.

func (*InvalidBatchResponseException) Error

func (*InvalidBatchResponseException) ErrorName

func (e *InvalidBatchResponseException) ErrorName() string

func (*InvalidBatchResponseException) Unwrap

type NamedError

type NamedError struct {
	Name, Message string
	Cause         error
}

NamedError supplies the reference error name without coupling to another utility.

func (*NamedError) Error

func (e *NamedError) Error() string

func (*NamedError) ErrorName

func (e *NamedError) ErrorName() string

func (*NamedError) Unwrap

func (e *NamedError) Unwrap() error

type Options

type Options struct {
	// Diagnostic runs outside registry locks and may be called concurrently.
	// Registration uses context.Background; invocation diagnostics retain context.
	Diagnostic func(ctx context.Context, level, message string, err error)
}

type Resolver

type Resolver struct{ *Router }

func New

func New(options Options) *Resolver

func (*Resolver) Resolve

func (r *Resolver) Resolve(ctx context.Context, input any) (any, error)

Resolve accepts decoded JSON events or batches. Invalid input returns nil after a warning. Handler errors become response envelopes except the two framework exceptions, which propagate to Lambda. Events are passed through without copying.

type ResolverNotFoundException

type ResolverNotFoundException struct {
	Message string
	Cause   error
}

ResolverNotFoundException bypasses registered exception handlers. Its concrete type name also preserves errorType in the Go Lambda Runtime API response.

func (*ResolverNotFoundException) Error

func (e *ResolverNotFoundException) Error() string

func (*ResolverNotFoundException) ErrorName

func (e *ResolverNotFoundException) ErrorName() string

func (*ResolverNotFoundException) Unwrap

func (e *ResolverNotFoundException) Unwrap() error

type Router

type Router struct {
	// contains filtered or unexported fields
}

Router owns ordered registries. Configure routes before serving requests. Concurrent lookups and registration are safe; inclusion copies registrations.

func NewRouter

func NewRouter(options Options) *Router

func (*Router) IncludeRouter

func (r *Router) IncludeRouter(routers ...*Router)

IncludeRouter merges in order, replacing collisions without sharing registries.

func (*Router) OnBatchMutation

func (r *Router) OnBatchMutation(field string, handler Handler, options ...BatchOptions)

func (*Router) OnBatchQuery

func (r *Router) OnBatchQuery(field string, handler Handler, options ...BatchOptions)

func (*Router) OnBatchResolver

func (r *Router) OnBatchResolver(typeName, field string, handler Handler, options ...BatchOptions)

func (*Router) OnException

func (r *Router) OnException(names []string, handler ExceptionHandler)

OnException registers exact error names, not inheritance or predicate matching.

func (*Router) OnMutation

func (r *Router) OnMutation(field string, handler Handler)

func (*Router) OnQuery

func (r *Router) OnQuery(field string, handler Handler)

func (*Router) OnResolver

func (r *Router) OnResolver(typeName, field string, handler Handler)

type TypeError

type TypeError struct{ Message string }

TypeError preserves the reference's empty-batch error name in the Lambda SDK.

func (*TypeError) Error

func (e *TypeError) Error() string

func (*TypeError) ErrorName

func (e *TypeError) ErrorName() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL