Help us shape the future of Go! Take the 2026 Go Developer Survey

appsync

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 34 Imported by: 0

Documentation

Overview

Package appsync emulates AWS AppSync GraphQL APIs: the REST-JSON control plane (APIs, API keys, schemas, data sources, functions, resolvers), the GraphQL endpoint on <apiId>.appsync-api.localhost that runs VTL and APPSYNC_JS resolvers against Lambda, DynamoDB, HTTP, RDS and NONE data sources, and real-time subscriptions on <apiId>.appsync-realtime-api.localhost.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	ID        string                 `json:"id"`
	Account   string                 `json:"account"`
	Region    string                 `json:"region"`
	Config    apiConfig              `json:"config"`
	Tags      map[string]string      `json:"tags,omitempty"`
	SDL       string                 `json:"sdl,omitempty"`
	Status    string                 `json:"status,omitempty"` // schema creation: SUCCESS or FAILED
	Details   string                 `json:"details,omitempty"`
	Keys      map[string]*APIKey     `json:"keys"`
	Sources   map[string]*DataSource `json:"sources"`
	Functions map[string]*Function   `json:"functions"`
	Resolvers map[string]*Resolver   `json:"resolvers"` // by Type.field
	// contains filtered or unexported fields
}

API is a GraphQL API and everything attached to it. Its nested values are replaced, never changed in place, so a request can run on a snapshot.

type APIKey

type APIKey struct {
	ID          string `json:"id"`
	Description string `json:"description,omitempty"`
	Expires     int64  `json:"expires"`
	Deletes     int64  `json:"deletes"`
}

APIKey is an API key; its id is the key.

type DataSource

type DataSource struct {
	DataSourceArn            string          `json:"dataSourceArn"`
	Name                     string          `json:"name"`
	Description              string          `json:"description,omitempty"`
	Type                     string          `json:"type"`
	ServiceRoleArn           string          `json:"serviceRoleArn,omitempty"`
	DynamodbConfig           json.RawMessage `json:"dynamodbConfig,omitempty"`
	LambdaConfig             json.RawMessage `json:"lambdaConfig,omitempty"`
	ElasticsearchConfig      json.RawMessage `json:"elasticsearchConfig,omitempty"`
	OpenSearchServiceConfig  json.RawMessage `json:"openSearchServiceConfig,omitempty"`
	HttpConfig               json.RawMessage `json:"httpConfig,omitempty"`
	RelationalDatabaseConfig json.RawMessage `json:"relationalDatabaseConfig,omitempty"`
	EventBridgeConfig        json.RawMessage `json:"eventBridgeConfig,omitempty"`
	MetricsConfig            string          `json:"metricsConfig,omitempty"`
}

DataSource is a data source; its configs are kept as sent.

type Function

type Function struct {
	FunctionId              string          `json:"functionId"`
	FunctionArn             string          `json:"functionArn"`
	Name                    string          `json:"name"`
	Description             string          `json:"description,omitempty"`
	DataSourceName          string          `json:"dataSourceName"`
	RequestMappingTemplate  string          `json:"requestMappingTemplate,omitempty"`
	ResponseMappingTemplate string          `json:"responseMappingTemplate,omitempty"`
	FunctionVersion         string          `json:"functionVersion,omitempty"`
	SyncConfig              json.RawMessage `json:"syncConfig,omitempty"`
	MaxBatchSize            int             `json:"maxBatchSize,omitempty"`
	Runtime                 *runtime        `json:"runtime,omitempty"`
	Code                    string          `json:"code,omitempty"`
}

Function is a pipeline function.

type Resolver

type Resolver struct {
	TypeName                string          `json:"typeName"`
	FieldName               string          `json:"fieldName"`
	DataSourceName          string          `json:"dataSourceName,omitempty"`
	ResolverArn             string          `json:"resolverArn"`
	RequestMappingTemplate  string          `json:"requestMappingTemplate,omitempty"`
	ResponseMappingTemplate string          `json:"responseMappingTemplate,omitempty"`
	Kind                    string          `json:"kind"`
	PipelineConfig          *pipeline       `json:"pipelineConfig,omitempty"`
	SyncConfig              json.RawMessage `json:"syncConfig,omitempty"`
	CachingConfig           json.RawMessage `json:"cachingConfig,omitempty"`
	MaxBatchSize            int             `json:"maxBatchSize,omitempty"`
	Runtime                 *runtime        `json:"runtime,omitempty"`
	Code                    string          `json:"code,omitempty"`
	MetricsConfig           string          `json:"metricsConfig,omitempty"`
}

Resolver attaches a data source (UNIT) or functions (PIPELINE) to a field.

type Service

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

Service is the AppSync emulator.

func New

func New(hub *core.Hub) *Service

New creates the AppSync service.

func (*Service) Close

func (s *Service) Close() error

Close ends the real-time connections.

func (*Service) Info

func (s *Service) Info() core.Info

func (*Service) Inspect

func (s *Service) Inspect(table, id string) any

Inspect returns an API with its schema, keys, data sources, functions and resolvers.

func (*Service) Load

func (s *Service) Load(b []byte) error

func (*Service) Reset

func (s *Service) Reset()

func (*Service) Resources

func (s *Service) Resources() []core.Table

Resources lists the GraphQL APIs.

func (*Service) Save

func (s *Service) Save() ([]byte, error)

func (*Service) ServeHTTP

func (s *Service) ServeHTTP(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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