Keep API interfaces simple and focused by avoiding unnecessary input wrapping, extracting context parameters appropriately, and limiting exposure of internal implementation details.
Keep API interfaces simple and focused by avoiding unnecessary input wrapping, extracting context parameters appropriately, and limiting exposure of internal implementation details.
Key principles:
CreateViewFieldInput
over Partial<Entity>
and UpdateInput
over QueryDeepPartialEntity
.workspaceId
in public APIs when users don’t need that information.switchToYearly()
or cancel()
rather than exposing the entire data model.Example:
// ❌ Avoid unnecessary input wrapping
async createPublicDomain(
@Args('input') { domain }: PublicDomainInput,
) { ... }
// ✅ Put properties directly at root level
async createPublicDomain(
@Args('domain') domain: string,
) { ... }
// ❌ Don't mix context with business data
async create(
viewFieldData: Partial<ViewFieldEntity>, // contains workspaceId
) { ... }
// ✅ Extract context parameters
async create(
viewFieldData: CreateViewFieldInput,
workspaceId: string,
) { ... }
This approach reduces API complexity, improves type safety, and maintains clear boundaries between public interfaces and internal implementation details.
Enter the URL of a public GitHub repository