appsync

package
v0.0.1-alpha.30 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: MIT Imports: 38 Imported by: 0

Documentation

Overview

Package appsync provides emulation of AWS AppSync (managed GraphQL).

Implemented: GraphQL API CRUD, schema upload/status, API key CRUD, data source CRUD, function CRUD, resolver CRUD, tagging, GraphQL query and mutation execution (NONE/HTTP/Lambda/DynamoDB data sources, UNIT and PIPELINE resolvers, VTL and APPSYNC_JS runtimes, full authentication), EvaluateMappingTemplate, EvaluateCode, real-time WebSocket subscriptions, merged API management (source API associations, schema merging), Events API (CRUD + channel namespace management).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiAssociation

type ApiAssociation struct {
	DomainName        string `json:"domainName"`
	ApiId             string `json:"apiId"`
	AssociationStatus string `json:"associationStatus"` // PROCESSING, SUCCESS, FAILED.
	DeploymentDetail  string `json:"deploymentDetail,omitempty"`
}

ApiAssociation maps a custom domain name to a GraphQL API.

type ApiCacheConfig

type ApiCacheConfig struct {
	ApiId                    string `json:"apiId,omitempty"`
	Type                     string `json:"type"`               // T2_SMALL, T2_MEDIUM, etc.
	ApiCachingBehavior       string `json:"apiCachingBehavior"` // FULL_REQUEST_CACHING, PER_RESOLVER_CACHING.
	TransitEncryptionEnabled bool   `json:"transitEncryptionEnabled"`
	AtRestEncryptionEnabled  bool   `json:"atRestEncryptionEnabled"`
	Ttl                      int64  `json:"ttl"`
	Status                   string `json:"status,omitempty"` // AVAILABLE, CREATING, DELETING, FAILED, etc.
	HealthMetricsConfig      string `json:"healthMetricsConfig,omitempty"`
}

ApiCacheConfig represents the caching configuration for a GraphQL API.

type ApiKey

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

ApiKey represents an AppSync API key for API_KEY authentication.

type Authenticator

type Authenticator interface {
	// Authenticate validates the request against the API's auth config.
	// Returns a RequestIdentity on success, or an error on failure.
	// The error should be an *protocol.AWSError with code "UnauthorizedException".
	Authenticate(r *http.Request, api *GraphqlAPI) (*RequestIdentity, error)
}

Authenticator validates incoming GraphQL requests based on the API's authentication configuration.

type ChannelNamespace

type ChannelNamespace struct {
	ApiId               string            `json:"apiId,omitempty"`
	Name                string            `json:"name"`
	ChannelNamespaceArn string            `json:"channelNamespaceArn,omitempty"`
	CodeHandlers        string            `json:"codeHandlers,omitempty"`
	Tags                map[string]string `json:"tags,omitempty"`
	Created             string            `json:"created,omitempty"`
	LastModified        string            `json:"lastModified,omitempty"`

	// Complex nested configs stored as raw JSON.
	PublishAuthModes   json.RawMessage `json:"publishAuthModes,omitempty"`
	SubscribeAuthModes json.RawMessage `json:"subscribeAuthModes,omitempty"`
	HandlerConfigs     json.RawMessage `json:"handlerConfigs,omitempty"`
}

ChannelNamespace represents a channel namespace within an Event API.

type CodeError

type CodeError struct {
	ErrorType string          `json:"errorType"`
	Value     string          `json:"value"`
	Location  *SourceLocation `json:"location,omitempty"`
}

CodeError pinpoints a specific error within evaluated JS code.

type CodeEvaluator

type CodeEvaluator interface {
	// Evaluate runs a JS code module and calls the specified function
	// ("request" or "response") with the given context. Returns the
	// function's return value as a JSON string plus any console.log output.
	Evaluate(code string, function string, context map[string]any) (*EvaluationResult, error)
}

CodeEvaluator evaluates APPSYNC_JS JavaScript resolver code.

type DataSource

type DataSource struct {
	DataSourceArn  string `json:"dataSourceArn"`
	Name           string `json:"name"`
	ApiId          string `json:"apiId,omitempty"`
	Type           string `json:"type"`
	Description    string `json:"description,omitempty"`
	ServiceRoleArn string `json:"serviceRoleArn,omitempty"`

	// Backend-specific configs stored as raw JSON.
	DynamodbConfig           json.RawMessage `json:"dynamodbConfig,omitempty"`
	LambdaConfig             json.RawMessage `json:"lambdaConfig,omitempty"`
	HttpConfig               json.RawMessage `json:"httpConfig,omitempty"`
	ElasticsearchConfig      json.RawMessage `json:"elasticsearchConfig,omitempty"`
	OpenSearchServiceConfig  json.RawMessage `json:"openSearchServiceConfig,omitempty"`
	RelationalDatabaseConfig json.RawMessage `json:"relationalDatabaseConfig,omitempty"`
	EventBridgeConfig        json.RawMessage `json:"eventBridgeConfig,omitempty"`
	MetricsConfig            json.RawMessage `json:"metricsConfig,omitempty"`
}

DataSource represents a backend data source attached to a GraphQL API.

type DomainNameConfig

type DomainNameConfig struct {
	DomainName        string `json:"domainName"`
	Description       string `json:"description,omitempty"`
	CertificateArn    string `json:"certificateArn"`
	AppsyncDomainName string `json:"appsyncDomainName,omitempty"` // Generated: d-xxxxx.appsync-api.{region}.{configured host}
	HostedZoneId      string `json:"hostedZoneId,omitempty"`      // Synthetic hosted zone ID.
}

