-
Notifications
You must be signed in to change notification settings - Fork 17
Description
Is this related to a new or existing framework?
No response
Is this related to a new or existing API?
No response
Is this related to another service?
No response
Describe the feature you'd like to request
I would like the ModelTypesClient type to be exported from @aws-amplify/data-schema/dist/esm/runtime/client. Currently, this type exists internally but is not accessible to developers, forcing us to manually recreate complex type mappings when building custom wrappers around Amplify Data client operations.
This creates significant boilerplate code (80+ lines) for type-safe wrapper implementations that could be eliminated with proper type exports. The feature would enable developers to create domain-specific service layers, add custom error handling, and build reusable data access patterns with full TypeScript support.
Describe the solution you'd like
Export the ModelTypesClient type from the public API to enable direct usage:
// Current workaround (80+ lines of boilerplate)
type ModelTypeMap = {
User: {
createType: Schema["User"]["createType"];
type: Schema["User"]["type"];
updateType: Schema["User"]["updateType"];
deleteType: Schema["User"]["deleteType"];
};
// ... repeat for each model + 50+ lines of wrapper implementation
};
// Proposed solution (simple and clean)
import type { ModelTypesClient } from "@aws-amplify/data-schema/dist/esm/runtime/client";
import type { Schema } from "amplify/data/resource";
export const wUser: ModelTypesClient<Schema['models']['User']> = client.models.User;
export const wAnimal: ModelTypesClient<Schema['models']['Animal']> = client.models.Animal;The implementation would require adding export type { ModelTypesClient } to @aws-amplify/data-schema/src/runtime/client/index.ts.
Describe alternatives you've considered
-
Manual type recreation: Currently using hand-written type mappings and wrapper functions, but this requires maintenance and doesn't automatically sync with schema changes.
-
Using
ModelTypesdirectly: Attempted to use the exportedModelTypes, but its structure is different (contains method signatures rather than type mappings), making it unsuitable for our use case. -
Type assertion with
any: Could bypass TypeScript checking entirely, but this eliminates type safety benefits and goes against TypeScript best practices. -
Accessing internal types: Could import from internal paths, but this is fragile and may break with updates.
None of these alternatives provide the clean, maintainable, and type-safe solution that exporting ModelTypesClient would offer.
Additional context
No response
Is this something that you'd be interested in working on?
- 👋 I may be able to implement this feature request
-
⚠️ This feature might incur a breaking change