// packages/api/lib/appsync-stack.ts import * as appsync from 'aws-cdk-lib/aws-appsync'; import * as dynamodb from 'aws-cdk-lib/aws-dynamodb'; const api = new appsync.GraphqlApi(this, 'MyUnifiedApi', { name: 'UnifiedBlogApi', schema: appsync.Schema.fromAsset('graphql/schema.graphql'), // single source of truth });
How to share schemas, resolvers, and logic across multiple frontends without losing your mind.
Because everything lives in packages/api , any frontend change that expects a new field forces you to update the resolver in the same PR . The magic of the monorepo happens in package.json scripts. After every schema change, regenerate all clients automatically.
Enter the (monorepo). By managing your AWS AppSync configuration—schema, resolvers (VTL or JavaScript), datasources, and even client code—in a single repository, you can enforce consistency, improve developer experience, and streamline CI/CD. appsync unified repo
If you have ever worked on a project with multiple frontends (React, iOS, Android) talking to a single GraphQL API, you know the pain: Schema drift, duplicated resolver logic, and the "it works on my machine" syndrome for GraphQL transformations.
my-appsync-monorepo/ ├── packages/ │ ├── api/ # AppSync backend definition (CDK or Terraform) │ │ ├── graphql/ │ │ │ ├── schema.graphql │ │ │ └── resolvers/ │ │ │ ├── getPost.js # JS resolvers (AppSync JS runtime) │ │ │ └── listPosts.vtl # or legacy VTL │ │ ├── lib/ │ │ │ └── datasources.ts # DynamoDB, Lambda, HTTP │ │ └── bin/ deploy.ts # CDK stack │ ├── web/ # React/Vue frontend │ │ ├── src/ │ │ └── codegen.yml # GraphQL Code Generator config │ ├── mobile/ # React Native / iOS │ └── shared/ # Common types & validation logic └── scripts/ └── codegen-all.sh # Trigger codegen for all clients Use the AWS Cloud Development Kit (CDK) or Amplify (with CDK under the hood) to define your AppSync API inside packages/api .
Try the official @aws-solutions-constructs/aws-appsync-dynamodb pattern inside a monorepo, or explore graphql-mesh for federation-like patterns. Do you run AppSync in a monorepo? What has been your biggest challenge? Let me know in the comments. // packages/api/lib/appsync-stack
import { util } from '@aws-appsync/utils'; import { get } from 'aws-appsync-resolver-helpers'; // your own helpers export function request(ctx: any) { return { operation: 'GetItem', key: util.dynamodb.toMapValues({ id: ctx.args.id }), }; }
export function response(ctx: any) { return ctx.result; }
{ "scripts": { "codegen": "graphql-codegen --config codegen.yml", "build": "npm run codegen && vite build" } } The codegen.yml points to the local schema file: If you have ever worked on a project
// DynamoDB datasource const postTable = new dynamodb.Table(...); const postDS = api.addDynamoDbDataSource('PostDS', postTable);
In packages/web/package.json :
Start with a simple two-package structure ( api + one client), then expand. The tooling (CDK, GraphQL Codegen, npm workspaces) is mature enough for production today.
Notice from Mega Big Ass . All Models Featured On This Site Are Legal Age. Megabigass.com is not in any way responsible for any damage as a result of linking to pages of other websites. Megabigass.com is not in any way responsible for the content of the pages to which it links. We encourage you to if you ever find a link in question pertaining to illegal or copyrighted to contact us and it will be reviewed promptly for removal from this website.
18 U.S.C. 2257 Record-Keeping Requirements Compliance Statement