DomainNameConfig represents a custom domain name registered with AppSync.

type EnvironmentVariables

type EnvironmentVariables struct {
	ApiId                string            `json:"apiId"`
	EnvironmentVariables map[string]string `json:"environmentVariables"`
}

EnvironmentVariables holds the key-value pairs for an API's environment variables.

type EvaluationError

type EvaluationError struct {
	Message string `json:"message"`
	// ErrorType is set when the code calls util.error() with an explicit error type.
	ErrorType string `json:"errorType,omitempty"`
	// Data holds additional error data from util.error().
	Data any `json:"data,omitempty"`
	// CodeErrors holds specific line-level errors for APPSYNC_JS evaluation.
	CodeErrors []CodeError `json:"codeErrors,omitempty"`
}

EvaluationError describes a failure during code/template evaluation.

type EvaluationResult

type EvaluationResult struct {
	// EvaluationResult is the serialised return value of the evaluated code/template.
	EvaluationResult string `json:"evaluationResult,omitempty"`
	// Error is set when the evaluation fails (syntax error, runtime exception, etc.).
	Error *EvaluationError `json:"error,omitempty"`
	// Logs contains any console.log or #set($debug) output captured during evaluation.
	Logs []string `json:"logs,omitempty"`
}

EvaluationResult holds the output of EvaluateCode or EvaluateMappingTemplate.

type EventApi

type EventApi struct {
	ApiId        string            `json:"apiId"`
	Name         string            `json:"name"`
	ApiArn       string            `json:"apiArn,omitempty"`
	Dns          map[string]string `json:"dns,omitempty"`
	OwnerContact string            `json:"ownerContact,omitempty"`
	Tags         map[string]string `json:"tags,omitempty"`
	WafWebAclArn string            `json:"wafWebAclArn,omitempty"`
	XrayEnabled  bool              `json:"xrayEnabled"`
	Created      string            `json:"created,omitempty"`

	// EventConfig stored as raw JSON for zero-cost passthrough.
	EventConfig json.RawMessage `json:"eventConfig,omitempty"`
}

EventApi represents an AppSync Event API (separate from GraphQL APIs). Event APIs provide pub/sub messaging over WebSockets via channel namespaces.

type ExecuteParams

type ExecuteParams struct {
	API           *GraphqlAPI
	Schema        *ParsedSchema
	Query         string           `json:"query"`
	Variables     map[string]any   `json:"variables,omitempty"`
	OperationName string           `json:"operationName,omitempty"`
	Identity      *RequestIdentity // Populated by Authenticator.
}

ExecuteParams contains the inputs for a GraphQL execution request.

type ExecuteResult

type ExecuteResult struct {
	Data       json.RawMessage `json:"data"`
	Errors     []GraphQLError  `json:"errors,omitempty"`
	Extensions map[string]any  `json:"extensions,omitempty"`
}

ExecuteResult is the GraphQL response envelope.

type FunctionConfiguration

type FunctionConfiguration struct {
	FunctionId              string `json:"functionId"`
	FunctionArn             string `json:"functionArn"`
	Name                    string `json:"name"`
	ApiId                   string `json:"apiId,omitempty"`
	DataSourceName          string `json:"dataSourceName,omitempty"`
	Description             string `json:"description,omitempty"`
	RequestMappingTemplate  string `json:"requestMappingTemplate,omitempty"`
	ResponseMappingTemplate string `json:"responseMappingTemplate,omitempty"`
	FunctionVersion         string `json:"functionVersion,omitempty"`
	MaxBatchSize            int    `json:"maxBatchSize,omitempty"`
	Code                    string `json:"code,omitempty"`

	Runtime    json.RawMessage `json:"runtime,omitempty"`
	SyncConfig json.RawMessage `json:"syncConfig,omitempty"`
}

FunctionConfiguration represents a resolver function (used in pipeline resolvers).

type GraphQLError

type GraphQLError struct {
	Message    string           `json:"message"`
	Locations  []SourceLocation `json:"locations,omitempty"`
	Path       []any            `json:"path,omitempty"`
	Extensions map[string]any   `json:"extensions,omitempty"`
}

GraphQLError represents a single error in the GraphQL response.

type GraphqlAPI

type GraphqlAPI struct {
	ApiId              string `json:"apiId"`
	Name               string `json:"name"`
	ARN                string `json:"arn"`
	AuthenticationType string `json:"authenticationType"`
	ApiType            string `json:"apiType,omitempty"`
	Visibility         string `json:"visibility,omitempty"`
	XrayEnabled        bool   `json:"xrayEnabled"`
	OwnerContact       string `json:"ownerContact,omitempty"`
	Owner              string `json:"owner,omitempty"`
	WafWebAclArn       string `json:"wafWebAclArn,omitempty"`

	MergedApiExecutionRoleArn string `json:"mergedApiExecutionRoleArn,omitempty"`
	IntrospectionConfig       string `json:"introspectionConfig,omitempty"`
	QueryDepthLimit           int    `json:"queryDepthLimit,omitempty"`
	ResolverCountLimit        int    `json:"resolverCountLimit,omitempty"`

	Uris map[string]string `json:"uris,omitempty"`
	Dns  map[string]string `json:"dns,omitempty"`
	Tags map[string]string `json:"tags,omitempty"`

	// Complex nested configs stored as raw JSON for zero-cost passthrough.
	// This avoids deep Go struct definitions and automatically handles
	// any new fields AWS adds to these objects.
	LogConfig                         json.RawMessage `json:"logConfig,omitempty"`
	UserPoolConfig                    json.RawMessage `json:"userPoolConfig,omitempty"`
	OpenIDConnectConfig               json.RawMessage `json:"openIDConnectConfig,omitempty"`
	LambdaAuthorizerConfig            json.RawMessage `json:"lambdaAuthorizerConfig,omitempty"`
	AdditionalAuthenticationProviders json.RawMessage `json:"additionalAuthenticationProviders,omitempty"`
	EnhancedMetricsConfig             json.RawMessage `json:"enhancedMetricsConfig,omitempty"`
}

