You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How to find code, understand the codebase, and navigate the package dependency graph.
Discovery Strategy
Search symbols first: Use code tool with search_symbols for functions/classes/types
Follow with lookup: Use lookup_symbols to get implementation details
Grep for text: Only for literal strings, comments, config values
Read this doc for architectural context when reviewing PRs or explaining behavior
High-Level Architecture
This is a Lerna monorepo that implements the Amplify Gen 2 Data layer. The system takes a user's GraphQL schema with Amplify directives (like @model, @auth, @hasMany) and transforms it into a fully deployed AWS AppSync API with all necessary infrastructure (DynamoDB tables, resolvers, Lambda functions, IAM roles, etc.) via AWS CDK constructs.
Data Flow
User's GraphQL Schema (with @directives)
│
▼
┌─────────────────────────┐
│ CDK Construct Layer │ amplify-graphql-api-construct / amplify-data-construct
│ (entry point) │
└────────┬────────────────┘
│
▼
┌─────────────────────────┐
│ Transformer Orchestrator│ amplify-graphql-transformer
│ (assembles pipeline) │
└────────┬────────────────┘
│
▼
┌─────────────────────────┐
│ Transform Engine │ amplify-graphql-transformer-core
│ (GraphQLTransform) │ Walks the schema AST, invokes each
│ │ transformer plugin per directive
└────────┬────────────────┘
│ calls each transformer's lifecycle methods:
│ before → object/field/interface → after
│ + preProcess, validate, prepare, transformSchema, generateResolvers
▼
┌─────────────────────────┐
│ Transformer Plugins │ amplify-graphql-*-transformer (one per directive)
│ @model, @auth, @index │ Each reads directives, mutates the TransformerContext:
│ @hasOne, @hasMany, etc │ adds types, resolvers, data sources, IAM policies
└────────┬────────────────┘
│
▼
┌─────────────────────────┐
│ CDK Resources │ NestedStacks with AppSync API, DynamoDB tables,
│ (output) │ Lambda functions, resolvers, IAM roles, etc.
└─────────────────────────┘
Key Concepts
TransformerContext — Shared mutable state passed through the pipeline. Transformers add/modify schema types, resolvers, data sources, and CloudFormation resources on this context.
Directive — A GraphQL schema annotation (e.g., @model, @auth) that a transformer plugin knows how to process.
Data Source Strategy — Configures how a model's data is stored (DynamoDB, SQL/RDS). Set per-model via ModelDataSourceStrategy.
VTL / JS Resolvers — Transformers generate AppSync resolver code (VTL mapping templates or JS runtime resolvers) that gets deployed as part of the API.
Package Catalog
Entry Points (CDK Constructs)
Package (directory)
npm name
Purpose
amplify-graphql-api-construct
@aws-amplify/graphql-api-construct
Main L3 CDK construct (AmplifyGraphqlApi). Entry point for deploying a GraphQL API. Assembles all transformers, runs the pipeline, produces CDK resources.
amplify-data-construct
@aws-amplify/data-construct
Thin alias over graphql-api-construct using "Data" naming for Amplify Gen 2 branding. Re-exports the same construct.
Transformer Pipeline
Package (directory)
npm name
Purpose
amplify-graphql-transformer
@aws-amplify/graphql-transformer
Orchestrator. Assembles the full list of transformer plugins and passes them to the transform engine. This is what the construct calls.
amplify-graphql-transformer-core
@aws-amplify/graphql-transformer-core
Transform engine. Contains GraphQLTransform (walks schema AST, invokes plugins), TransformerContext, TransformerResolver, TransformerOutput, StackManager, and all CDK resource generation logic.
amplify-graphql-transformer-interfaces
@aws-amplify/graphql-transformer-interfaces
TypeScript interfaces and types for the transformer plugin contract. Leaf package — no internal deps. Defines TransformerPluginProvider, TransformerContextProvider, ModelDataSourceStrategy, etc.
Directive Transformer Plugins
Each handles one or more GraphQL directives. All share a common dependency pattern: directives + transformer-core + transformer-interfaces + mapping-template + transformer-common.
Package (directory)
npm name
Directive(s)
What it does
amplify-graphql-model-transformer
@aws-amplify/graphql-model-transformer
@model
Core transformer. Generates CRUD operations, DynamoDB tables (or SQL data sources), queries, mutations, subscriptions, and resolvers. Most other transformers depend on this.
amplify-graphql-auth-transformer
@aws-amplify/graphql-auth-transformer
@auth
Generates authorization rules (API key, Cognito, IAM, OIDC, Lambda). Injects auth logic into resolvers. Depends on model + relational transformers.
amplify-graphql-index-transformer
@aws-amplify/graphql-index-transformer
@index, @primaryKey
Creates DynamoDB GSIs and configures primary keys. Depends on model transformer.
amplify-graphql-relational-transformer
@aws-amplify/graphql-relational-transformer
@hasOne, @hasMany, @belongsTo, @manyToMany
Generates relational connections between models. Depends on model + index transformers.
amplify-graphql-searchable-transformer
@aws-amplify/graphql-searchable-transformer
@searchable
Adds OpenSearch integration for full-text search. Depends on model transformer.
amplify-graphql-function-transformer
@aws-amplify/graphql-function-transformer
@function
Connects fields to Lambda function data sources.
amplify-graphql-http-transformer
@aws-amplify/graphql-http-transformer
@http
Connects fields to HTTP endpoint data sources.
amplify-graphql-predictions-transformer
@aws-amplify/graphql-predictions-transformer
@predictions
Integrates with Amazon AI/ML services (Rekognition, Translate, Polly).
amplify-graphql-default-value-transformer
@aws-amplify/graphql-default-value-transformer
@default
Sets default values on model fields during create mutations.
amplify-graphql-sql-transformer
@aws-amplify/graphql-sql-transformer
@sql
Enables custom SQL statements against RDS data sources. Depends on model transformer.
amplify-graphql-validate-transformer
@aws-amplify/graphql-validate-transformer
@validate
Adds input validation rules to mutation fields.
amplify-graphql-conversation-transformer
@aws-amplify/graphql-conversation-transformer
@conversation
AI conversation routes. Depends on model + relational + index transformers.
amplify-graphql-generation-transformer
@aws-amplify/graphql-generation-transformer
@generation
AI content generation queries.
amplify-graphql-name-mapping-transformer
@aws-amplify/graphql-maps-to-transformer
@mapsTo
Maps model names for schema evolution / renaming. Note: directory name differs from npm name.
Foundation Libraries
Package (directory)
npm name
Purpose
amplify-graphql-directives
@aws-amplify/graphql-directives
Directive SDL definitions (the actual directive @model on OBJECT strings). Leaf package — no deps.
graphql-mapping-template
graphql-mapping-template
AST builder for AppSync VTL resolver mapping templates. Leaf package — no deps.
graphql-transformer-common
graphql-transformer-common
Shared utilities: type helpers, resource name generation, GraphQL AST manipulation. Depends on graphql-mapping-template.
graphql-transformer-core
graphql-transformer-core
Legacy (v1) transform engine. Still used by some e2e tests. Not used in the main Gen 2 pipeline.
amplify-graphql-schema-generator
@aws-amplify/graphql-schema-generator
Generates GraphQL schema from existing SQL database introspection.
Test Packages
Package (directory)
npm name
Purpose
amplify-graphql-transformer-test-utils
@aws-amplify/graphql-transformer-test-utils
Shared test helpers for transformer unit tests. Used as devDep by nearly all transformer packages.
amplify-graphql-schema-test-library
@aws-amplify/graphql-schema-test-library
Library of valid and unsupported schema examples for testing.
auth-transformer → depends on model-transformer + relational-transformer
relational-transformer → depends on model-transformer + index-transformer
conversation-transformer → depends on model-transformer + relational-transformer + index-transformer
index-transformer → depends on model-transformer
searchable-transformer → depends on model-transformer
sql-transformer → depends on model-transformer
External Amplify Dependencies
These @aws-amplify packages are consumed by this repo but maintained in other repositories. Changes to their APIs or behavior can affect this codebase.