Repo — Appsync Unified

    import  appSyncClient  from '../client/AppSyncClient';
    import  Observable  from 'zen-observable-ts';
    

    export interface IAppSyncRepository<T, TCreateInput, TUpdateInput> get(id: string): Promise<T>; list(limit?: number, nextToken?: string): Promise< items: T[]; nextToken?: string >; create(input: TCreateInput): Promise<T>; update(id: string, input: TUpdateInput): Promise<T>; delete(id: string): Promise<string>; subscribeToCreated(): Observable<T>; subscribeToUpdated(): Observable<T>; subscribeToDeleted(): Observable<string>;

    export class AppSyncUnifiedRepository<T, TCreateInput, TUpdateInput> implements IAppSyncRepository<T, TCreateInput, TUpdateInput> { constructor( private readonly queries: get: string; list: string; create: string; update: string; delete: string; , private readonly subscriptions: onCreate: string; onUpdate: string; onDelete: string; , private readonly modelName: string ) {}

    async get(id: string): Promise<T> try const result = await appSyncClient.query< [key: string]: T >( query: this.queries.get, variables: id , fetchPolicy: 'network-only', ); return result[get$this.modelName]; catch (error) throw new Error(Failed to get $this.modelName: $error.message);

    async list(limit = 100, nextToken?: string): Promise< items: T[]; nextToken?: string > try const result = await appSyncClient.query< [key: string]: items: T[]; nextToken?: string ; >( query: this.queries.list, variables: limit, nextToken , ); return result[list$this.modelNames]; catch (error) throw new Error(Failed to list $this.modelNames: $error.message); appsync unified repo

    async create(input: TCreateInput): Promise<T> try const result = await appSyncClient.mutate< [key: string]: T >( mutation: this.queries.create, variables: input , ); return result[create$this.modelName]; catch (error) throw new Error(Failed to create $this.modelName: $error.message);

    async update(id: string, input: TUpdateInput): Promise<T> try const result = await appSyncClient.mutate< [key: string]: T >( mutation: this.queries.update, variables: input: id, ...input , ); return result[update$this.modelName]; catch (error) throw new Error(Failed to update $this.modelName: $error.message);

    async delete(id: string): Promise<string> try const result = await appSyncClient.mutate< [key: string]: string >( mutation: this.queries.delete, variables: input: id , ); return result[delete$this.modelName]; catch (error) throw new Error(Failed to delete $this.modelName: $error.message); import appSyncClient from '

    subscribeToCreated(): Observable<T> return appSyncClient.subscribe<T>( query: this.subscriptions.onCreate, );

    subscribeToUpdated(): Observable<T> return appSyncClient.subscribe<T>( query: this.subscriptions.onUpdate, );

    subscribeToDeleted(): Observable<string> return appSyncClient.subscribe<string>( query: this.subscriptions.onDelete, ); } async list(limit = 100, nextToken


    You don’t need to rewrite everything. Start by:

    An e‑commerce company with separate teams for User Profile, Inventory, and Orders each owns a folder in the unified repo. Their pipeline:

    When the Orders team adds a new priority field to Order, only their folder and the composed API are re-deployed — but the change is atomic in the repo.