Just a moment...
The unification shines when you add code generation.
import AWSAppSyncClient, createAppSyncLink from 'aws-appsync'; import Auth from 'aws-amplify';class AppSyncClient private client: AWSAppSyncClient<any>;
constructor() this.client = new AWSAppSyncClient( url: process.env.REACT_APP_APPSYNC_ENDPOINT!, region: process.env.REACT_APP_AWS_REGION!, auth: type: 'AMAZON_COGNITO_USER_POOLS', jwtToken: async () => (await Auth.currentSession()).getIdToken().getJwtToken(), , offlineConfig: keyPrefix: 'appsync-offline', , );
getClient() return this.client;
async query<T>(options: any): Promise<T> const result = await this.client.query<T>(options); return result.data; appsync unified repo
async mutate<T>(options: any): Promise<T> const result = await this.client.mutate<T>(options); return result.data;
subscribe<T>(options: any): Observable<T> return this.client.subscribe<T>(options);
export const appSyncClient = new AppSyncClient();
Your stack file unifies everything:
// packages/api/lib/api-stack.ts export class ApiStack extends Stack public readonly graphqlUrl: string; public readonly apiId: string;constructor(scope: Construct, id: string, props: ApiStackProps) super(scope, id, props);
const api = new GraphqlApi(this, 'UnifiedApi', name: 'UnifiedRepoApi', schema: Schema.fromAsset(path.join(__dirname, 'schema.graphql')), authorizationConfig: defaultAuthorization: ... , ); // Inline resolvers (stored as assets) api.createResolver('QueryGetPostJS', typeName: 'Query', fieldName: 'getPost', code: Code.fromAsset(path.join(__dirname, 'resolvers/Query.getPost.js')), runtime: FunctionRuntime.JS_1_0_0, ); this.graphqlUrl = api.graphqlUrl; this.apiId = api.apiId;
1. The Blast Radius of Failure If your Unified API goes down (or hits a throttle limit), everything goes down. In a standard microservice setup, if the "Reviews" service goes down, the "Products" service still works. In a Unified API, a misconfiguration in the schema or a resolver error can take down the entire frontend.
2. Cold Starts on Steroids If your unified API relies on Lambda resolvers to stitch data, you might hit the concurrent execution limits of Lambda, or suffer from cold starts that affect the entire user experience, not just one feature.
A Unified Repository is a single codebase (monorepo structure) that contains everything your AppSync API needs to run, test, and deploy:
The goal: One git push to update your API, resolvers, and infrastructure together. The unification shines when you add code generation