How ardatan/graphql-mesh works
Main Components
• CLI & Config Loader (packages/compose-cli, legacy CLI)
• Core Engine (packages/fusion/composition + cross-helpers + utils)
• Schema Loaders (packages/loaders/*)
• Transforms & Plugins (packages/fusion/composition/src/transforms and packages/plugins/*)
• Transports / Source Handlers (packages/transports/* and legacy/handlers/*)
• Cache Adapters (packages/cache/*)
• Data Sources (external GraphQL services, REST/OpenAPI, gRPC, SOAP, databases like MySQL/SQLite/Neo4j)
• Website / Docs (website/)
• E2E & Example Projects (e2e/, examples/)
Relationships & Data Flow
1) Developer invokes graphql-mesh CLI → reads .meshrc.yml or programmatic config.
2) CLI/compose-cli loads configuration schemas (declarations.d.ts, config-schema).
3) Core Engine calls each Schema Loader:
– Loaders parse API spec (OpenAPI, JSON Schema, OData, etc.) and produce GraphQL type definitions.
– Loaders may use Transports to fetch remote schemas or data (e.g., HTTP, gRPC, SOAP, SQL drivers).
4) Loaded schemas enter the Transform pipeline:
– Namespace/prune/hoist/prefix/federation transforms (packages/fusion).
– Plugin hooks apply execution-time behavior (caching, rate-limit, mock, live queries, metrics).
5) Fusion/composition merges all sub-schemas into a single unified GraphQL schema or a Federation supergraph.
6) Mesh spins up a GraphQL server endpoint:
– Incoming GraphQL queries hit the execution layer.
– Each field resolver uses Transports + Cache + Plugin pipeline to fetch from underlying Data Sources.
7) Results return to client.
Architectural Patterns & Principles
• Plugin-Based Pipeline: Loaders, Transforms, Plugins, Transports are independent packages.
• Monorepo/Yarn Workspaces: Each package is versioned/co-developed centrally.
• Composition Pipeline: Clear separation between schema-generation (static) and query execution (dynamic).
• DI/Extensibility: New handlers or plugins drop into packages/loaders, packages/plugins, or packages/transports.
Key Technologies
• Node.js + TypeScript
• Yarn v4 Workspaces / PnP
• Jest for unit & e2e tests
• Next.js for the website (static-generated docs)
• GitHub Actions for CI/CD, Docker for containerization