axolotl-federation

Axolotl micro-federation architecture - config, schema merging, mergeAxolotls, cross-module dependencies, best practices, and troubleshooting

16 stars

Best use case

axolotl-federation is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Axolotl micro-federation architecture - config, schema merging, mergeAxolotls, cross-module dependencies, best practices, and troubleshooting

Teams using axolotl-federation should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/axolotl-federation/SKILL.md --create-dirs "https://raw.githubusercontent.com/diegosouzapw/awesome-omni-skill/main/skills/development/axolotl-federation/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/axolotl-federation/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How axolotl-federation Compares

Feature / Agentaxolotl-federationStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Axolotl micro-federation architecture - config, schema merging, mergeAxolotls, cross-module dependencies, best practices, and troubleshooting

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

## Micro-Federation

- Each domain has its own `schema.graphql`, `models.ts`, `axolotl.ts`, and `resolvers/`
- `axolotl build` merges schemas into a single supergraph
- Each module has its own generated `models.ts` for local type safety
- All modules built and deployed together (not distributed microservices)

---

## Module Adapter

All modules use `graphqlYogaWithContextAdapter<AppContext>()` for typed context. Only root passes a context builder.

```typescript
// every module's axolotl.ts — type-only, no context builder
import { graphqlYogaWithContextAdapter } from '@aexol/axolotl-graphql-yoga';
import type { AppContext } from '@/src/context.js';
const yogaAdapter = graphqlYogaWithContextAdapter<AppContext>();
export const { createResolvers } = Axolotl(yogaAdapter)<Models, unknown>();

// root src/axolotl.ts — WITH context builder (runs once at startup)
const yogaAdapter = graphqlYogaWithContextAdapter<AppContext>(async (initial) => {
  // verifyAuth here — runs per-request
  return { ...initial, authUser };
});
export const { createResolvers, adapter } = Axolotl(yogaAdapter)<Models, Scalars>();
```

---

## Schema Merging Rules

- **Types merged by name** — fields from all modules combined; conflicting field types cause build failure
- **Root types auto-merged** — `Query`, `Mutation`, `Subscription` fields combined across modules
- **Shared field definitions must match exactly**

---

## No `extend type` — Use `type` Declarations

**Never use `extend type`.** Axolotl merges by name, not SDL extension.

```graphql
# ✅ CORRECT — plain type in each module
# src/modules/users/schema.graphql
type AuthorizedUserQuery {
  me: User @resolver
}

# src/modules/posts/schema.graphql
type AuthorizedUserQuery {
  posts: [Post!]! @resolver
}
# → merged: AuthorizedUserQuery has both `me` and `posts`

# ❌ WRONG
extend type AuthorizedUserQuery {
  posts: [Post!]! @resolver
}
```

Applies to ALL shared types: `Query`, `Mutation`, `AuthorizedUserQuery`, `AuthorizedUserMutation`, and any shared domain types.

---

## Sharing Types Across Modules

Modules can declare the same type name — shared fields must match exactly, unique fields are merged:

```graphql
# users/schema.graphql         # posts/schema.graphql
type User {                     type User {
  _id: String!                    _id: String!  # must match
  email: String!                }
}                               type Post { owner: User! }
# → merged User has _id + email
```

---

## `mergeAxolotls` Behavior

- **Non-overlapping resolvers** — combined into one map
- **Overlapping resolvers** — executed in parallel, results deep-merged
- **Subscriptions** — first-wins; define each in exactly ONE module

```typescript
import { mergeAxolotls } from '@aexol/axolotl-core';
export default mergeAxolotls(authResolvers, usersResolvers /*, postsResolvers */);
```

---

## Auth Gateway & Cross-Module Access

- Auth module exclusively owns `Query.user` / `Mutation.user` — never duplicate in domain modules
- Domain modules add fields to `AuthorizedUserQuery` / `AuthorizedUserMutation`
- Domain resolvers access auth via `context.authUser` (set by context builder):

```typescript
export default createResolvers({
  AuthorizedUserQuery: {
    posts: async ([, , context]) => {
      return prisma.post.findMany({ where: { authorId: context.authUser!._id } });
    },
  },
});
```

---

## When to Run `axolotl build`

Run `cd backend && npx @aexol/axolotl build` after any schema/type/field change or federation config change.

---

## Custom Scalars

Declare `scalar Secret` in each module schema that uses it. Map once in root `axolotl.ts`:

```typescript
Axolotl(yogaAdapter)<Models<{ Secret: number }>, Scalars>();
```

See `axolotl-server` skill for `createScalars` implementation.

Related Skills

bgo

10
from diegosouzapw/awesome-omni-skill

Automates the complete Blender build-go workflow, from building and packaging your extension/add-on to removing old versions, installing, enabling, and launching Blender for quick testing and iteration.

Coding & Development

backend-designer-skill

16
from diegosouzapw/awesome-omni-skill

Design backend architecture, API contracts, core business logic boundaries, and language/framework choices based on architecture/story artifacts. Use when selecting backend stack, auth strategy, and service design.

backend-design

16
from diegosouzapw/awesome-omni-skill

Elite Tier Backend standards, including Vertical Slice Architecture, Zero Trust Security, and High-Performance API protocols.

Backend Database Expert

16
from diegosouzapw/awesome-omni-skill

专注于数据库设计、SQL 优化和迁移策略。

backend-coding

16
from diegosouzapw/awesome-omni-skill

Expert backend development guidance covering Node.js, Python, Java, Go, API design (REST/GraphQL/gRPC), database patterns, authentication, caching, message queues, microservices, and testing. Produces production-ready, scalable, and secure backend code with industry best practices. Use when building APIs, implementing business logic, designing data models, integrating services, or when users mention backend development, server-side code, APIs, databases, or microservices.

backend-architecture

16
from diegosouzapw/awesome-omni-skill

Design and implement scalable backend infrastructure, microservices, and system architecture patterns.

backend-architect

16
from diegosouzapw/awesome-omni-skill

Expert backend architect specializing in scalable API design, microservices architecture, and distributed systems. Masters REST/GraphQL/gRPC APIs, event-driven architectures, service mesh patterns, and modern backend frameworks. Handles service boundary definition, inter-service communication, resilience patterns, and observability. Use PROACTIVELY when creating new backend services or APIs.

Backend API

16
from diegosouzapw/awesome-omni-skill

Manage items, projects, and references in Senticor Project via REST API

babel-config

16
from diegosouzapw/awesome-omni-skill

Generates Babel configuration for JavaScript transpilation in tests. Creates babel.config.js file.

azure-web-pubsub-ts

16
from diegosouzapw/awesome-omni-skill

Build real-time messaging applications using Azure Web PubSub SDKs for JavaScript (@azure/web-pubsub, @azure/web-pubsub-client). Use when implementing WebSocket-based real-time features, pub/sub me...

azure-servicebus-ts

16
from diegosouzapw/awesome-omni-skill

Build messaging applications using Azure Service Bus SDK for JavaScript (@azure/service-bus). Use when implementing queues, topics/subscriptions, message sessions, dead-letter handling, or enterpri...

azure-security-keyvault-secrets-java

16
from diegosouzapw/awesome-omni-skill

Azure Key Vault Secrets Java SDK for secret management. Use when storing, retrieving, or managing passwords, API keys, connection strings, or other sensitive configuration data.