GraphqlAPI represents an AppSync GraphQL API. JSON field names match the AWS AppSync REST-JSON wire format exactly.

type Handler

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

Handler holds AppSync handler dependencies.

func (*Handler) AssociateApi

func (h *Handler) AssociateApi(w http.ResponseWriter, r *http.Request)

AssociateApi handles POST /v1/domainnames/{domainName}/apiassociation.

func (*Handler) AssociateMergedGraphqlApi

func (h *Handler) AssociateMergedGraphqlApi(w http.ResponseWriter, r *http.Request)

AssociateMergedGraphqlApi handles POST /v1/sourceApis/{sourceApiIdentifier}/mergedApiAssociations. Associates a merged API with a source API (called from the source API side).

func (*Handler) AssociateSourceGraphqlApi

func (h *Handler) AssociateSourceGraphqlApi(w http.ResponseWriter, r *http.Request)

AssociateSourceGraphqlApi handles POST /v1/mergedApis/{mergedApiIdentifier}/sourceApiAssociations. Associates a source API with a merged API (called from the merged API side).

func (*Handler) CreateApi

func (h *Handler) CreateApi(w http.ResponseWriter, r *http.Request)

CreateApi handles POST /v2/apis.

func (*Handler) CreateApiCache

func (h *Handler) CreateApiCache(w http.ResponseWriter, r *http.Request)

CreateApiCache handles POST /v1/apis/{apiId}/ApiCaches.

func (*Handler) CreateApiKey

func (h *Handler) CreateApiKey(w http.ResponseWriter, r *http.Request)

CreateApiKey handles POST /v1/apis/{apiId}/apikeys.

func (*Handler) CreateChannelNamespace

func (h *Handler) CreateChannelNamespace(w http.ResponseWriter, r *http.Request)

CreateChannelNamespace handles POST /v2/apis/{apiId}/channelNamespaces.

func (*Handler) CreateDataSource

func (h *Handler) CreateDataSource(w http.ResponseWriter, r *http.Request)

CreateDataSource handles POST /v1/apis/{apiId}/datasources.

func (*Handler) CreateDomainName

func (h *Handler) CreateDomainName(w http.ResponseWriter, r *http.Request)

CreateDomainName handles POST /v1/domainnames.

func (*Handler) CreateFunction

func (h *Handler) CreateFunction(w http.ResponseWriter, r *http.Request)

CreateFunction handles POST /v1/apis/{apiId}/functions.

func (*Handler) CreateGraphqlApi

func (h *Handler) CreateGraphqlApi(w http.ResponseWriter, r *http.Request)

CreateGraphqlApi handles POST /v1/apis.

func (*Handler) CreateResolver

func (h *Handler) CreateResolver(w http.ResponseWriter, r *http.Request)

CreateResolver handles POST /v1/apis/{apiId}/types/{typeName}/resolvers.

func (*Handler) CreateType

func (h *Handler) CreateType(w http.ResponseWriter, r *http.Request)

CreateType handles POST /v1/apis/{apiId}/types.

func (*Handler) DeleteApi

func (h *Handler) DeleteApi(w http.ResponseWriter, r *http.Request)

DeleteApi handles DELETE /v2/apis/{apiId}.

func (*Handler) DeleteApiCache

func (h *Handler) DeleteApiCache(w http.ResponseWriter, r *http.Request)

DeleteApiCache handles DELETE /v1/apis/{apiId}/ApiCaches.

func (*Handler) DeleteApiKey

func (h *Handler) DeleteApiKey(w http.ResponseWriter, r *http.Request)

DeleteApiKey handles DELETE /v1/apis/{apiId}/apikeys/{keyId}.

func (*Handler) DeleteChannelNamespace

func (h *Handler) DeleteChannelNamespace(w http.ResponseWriter, r *http.Request)

DeleteChannelNamespace handles DELETE /v2/apis/{apiId}/channelNamespaces/{name}.

func (*Handler) DeleteDataSource

func (h *Handler) DeleteDataSource(w http.ResponseWriter, r *http.Request)

DeleteDataSource handles DELETE /v1/apis/{apiId}/datasources/{name}.

func (*Handler) DeleteDomainName

func (h *Handler) DeleteDomainName(w http.ResponseWriter, r *http.Request)

DeleteDomainName handles DELETE /v1/domainnames/{domainName}.

func (*Handler) DeleteFunction

func (h *Handler) DeleteFunction(w http.ResponseWriter, r *http.Request)

DeleteFunction handles DELETE /v1/apis/{apiId}/functions/{functionId}.

func (*Handler) DeleteGraphqlApi

func (h *Handler) DeleteGraphqlApi(w http.ResponseWriter, r *http.Request)

DeleteGraphqlApi handles DELETE /v1/apis/{apiId}.

func (*Handler) DeleteResolver

func (h *Handler) DeleteResolver(w http.ResponseWriter, r *http.Request)

DeleteResolver handles DELETE /v1/apis/{apiId}/types/{typeName}/resolvers/{fieldName}.

func (*Handler) DeleteType

func (h *Handler) DeleteType(w http.ResponseWriter, r *http.Request)

