Skip to content

AppSync

CloudMock emulates AWS AppSync, supporting GraphQL API management, data source configuration, resolver and function management, API key lifecycle, and tagging.

OperationStatusNotes
CreateGraphqlApiSupportedCreates a GraphQL API
GetGraphqlApiSupportedReturns API details
ListGraphqlApisSupportedReturns all GraphQL APIs
UpdateGraphqlApiSupportedUpdates API configuration
DeleteGraphqlApiSupportedDeletes a GraphQL API
CreateDataSourceSupportedCreates a data source for an API
GetDataSourceSupportedReturns data source details
ListDataSourcesSupportedReturns all data sources for an API
UpdateDataSourceSupportedUpdates a data source
DeleteDataSourceSupportedDeletes a data source
CreateResolverSupportedCreates a resolver for a type/field
GetResolverSupportedReturns resolver details
ListResolversSupportedReturns all resolvers for a type
UpdateResolverSupportedUpdates a resolver
DeleteResolverSupportedDeletes a resolver
CreateFunctionSupportedCreates a pipeline function
GetFunctionSupportedReturns function details
ListFunctionsSupportedReturns all functions for an API
UpdateFunctionSupportedUpdates a function
DeleteFunctionSupportedDeletes a function
CreateApiKeySupportedCreates an API key
ListApiKeysSupportedReturns all API keys
UpdateApiKeySupportedUpdates an API key expiration
DeleteApiKeySupportedDeletes an API key
TagResourceSupportedAdds tags to a resource
UntagResourceSupportedRemoves tags
ListTagsForResourceSupportedReturns tags for a resource
Terminal window
# Create a GraphQL API
curl -X POST http://localhost:4566/v1/apis \
-H "Content-Type: application/json" \
-d '{
"name": "MyAPI",
"authenticationType": "API_KEY"
}'
# Create an API key
curl -X POST http://localhost:4566/v1/apis/<api-id>/apikeys \
-H "Content-Type: application/json" \
-d '{"description": "dev key"}'
import { AppSyncClient, CreateGraphqlApiCommand, CreateDataSourceCommand, CreateResolverCommand } from '@aws-sdk/client-appsync';
const appsync = new AppSyncClient({
endpoint: 'http://localhost:4566',
region: 'us-east-1',
credentials: { accessKeyId: 'test', secretAccessKey: 'test' },
});
const api = await appsync.send(new CreateGraphqlApiCommand({
name: 'MyAPI', authenticationType: 'API_KEY',
}));
const apiId = api.graphqlApi!.apiId!;
await appsync.send(new CreateDataSourceCommand({
apiId, name: 'usersTable', type: 'AMAZON_DYNAMODB',
dynamodbConfig: { tableName: 'Users', awsRegion: 'us-east-1' },
serviceRoleArn: 'arn:aws:iam::000000000000:role/appsync-role',
}));
await appsync.send(new CreateResolverCommand({
apiId, typeName: 'Query', fieldName: 'getUser',
dataSourceName: 'usersTable',
requestMappingTemplate: '{"version":"2017-02-28","operation":"GetItem","key":{"id":{"S":"$ctx.args.id"}}}',
responseMappingTemplate: '$util.toJson($ctx.result)',
}));
import boto3
appsync = boto3.client('appsync', endpoint_url='http://localhost:4566',
aws_access_key_id='test', aws_secret_access_key='test',
region_name='us-east-1')
api = appsync.create_graphql_api(name='MyAPI', authenticationType='API_KEY')
api_id = api['graphqlApi']['apiId']
appsync.create_data_source(
apiId=api_id, name='usersTable', type='AMAZON_DYNAMODB',
dynamodbConfig={'tableName': 'Users', 'awsRegion': 'us-east-1'},
serviceRoleArn='arn:aws:iam::000000000000:role/appsync-role',
)
appsync.create_resolver(
apiId=api_id, typeName='Query', fieldName='getUser',
dataSourceName='usersTable',
requestMappingTemplate='{"version":"2017-02-28","operation":"GetItem","key":{"id":{"S":"$ctx.args.id"}}}',
responseMappingTemplate='$util.toJson($ctx.result)',
)
keys = appsync.create_api_key(apiId=api_id, description='dev key')
print(keys['apiKey']['id'])
cloudmock.yml
services:
appsync:
enabled: true

No additional service-specific configuration is required.

  • Only the management API is emulated. GraphQL query execution against the API endpoint is not supported.
  • Resolvers and functions are stored as metadata but mapping templates are not executed.
  • Subscriptions (real-time WebSocket) are not implemented.
  • Caching, logging, and WAF integration are not implemented.
  • Merged APIs and custom domains are not implemented.
  • Data source connections to DynamoDB, Lambda, etc. are recorded but not used for query resolution.
CodeHTTP StatusDescription
NotFoundException404The specified API, data source, or resolver does not exist
ConcurrentModificationException409The resource was modified by another request
BadRequestException400The request is not valid
ApiKeyLimitExceededException400Too many API keys for this API
ApiLimitExceededException400Too many APIs in this account