AppSync
AWS AppSync managed GraphQL service for building data-driven APIs with real-time and offline capabilities.
Configuration
| Property | Value |
|---|---|
| Protocol | RestJson1 |
| Signing Name | appsync |
| Persistence | No |
AppSync uses REST-style routing with JSON bodies. Paths follow the pattern /v1/apis/{apiId}/....
Quick Start
Create a GraphQL API, upload a schema, and create an API key for access:
# Create a GraphQL API
API_ID=$(curl -s -X POST http://localhost:4566/v1/apis \
-H "Content-Type: application/json" \
-H "Authorization: AWS4-HMAC-SHA256 Credential=test/20260421/us-east-1/appsync/aws4_request, SignedHeaders=host, Signature=fake" \
-d '{"name":"my-graphql-api","authenticationType":"API_KEY"}' \
| jq -r '.graphqlApi.apiId')
echo "API ID: $API_ID"
# Create an API key
curl -s -X POST http://localhost:4566/v1/apis/$API_ID/ApiKeys \
-H "Content-Type: application/json" \
-H "Authorization: AWS4-HMAC-SHA256 Credential=test/20260421/us-east-1/appsync/aws4_request, SignedHeaders=host, Signature=fake" \
-d '{"description":"Dev key"}'Operations
GraphQL APIs
CreateGraphqlApi— create a new GraphQL API- Input:
name(required),authenticationType(API_KEY,AWS_IAM,OPENID_CONNECT,AMAZON_COGNITO_USER_POOLS),userPoolConfig,openIDConnectConfig,logConfig,tags - Returns:
graphqlApiobject withapiId,arn,uris(GRAPHQL and REALTIME endpoints)
- Input:
GetGraphqlApi— get a specific GraphQL API by ID- Input:
apiId - Returns: full
graphqlApiobject
- Input:
ListGraphqlApis— list all GraphQL APIs- Input: optional
maxResults,nextToken - Returns: paginated
graphqlApislist
- Input: optional
DeleteGraphqlApi— delete a GraphQL API and all associated resources- Input:
apiId
- Input:
UpdateGraphqlApi— update API name or authentication configuration- Input:
apiId, plus any fields to update
- Input:
Schemas
StartSchemaCreation— upload a GraphQL schema definition (SDL format, base64-encoded)- Input:
apiId,definition(base64-encoded SDL string) - Returns:
status(PROCESSING, thenACTIVE)
- Input:
GetSchemaCreationStatus— poll the status of an in-progress schema upload- Input:
apiId - Returns:
statusanddetails
- Input:
API Keys
CreateApiKey— create an API key forAPI_KEYauthentication- Input:
apiId, optionaldescription,expires(Unix timestamp) - Returns:
apiKeywithidandvalue(the secret key string)
- Input:
ListApiKeys— list all API keys for a GraphQL API- Input:
apiId - Returns:
apiKeyslist
- Input:
DeleteApiKey— delete an API key- Input:
apiId,id
- Input:
Data Sources
CreateDataSource— attach a backend data source (Lambda, DynamoDB, HTTP, etc.)- Input:
apiId,name,type(AWS_LAMBDA,AMAZON_DYNAMODB,HTTP,NONE),lambdaConfigordynamodbConfigorhttpConfig - Returns:
dataSourcewithdataSourceArn
- Input:
ListDataSources— list data sources for a GraphQL APIDeleteDataSource— remove a data source
API Keys (extended)
UpdateApiKey— update API key description or expiry- Input:
apiId,id, optionaldescription,expires(Unix timestamp) - Returns: updated
apiKey
- Input:
Resolvers
CreateResolver— map a GraphQL type/field to a data source- Input:
apiId,typeName(e.g.,Query),fieldName(e.g.,getUser),dataSourceName,requestMappingTemplate,responseMappingTemplate - Returns:
resolverobject including mapping templates
- Input:
ListResolvers— list resolvers for a type in a GraphQL API- Input:
apiId,typeName
- Input:
UpdateResolver— update a resolver's data source or mapping templates- Input:
apiId,typeName,fieldName, plus any of:dataSourceName,requestMappingTemplate,responseMappingTemplate - Returns: updated
resolver
- Input:
DeleteResolver— remove a resolver- Input:
apiId,typeName,fieldName
- Input:
GraphQL Types
CreateType— define a GraphQL type (SDL or JSON format)- Input:
apiId,definition(SDL string, e.g.,type User { id: ID! name: String }),format(SDL|JSON) - Type name is automatically extracted from the SDL definition
- Returns:
typewithname,arn,definition,format
- Input:
GetType— get a specific type by name- Input:
apiId,typeName - Returns:
type
- Input:
ListTypes— list all types for a GraphQL API- Input:
apiId - Returns:
typeslist
- Input:
DeleteType— delete a type- Input:
apiId,typeName
- Input:
AppSync Functions (Pipeline Resolvers)
CreateFunction— create an AppSync pipeline function (not Lambda)- Input:
apiId,name,dataSourceName(required), optionaldescription,requestMappingTemplate,responseMappingTemplate,functionVersion - Returns:
functionConfigurationwithfunctionId,functionArn,name
- Input:
GetFunction— get a specific function by ID- Input:
apiId,functionId
- Input:
ListFunctions— list all functions for a GraphQL API- Input:
apiId - Returns:
functionslist
- Input:
UpdateFunction— update a function's configuration- Input:
apiId,functionId, plus any of:name,description,dataSourceName,requestMappingTemplate,responseMappingTemplate
- Input:
DeleteFunction— delete a function- Input:
apiId,functionId
- Input:
API Cache
FlushApiCache— flush the API cache for a GraphQL API (stub: always succeeds)- Input:
apiId
- Input:
Curl Examples
# 1. Create a GraphQL API with Cognito authentication
curl -s -X POST http://localhost:4566/v1/apis \
-H "Content-Type: application/json" \
-H "Authorization: AWS4-HMAC-SHA256 Credential=test/20260421/us-east-1/appsync/aws4_request, SignedHeaders=host, Signature=fake" \
-d '{"name":"my-api","authenticationType":"AMAZON_COGNITO_USER_POOLS","userPoolConfig":{"userPoolId":"us-east-1_abc123","awsRegion":"us-east-1","defaultAction":"ALLOW"}}'
# 2. Upload a schema (schema SDL must be base64-encoded)
SCHEMA='type Query { users: [String] }'
ENCODED=$(echo -n "$SCHEMA" | base64)
curl -s -X POST http://localhost:4566/v1/apis/YOUR_API_ID/schemacreation \
-H "Content-Type: application/json" \
-H "Authorization: AWS4-HMAC-SHA256 Credential=test/20260421/us-east-1/appsync/aws4_request, SignedHeaders=host, Signature=fake" \
-d "{\"definition\":\"$ENCODED\"}"
# 3. Create a Lambda data source
curl -s -X POST http://localhost:4566/v1/apis/YOUR_API_ID/datasources \
-H "Content-Type: application/json" \
-H "Authorization: AWS4-HMAC-SHA256 Credential=test/20260421/us-east-1/appsync/aws4_request, SignedHeaders=host, Signature=fake" \
-d '{"name":"userLambda","type":"AWS_LAMBDA","serviceRoleArn":"arn:aws:iam::000000000000:role/AppSyncRole","lambdaConfig":{"lambdaFunctionArn":"arn:aws:lambda:us-east-1:000000000000:function:get-users"}}'SDK Example
import {
AppSyncClient,
CreateGraphqlApiCommand,
StartSchemaCreationCommand,
CreateApiKeyCommand,
CreateDataSourceCommand,
} from '@aws-sdk/client-appsync';
const appsync = new AppSyncClient({
region: 'us-east-1',
endpoint: 'http://localhost:4566',
credentials: { accessKeyId: 'test', secretAccessKey: 'test' },
});
// Create GraphQL API
const { graphqlApi } = await appsync.send(new CreateGraphqlApiCommand({
name: 'my-api',
authenticationType: 'API_KEY',
}));
const apiId = graphqlApi!.apiId!;
// Upload schema
const schema = 'type Query { users: [String] }';
await appsync.send(new StartSchemaCreationCommand({
apiId,
definition: Buffer.from(schema),
}));
// Create API key
const { apiKey } = await appsync.send(new CreateApiKeyCommand({ apiId }));
console.log('API Key:', apiKey?.id, apiKey?.value);
// Create Lambda data source
await appsync.send(new CreateDataSourceCommand({
apiId,
name: 'myLambda',
type: 'AWS_LAMBDA',
serviceRoleArn: 'arn:aws:iam::000000000000:role/AppSyncRole',
lambdaConfig: {
lambdaFunctionArn: 'arn:aws:lambda:us-east-1:000000000000:function:my-fn',
},
}));Behavior Notes
- AppSync in AWSim manages API metadata, schemas, data sources, and resolvers but does not execute GraphQL queries.
- Schema definitions are stored as-is (base64-encoded) and returned as-is — no SDL parsing or validation is performed.
- Real GraphQL request execution is not supported; use AWSim AppSync for SDK configuration testing and IaC validation.
- State is in-memory only and lost on restart.
- The
urisfield inCreateGraphqlApiresponse includes a placeholder GraphQL endpoint URL.