DeleteType handles DELETE /v1/apis/{apiId}/types/{typeName}.

func (*Handler) DisassociateApi

func (h *Handler) DisassociateApi(w http.ResponseWriter, r *http.Request)

DisassociateApi handles DELETE /v1/domainnames/{domainName}/apiassociation.

func (*Handler) DisassociateMergedGraphqlApi

func (h *Handler) DisassociateMergedGraphqlApi(w http.ResponseWriter, r *http.Request)

DisassociateMergedGraphqlApi handles DELETE /v1/sourceApis/{sourceApiIdentifier}/mergedApiAssociations/{associationId}.

func (*Handler) DisassociateSourceGraphqlApi

func (h *Handler) DisassociateSourceGraphqlApi(w http.ResponseWriter, r *http.Request)

DisassociateSourceGraphqlApi handles DELETE /v1/mergedApis/{mergedApiIdentifier}/sourceApiAssociations/{associationId}.

func (*Handler) EvaluateCode

func (h *Handler) EvaluateCode(w http.ResponseWriter, r *http.Request)

EvaluateCode handles POST /v1/apis/{apiId}/evaluateCode.

func (*Handler) EvaluateMappingTemplate

func (h *Handler) EvaluateMappingTemplate(w http.ResponseWriter, r *http.Request)

EvaluateMappingTemplate handles POST /v1/apis/{apiId}/evaluateMappingTemplate.

func (*Handler) ExecuteGraphQL

func (h *Handler) ExecuteGraphQL(w http.ResponseWriter, r *http.Request)

ExecuteGraphQL handles POST /_appsync/{apiId}/graphql.

func (*Handler) FlushApiCache

func (h *Handler) FlushApiCache(w http.ResponseWriter, r *http.Request)

FlushApiCache handles DELETE /v1/apis/{apiId}/ApiCaches/flush. This is a no-op for the emulator — we don't actually cache resolver results.

func (*Handler) GetApi

func (h *Handler) GetApi(w http.ResponseWriter, r *http.Request)

GetApi handles GET /v2/apis/{apiId}.

func (*Handler) GetApiAssociation

func (h *Handler) GetApiAssociation(w http.ResponseWriter, r *http.Request)

GetApiAssociation handles GET /v1/domainnames/{domainName}/apiassociation.

func (*Handler) GetApiCache

func (h *Handler) GetApiCache(w http.ResponseWriter, r *http.Request)

GetApiCache handles GET /v1/apis/{apiId}/ApiCaches.

func (*Handler) GetChannelNamespace

func (h *Handler) GetChannelNamespace(w http.ResponseWriter, r *http.Request)

GetChannelNamespace handles GET /v2/apis/{apiId}/channelNamespaces/{name}.

func (*Handler) GetDataSource

func (h *Handler) GetDataSource(w http.ResponseWriter, r *http.Request)

GetDataSource handles GET /v1/apis/{apiId}/datasources/{name}.

func (*Handler) GetDomainName

func (h *Handler) GetDomainName(w http.ResponseWriter, r *http.Request)

GetDomainName handles GET /v1/domainnames/{domainName}.

func (*Handler) GetFunction

func (h *Handler) GetFunction(w http.ResponseWriter, r *http.Request)

GetFunction handles GET /v1/apis/{apiId}/functions/{functionId}.

func (*Handler) GetGraphqlApi

func (h *Handler) GetGraphqlApi(w http.ResponseWriter, r *http.Request)

GetGraphqlApi handles GET /v1/apis/{apiId}.

func (*Handler) GetGraphqlApiEnvironmentVariables

func (h *Handler) GetGraphqlApiEnvironmentVariables(w http.ResponseWriter, r *http.Request)

GetGraphqlApiEnvironmentVariables handles GET /v1/apis/{apiId}/environmentVariables.

func (*Handler) GetIntrospectionSchema

func (h *Handler) GetIntrospectionSchema(w http.ResponseWriter, r *http.Request)

GetIntrospectionSchema handles GET /v1/apis/{apiId}/schema. Returns the schema in SDL or JSON introspection format. The ?format query parameter selects the output format (SDL | JSON). Both formats are returned as base64-encoded bytes in the "schema" key.

func (*Handler) GetResolver

func (h *Handler) GetResolver(w http.ResponseWriter, r *http.Request)

GetResolver handles GET /v1/apis/{apiId}/types/{typeName}/resolvers/{fieldName}.

func (*Handler) GetSchemaCreationStatus

func (h *Handler) GetSchemaCreationStatus(w http.ResponseWriter, r *http.Request)

GetSchemaCreationStatus handles GET /v1/apis/{apiId}/schemacreation.

func (*Handler) GetSourceApiAssociation

func (h *Handler) GetSourceApiAssociation(w http.ResponseWriter, r *http.Request)

GetSourceApiAssociation handles GET /v1/mergedApis/{mergedApiIdentifier}/sourceApiAssociations/{associationId}.

func (*Handler) GetType

func (h *Handler) GetType(w http.ResponseWriter, r *http.Request)

GetType handles GET /v1/apis/{apiId}/types/{typeName}.

func (*Handler) HandleWebSocket

func (h *Handler) HandleWebSocket(w http.ResponseWriter, r *http.Request)

HandleWebSocket handles GET /_appsync/{apiId}/realtime — upgrades to WebSocket and manages the AppSync real-time subscription protocol.

func (*Handler) ListApiKeys

func (h *Handler) ListApiKeys(w http.ResponseWriter, r *http.Request)

ListApiKeys handles GET /v1/apis/{apiId}/apikeys.

func (*Handler) ListApis

func (h *Handler) ListApis(w http.ResponseWriter, r *http.Request)

