Appsync Repo -
const table = new dynamodb.Table(this, 'ItemsTable', { ... }); const dataSource = api.addDynamoDbDataSource('ItemsDS', table);
my-appsync-repo/ ├── backend/ │ ├── schema/ │ │ └── schema.graphql │ ├── resolvers/ │ │ ├── Query/ │ │ │ ├── getItem.js │ │ │ └── listItems.js │ │ ├── Mutation/ │ │ │ ├── createItem.js │ │ │ └── updateItem.js │ │ └── pipelines/ │ ├── datasources/ │ │ └── datasources.json │ └── functions/ │ └── auth.js ├── infrastructure/ │ ├── appsync-stack.ts (CDK) │ └── config/ ├── tests/ │ ├── unit/ │ └── integration/ ├── scripts/ │ └── deploy.sh └── README.md This is the heart of your API. It defines types, queries, mutations, and subscriptions. Keep it in a single file or split it using #import directives. Example: appsync repo
dataSource.createResolver('getItemResolver', { typeName: 'Query', fieldName: 'getItem', code: appsync.Code.fromAsset('backend/resolvers/Query/getItem.js'), runtime: appsync.FunctionRuntime.JS_1_0_0, }); const table = new dynamodb
// getItem.test.js import { request } from './getItem'; test('request includes user ID from identity', () => { const ctx = { args: { id: '123' }, identity: { claims: { sub: 'user1' } } }; expect(request(ctx).key.userId).toBe('user1'); }); Deploy your API to a test environment and run real queries using aws-appsync or Apollo Client. End-to-End Tests Test the full flow: mutation → subscription → query. CI/CD Pipeline for Your AppSync Repo Your pipeline should automate every step from commit to production. Here is a GitHub Actions workflow for an AppSync repo: Keep it in a single file or split