ListApis handles GET /v2/apis.

func (*Handler) ListChannelNamespaces

func (h *Handler) ListChannelNamespaces(w http.ResponseWriter, r *http.Request)

ListChannelNamespaces handles GET /v2/apis/{apiId}/channelNamespaces.

func (*Handler) ListDataSources

func (h *Handler) ListDataSources(w http.ResponseWriter, r *http.Request)

ListDataSources handles GET /v1/apis/{apiId}/datasources.

func (*Handler) ListDomainNames

func (h *Handler) ListDomainNames(w http.ResponseWriter, r *http.Request)

ListDomainNames handles GET /v1/domainnames.

func (*Handler) ListFunctions

func (h *Handler) ListFunctions(w http.ResponseWriter, r *http.Request)

ListFunctions handles GET /v1/apis/{apiId}/functions.

func (*Handler) ListGraphqlApis

func (h *Handler) ListGraphqlApis(w http.ResponseWriter, r *http.Request)

ListGraphqlApis handles GET /v1/apis.

func (*Handler) ListResolvers

func (h *Handler) ListResolvers(w http.ResponseWriter, r *http.Request)

ListResolvers handles GET /v1/apis/{apiId}/types/{typeName}/resolvers.

func (*Handler) ListResolversByFunction

func (h *Handler) ListResolversByFunction(w http.ResponseWriter, r *http.Request)

ListResolversByFunction handles GET /v1/apis/{apiId}/functions/{functionId}/resolvers. Returns all resolvers that reference the given function in their pipeline config.

func (*Handler) ListSourceApiAssociations

func (h *Handler) ListSourceApiAssociations(w http.ResponseWriter, r *http.Request)

ListSourceApiAssociations handles GET /v1/apis/{apiId}/sourceApiAssociations.

func (*Handler) ListTagsForResource

func (h *Handler) ListTagsForResource(w http.ResponseWriter, r *http.Request)

ListTagsForResource handles GET /v1/tags/{resourceArn}.

func (*Handler) ListTypes

func (h *Handler) ListTypes(w http.ResponseWriter, r *http.Request)

ListTypes handles GET /v1/apis/{apiId}/types.

func (*Handler) PutGraphqlApiEnvironmentVariables

func (h *Handler) PutGraphqlApiEnvironmentVariables(w http.ResponseWriter, r *http.Request)

PutGraphqlApiEnvironmentVariables handles PUT /v1/apis/{apiId}/environmentVariables.

func (*Handler) StartSchemaCreation

func (h *Handler) StartSchemaCreation(w http.ResponseWriter, r *http.Request)

StartSchemaCreation handles POST /v1/apis/{apiId}/schemacreation.

In real AWS this is async — the schema is validated and compiled in the background. Our emulator validates, parses, and stores the SDL immediately.

func (*Handler) StartSchemaMerge

func (h *Handler) StartSchemaMerge(w http.ResponseWriter, r *http.Request)

StartSchemaMerge handles POST /v1/mergedApis/{mergedApiIdentifier}/sourceApiAssociations/{associationId}/merge.

func (*Handler) TagResource

func (h *Handler) TagResource(w http.ResponseWriter, r *http.Request)

TagResource handles POST /v1/tags/{resourceArn}.

func (*Handler) UntagResource

func (h *Handler) UntagResource(w http.ResponseWriter, r *http.Request)

UntagResource handles DELETE /v1/tags/{resourceArn}.

func (*Handler) UpdateApi

func (h *Handler) UpdateApi(w http.ResponseWriter, r *http.Request)

UpdateApi handles POST /v2/apis/{apiId}.

func (*Handler) UpdateApiCache

func (h *Handler) UpdateApiCache(w http.ResponseWriter, r *http.Request)

UpdateApiCache handles POST /v1/apis/{apiId}/ApiCaches/update.

func (*Handler) UpdateApiKey

func (h *Handler) UpdateApiKey(w http.ResponseWriter, r *http.Request)

UpdateApiKey handles POST /v1/apis/{apiId}/apikeys/{keyId}.

func (*Handler) UpdateChannelNamespace

func (h *Handler) UpdateChannelNamespace(w http.ResponseWriter, r *http.Request)

UpdateChannelNamespace handles POST /v2/apis/{apiId}/channelNamespaces/{name}.

func (*Handler) UpdateDataSource

func (h *Handler) UpdateDataSource(w http.ResponseWriter, r *http.Request)

UpdateDataSource handles PUT /v1/apis/{apiId}/datasources/{name}.

func (*Handler) UpdateDomainName

func (h *Handler) UpdateDomainName(w http.ResponseWriter, r *http.Request)

UpdateDomainName handles POST /v1/domainnames/{domainName}.

func (*Handler) UpdateFunction

func (h *Handler) UpdateFunction(w http.ResponseWriter, r *http.Request)

UpdateFunction handles POST /v1/apis/{apiId}/functions/{functionId}.

func (*Handler) UpdateGraphqlApi

func (h *Handler) UpdateGraphqlApi(w http.ResponseWriter, r *http.Request)

UpdateGraphqlApi handles POST /v1/apis/{apiId}.

func (*Handler) UpdateResolver

func (h *Handler) UpdateResolver(w http.ResponseWriter, r *http.Request)

UpdateResolver handles POST /v1/apis/{apiId}/types/{typeName}/resolvers/{fieldName}.

func (*Handler) UpdateType

func (h *Handler) UpdateType(w http.ResponseWriter, r *http.Request)

UpdateType handles POST /v1/apis/{apiId}/types/{typeName}.

type MappingTemplateEvaluator

type MappingTemplateEvaluator interface {
	// Evaluate takes a VTL template string and a context map, and returns
	// the rendered output string. The context map is the $context variable
	// available to the template.
	Evaluate(template string, context map[string]any) (string, error)
}

MappingTemplateEvaluator evaluates Apache Velocity Template Language (VTL) mapping templates used by AppSync resolvers and functions.

type ParsedSchema

type ParsedSchema struct {
	// Raw is the original SDL source (for re-serialisation).
	Raw []byte

	// TypeNames lists all type names defined in the schema.
	TypeNames []string

	// QueryType is the name of the root query type (usually "Query").
	QueryType string
	// MutationType is the name of the root mutation type (usually "Mutation").
	MutationType string
	// SubscriptionType is the name of the root subscription type (usually "Subscription").
	SubscriptionType string

	// Opaque holds the parser-specific internal representation (e.g. *ast.Schema).
	// Typed as any to avoid importing the parser package in this interface file.
	Opaque any
}

ParsedSchema holds a parsed and validated GraphQL schema. The implementation should wrap *ast.Schema from gqlparser and expose only what the executor needs — keeping the parser dependency contained.

type QueryExecutor

type QueryExecutor interface {
	// Execute runs a GraphQL operation and returns the result.
	// The executor is responsible for:
	//   1. Parsing and validating the query against the schema.
	//   2. Walking the selection set and resolving each field.
	//   3. Calling the appropriate MappingTemplateEvaluator or CodeEvaluator.
	//   4. Dispatching data source requests (DynamoDB, Lambda, HTTP, NONE).
	//   5. Assembling the response per the GraphQL spec.
	Execute(ctx context.Context, params ExecuteParams) (*ExecuteResult, error)
}

QueryExecutor executes a GraphQL operation (query, mutation, or subscription start) against a parsed schema, using the configured resolvers and data sources.

type RequestIdentity

type RequestIdentity struct {
	// AccountId is the AWS account (always the emulator's configured account).
	AccountId string `json:"accountId,omitempty"`
	// Sub is the authenticated user's subject claim (from JWT).
	Sub string `json:"sub,omitempty"`
	// Issuer is the token issuer URL (Cognito or OIDC).
	Issuer string `json:"issuer,omitempty"`
	// Claims holds the full JWT claims map.
	Claims map[string]any `json:"claims,omitempty"`
}

RequestIdentity holds the authenticated caller's identity, populated by the Authenticator and passed into the resolver context ($context.identity).

type Resolver

type Resolver struct {
	TypeName                string `json:"typeName"`
	FieldName               string `json:"fieldName"`
	ResolverArn             string `json:"resolverArn"`
	ApiId                   string `json:"apiId,omitempty"`
	DataSourceName          string `json:"dataSourceName,omitempty"`
	RequestMappingTemplate  string `json:"requestMappingTemplate,omitempty"`
	ResponseMappingTemplate string `json:"responseMappingTemplate,omitempty"`
	Kind                    string `json:"kind,omitempty"`
	MaxBatchSize            int    `json:"maxBatchSize,omitempty"`
	Code                    string `json:"code,omitempty"`

	PipelineConfig json.RawMessage `json:"pipelineConfig,omitempty"`
	Runtime        json.RawMessage `json:"runtime,omitempty"`
	SyncConfig     json.RawMessage `json:"syncConfig,omitempty"`
	CachingConfig  json.RawMessage `json:"cachingConfig,omitempty"`
	MetricsConfig  json.RawMessage `json:"metricsConfig,omitempty"`
}

Resolver represents a GraphQL field resolver (UNIT or PIPELINE).

type Schema

type Schema struct {
	ApiId      string `json:"apiId"`
	Definition []byte `json:"definition"` // Raw SDL bytes.
	Status     string `json:"status"`     // ACTIVE, PROCESSING, FAILED, etc.
}

Schema holds a GraphQL schema definition for an API.

type SchemaParser

type SchemaParser interface {
	// Parse validates and parses raw SDL bytes into a ParsedSchema.
	// Returns an error with line/column info if the SDL is invalid.
	Parse(sdl []byte) (*ParsedSchema, error)

	// Merge combines multiple SDL sources into a single merged schema.
	// Used by the merged API feature (StartSchemaMerge).
	Merge(schemas [][]byte) (*ParsedSchema, error)
}

SchemaParser parses a GraphQL SDL string into an internal representation that can be used for query validation, introspection, and execution.

type Service

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

Service implements router.Service for AppSync using REST paths.

func New

func New(cfg *config.Config, store state.Store, logger *zap.Logger, clk clock.Clock) *Service

New returns a configured AppSync Service.

func (*Service) Dispatch

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

func (*Service) EventsAPIRouter

func (s *Service) EventsAPIRouter() chi.Router

EventsAPIRouter returns a chi.Router for the AppSync Events API routes that live under /v2/apis. This is mounted by the main router via service-name dispatch so that it coexists with API Gateway v2 on the same path prefix.

func (*Service) HostRouteRewrite

func (s *Service) HostRouteRewrite(r *http.Request, m middleware.HostRouteMatch)

HostRouteRewrite adapts a Host-routed AppSync request ({apiId}.appsync-api.{region}.{base}/graphql) to the emulator's existing /_appsync/{apiId}/graphql path-style route.

func (*Service) InitBus

func (s *Service) InitBus(bus *events.Bus)

InitBus wires the event bus for API lifecycle events.

func (*Service) InitDynamoDBInvoker

func (s *Service) InitDynamoDBInvoker(invoker events.DynamoDBInvoker)

InitDynamoDBInvoker wires the DynamoDB invoker for AMAZON_DYNAMODB data source dispatch.

func (*Service) InitLambdaInvoker

func (s *Service) InitLambdaInvoker(invoker events.FunctionSyncInvoker)

InitLambdaInvoker wires the Lambda invoker for AWS_LAMBDA data source dispatch.

func (*Service) Name

func (s *Service) Name() string

Name satisfies router.Service.

func (*Service) Operations

func (s *Service) Operations() []op.Operation

func (*Service) ReferencesFunction

func (s *Service) ReferencesFunction(ctx context.Context, functionARN string) bool

ReferencesFunction implements the Lambda service's TriggerSource: it reports whether any AWS_LAMBDA data source targets the given function. A raw substring scan of the stored data-source records is deliberate — lambdaConfig embeds the full function ARN, the check runs only when a function settles after a deploy, and the closing-quote delimiter keeps `…function:app` from matching `…function:app-2`.

func (*Service) RegisterRoutes

func (s *Service) RegisterRoutes(r chi.Router)

RegisterRoutes satisfies router.Service. AppSync uses REST paths under /v1/apis (and /v1/domainnames, etc.).

NOTE: /v1/tags routes are NOT registered here — see TagsRouter.

func (*Service) SupportedProtocols

func (s *Service) SupportedProtocols() []codec.Codec

func (*Service) TagsRouter

func (s *Service) TagsRouter() chi.Router

TagsRouter returns a chi.Router for the AppSync tagging routes that live under /v1/tags. This is mounted by the main router alongside other taggable services' tag routers and dispatched by the resourceArn's service segment, since /v1/tags/{resourceArn} is shared across services (e.g. MSK) that each own tagging for their own ARNs.

func (*Service) TargetPrefix

func (s *Service) TargetPrefix() string

type SourceApiAssociation

type SourceApiAssociation struct {
	AssociationId  string `json:"associationId"`
	AssociationArn string `json:"associationArn,omitempty"`
	Description    string `json:"description,omitempty"`
	SourceApiId    string `json:"sourceApiId"`
	SourceApiArn   string `json:"sourceApiArn,omitempty"`
	MergedApiId    string `json:"mergedApiId"`
	MergedApiArn   string `json:"mergedApiArn,omitempty"`

	SourceApiAssociationConfig       json.RawMessage `json:"sourceApiAssociationConfig,omitempty"` // {"mergeType": "MANUAL_MERGE"|"AUTO_MERGE"}
	SourceApiAssociationStatus       string          `json:"sourceApiAssociationStatus,omitempty"` // MERGE_SCHEDULED, MERGE_IN_PROGRESS, MERGE_SUCCESS, MERGE_FAILED, etc.
	SourceApiAssociationStatusDetail string          `json:"sourceApiAssociationStatusDetail,omitempty"`
	LastSuccessfulMergeDate          int64           `json:"lastSuccessfulMergeDate,omitempty"` // Unix epoch seconds.
}

SourceApiAssociation links a source API to a merged API.

type SourceLocation

type SourceLocation struct {
	Line   int `json:"line"`
	Column int `json:"column"`
}

SourceLocation identifies a position in a GraphQL document.

type Store

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

Store wraps state.Store with AppSync-specific helpers.

func (*Store) DeleteAPI

func (st *Store) DeleteAPI(ctx context.Context, apiID string) error

func (*Store) DeleteAPIAndChildren

func (st *Store) DeleteAPIAndChildren(ctx context.Context, apiID string) error

DeleteAPIAndChildren removes an API and all of its sub-resources (schema, keys, data sources, functions, resolvers).

func (*Store) DeleteApiAssociation

func (st *Store) DeleteApiAssociation(ctx context.Context, domainName string) error

func (*Store) DeleteApiCache

func (st *Store) DeleteApiCache(ctx context.Context, apiID string) error

func (*Store) DeleteApiKey

func (st *Store) DeleteApiKey(ctx context.Context, apiID, keyID string) error

func (*Store) DeleteChannelNamespace

func (st *Store) DeleteChannelNamespace(ctx context.Context, apiID, name string) error

func (*Store) DeleteDataSource

func (st *Store) DeleteDataSource(ctx context.Context, apiID, name string) error

func (*Store) DeleteDomainName

func (st *Store) DeleteDomainName(ctx context.Context, domainName string) error

func (*Store) DeleteEventApi

func (st *Store) DeleteEventApi(ctx context.Context, apiID string) error

func (*Store) DeleteFunction

func (st *Store) DeleteFunction(ctx context.Context, apiID, fnID string) error

func (*Store) DeleteResolver

func (st *Store) DeleteResolver(ctx context.Context, apiID, typeName, fieldName string) error

func (*Store) DeleteSourceApiAssociation

func (st *Store) DeleteSourceApiAssociation(ctx context.Context, mergedApiID, assocID string) error

func (*Store) DeleteType

func (st *Store) DeleteType(ctx context.Context, apiID, typeName string) error

func (*Store) GetAPI

func (st *Store) GetAPI(ctx context.Context, apiID string) (*GraphqlAPI, error)

func (*Store) GetApiAssociation

func (st *Store) GetApiAssociation(ctx context.Context, domainName string) (*ApiAssociation, error)

func (*Store) GetApiCache

func (st *Store) GetApiCache(ctx context.Context, apiID string) (*ApiCacheConfig, error)

func (*Store) GetApiKey

func (st *Store) GetApiKey(ctx context.Context, apiID, keyID string) (*ApiKey, error)

func (*Store) GetChannelNamespace

func (st *Store) GetChannelNamespace(ctx context.Context, apiID, name string) (*ChannelNamespace, error)

func (*Store) GetDataSource

func (st *Store) GetDataSource(ctx context.Context, apiID, name string) (*DataSource, error)

func (*Store) GetDomainName

func (st *Store) GetDomainName(ctx context.Context, domainName string) (*DomainNameConfig, error)

func (*Store) GetEnvironmentVariables

func (st *Store) GetEnvironmentVariables(ctx context.Context, apiID string) (*EnvironmentVariables, error)

func (*Store) GetEventApi

func (st *Store) GetEventApi(ctx context.Context, apiID string) (*EventApi, error)

func (*Store) GetFunction

func (st *Store) GetFunction(ctx context.Context, apiID, fnID string) (*FunctionConfiguration, error)

func (*Store) GetResolver

func (st *Store) GetResolver(ctx context.Context, apiID, typeName, fieldName string) (*Resolver, error)

func (*Store) GetSchema

func (st *Store) GetSchema(ctx context.Context, apiID string) (*Schema, error)

func (*Store) GetSourceApiAssociation

func (st *Store) GetSourceApiAssociation(ctx context.Context, mergedApiID, assocID string) (*SourceApiAssociation, error)

func (*Store) GetType

func (st *Store) GetType(ctx context.Context, apiID, typeName string) (*TypeDefinition, error)

func (*Store) ListAPIs

func (st *Store) ListAPIs(ctx context.Context) ([]*GraphqlAPI, error)

func (*Store) ListApiKeys

func (st *Store) ListApiKeys(ctx context.Context, apiID string) ([]*ApiKey, error)

func (*Store) ListChannelNamespaces

func (st *Store) ListChannelNamespaces(ctx context.Context, apiID string) ([]*ChannelNamespace, error)

func (*Store) ListDataSources

func (st *Store) ListDataSources(ctx context.Context, apiID string) ([]*DataSource, error)

func (*Store) ListDomainNames

func (st *Store) ListDomainNames(ctx context.Context) ([]*DomainNameConfig, error)

func (*Store) ListEventApis

func (st *Store) ListEventApis(ctx context.Context) ([]*EventApi, error)

func (*Store) ListFunctions

func (st *Store) ListFunctions(ctx context.Context, apiID string) ([]*FunctionConfiguration, error)

func (*Store) ListResolvers

func (st *Store) ListResolvers(ctx context.Context, apiID, typeName string) ([]*Resolver, error)

func (*Store) ListSourceApiAssociations

func (st *Store) ListSourceApiAssociations(ctx context.Context, mergedApiID string) ([]*SourceApiAssociation, error)

func (*Store) ListTypes

func (st *Store) ListTypes(ctx context.Context, apiID string) ([]*TypeDefinition, error)

func (*Store) PutAPI

func (st *Store) PutAPI(ctx context.Context, api *GraphqlAPI) error

func (*Store) PutApiAssociation

func (st *Store) PutApiAssociation(ctx context.Context, assoc *ApiAssociation) error

func (*Store) PutApiCache

func (st *Store) PutApiCache(ctx context.Context, apiID string, cache *ApiCacheConfig) error

func (*Store) PutApiKey

func (st *Store) PutApiKey(ctx context.Context, apiID string, key *ApiKey) error

func (*Store) PutChannelNamespace

func (st *Store) PutChannelNamespace(ctx context.Context, apiID string, ns *ChannelNamespace) error

func (*Store) PutDataSource

func (st *Store) PutDataSource(ctx context.Context, apiID string, ds *DataSource) error

func (*Store) PutDomainName

func (st *Store) PutDomainName(ctx context.Context, dn *DomainNameConfig) error

func (*Store) PutEnvironmentVariables

func (st *Store) PutEnvironmentVariables(ctx context.Context, apiID string, ev *EnvironmentVariables) error

func (*Store) PutEventApi

func (st *Store) PutEventApi(ctx context.Context, api *EventApi) error

func (*Store) PutFunction

func (st *Store) PutFunction(ctx context.Context, apiID string, fn *FunctionConfiguration) error

func (*Store) PutResolver

func (st *Store) PutResolver(ctx context.Context, apiID string, res *Resolver) error

func (*Store) PutSchema

func (st *Store) PutSchema(ctx context.Context, schema *Schema) error

func (*Store) PutSourceApiAssociation

func (st *Store) PutSourceApiAssociation(ctx context.Context, mergedApiID string, assoc *SourceApiAssociation) error

func (*Store) PutType

func (st *Store) PutType(ctx context.Context, apiID string, td *TypeDefinition) error

type SubscriptionManager

type SubscriptionManager interface {
	// Register adds a new subscription for the given API and connection.
	Register(ctx context.Context, apiID string, subscriptionID string, query string, variables map[string]any) error
	// Unregister removes a subscription.
	Unregister(apiID string, subscriptionID string)
	// Publish fans out a mutation result to all matching subscriptions.
	Publish(ctx context.Context, apiID string, typeName string, data json.RawMessage) error
}

SubscriptionManager tracks active GraphQL subscriptions and delivers real-time updates over WebSocket connections.

type TypeDefinition

type TypeDefinition struct {
	Name        string `json:"name"`
	Arn         string `json:"arn"`
	Description string `json:"description,omitempty"`
	Definition  string `json:"definition"`
	Format      string `json:"format"` // SDL or JSON
}

TypeDefinition represents a GraphQL type definition within an API. Used by the Types API (CreateType, GetType, ListTypes, UpdateType, DeleteType) to allow programmatic type creation and introspection.

Jump to

Keyboard shortcuts

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