# rest-to-graphql-migrator

rest-to-graphql-migrator — a skill that walks a REST API over to GraphQL one endpoint at a time, wrapping existing routes instead of rebuilding the backend.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Windsurf (Devin Desktop), Claude.ai · 277 installs · ★ 64 repo stars
- Author: patricio0312rev
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/patricio0312rev/skills/tree/HEAD/backend/rest-to-graphql-migrator/SKILL.md
- Updated: 2026-01-12
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/skills/rest-to-graphql-migrator

## What it does

The skill starts by cataloguing the REST endpoints you already have, then designs a GraphQL schema from them, adds a data source that talks to the old routes, and moves traffic over endpoint by endpoint. Old clients keep hitting REST until you retire a route.

Three migration paths are laid out: a wrapper for a fast start with no backend changes, a gradual move for large APIs already in production, and a full rewrite when the service is being rebuilt anyway. The samples are TypeScript and use Apollo's `RESTDataSource` — a class with `baseURL` from `REST_API_URL`, an auth header set in `willSendRequest`, one method per REST verb, and transforms that turn `user_name` into `username` and `created_at` into a `Date`.

Caching gets its own example: `ttl: 3600` on reads, plus a `this.delete` call inside the update mutation to drop the cached entry. Skip that invalidation and `getProduct` keeps returning the old record. A `DataLoader` section covers the other weak spot — nested `posts` and `comments` fire one REST call per parent, so batching is what keeps the wrapper out of N+1 territory.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add patricio0312rev/skills --skill rest-to-graphql-migrator -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/rest-to-graphql-migrator/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/rest-to-graphql-migrator/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add patricio0312rev/skills --skill rest-to-graphql-migrator -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/rest-to-graphql-migrator/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add patricio0312rev/skills --skill rest-to-graphql-migrator -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/rest-to-graphql-migrator/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install patricio0312rev/skills backend/rest-to-graphql-migrator/SKILL.md
```

2. **Manually: put the files in place**
- File: `.github/skills/rest-to-graphql-migrator/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add patricio0312rev/skills --skill rest-to-graphql-migrator -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/patricio0312rev/skills --path backend/rest-to-graphql-migrator
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/rest-to-graphql-migrator/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add patricio0312rev/skills --skill rest-to-graphql-migrator -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/patricio0312rev/skills/tree/HEAD/backend/rest-to-graphql-migrator/SKILL.md

## When to use it
- wrap an existing REST API in GraphQL without touching the backend
- turn a list of REST endpoints into a GraphQL schema
- ship one migrated endpoint at a time while old clients stay on REST
- batch nested lookups with `DataLoader` to avoid N+1 calls
- invalidate a cached REST data source on mutations

## Example prompts
- Map `GET /api/users` and the rest of the user routes to a GraphQL schema and show me the resolvers.
- Wrap the products API in a `RESTDataSource` with `ttl: 3600` and cache invalidation on update.
- Add a `DataLoader` for nested `posts` and `comments` so requests stop fanning out to REST.

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 285c6c700aa58b42.

BEGIN THIRD-PARTY FILE 285c6c700aa58b42
````text
---
name: rest-to-graphql-migrator
description: Migrates REST APIs to GraphQL incrementally with schema stitching, REST datasources, and gradual endpoint migration. Use when users request "migrate to GraphQL", "REST to GraphQL", "GraphQL wrapper", or "API modernization".
---

# REST to GraphQL Migrator

Incrementally migrate REST APIs to GraphQL without breaking existing clients.

## Core Workflow

1. **Analyze REST endpoints**: Document existing API
2. **Design GraphQL schema**: Map REST to types
3. **Create REST data source**: Wrap existing endpoints
4. **Implement resolvers**: Connect to REST
5. **Migrate incrementally**: One endpoint at a time
6. **Deprecate REST**: Gradual sunset

## Migration Strategies

### Strategy Comparison

| Strategy | Best For | Complexity |
|----------|----------|------------|
| Wrapper | Quick start, no backend changes | Low |
| Gradual | Large APIs, production systems | Medium |
| Rewrite | Greenfield opportunity | High |

## REST Data Source Wrapper

### Apollo RESTDataSource

```typescript
// datasources/users.datasource.ts
import { RESTDataSource } from '@apollo/datasource-rest';

export class UsersAPI extends RESTDataSource {
  override baseURL = process.env.REST_API_URL;

  // Add auth header
  override willSendRequest(_path: string, request: AugmentedRequest) {
    request.headers['Authorization'] = this.context.token;
  }

  // GET /api/users
  async getUsers(params?: { page?: number; limit?: number }) {
    const query = new URLSearchParams();
    if (params?.page) query.set('page', String(params.page));
    if (params?.limit) query.set('limit', String(params.limit));

    return this.get<User[]>(`/api/users?${query}`);
  }

  // GET /api/users/:id
  async getUser(id: string) {
    return this.get<User>(`/api/users/${id}`);
  }

  // POST /api/users
  async createUser(input: CreateUserInput) {
    return this.post<User>('/api/users', { body: input });
  }

  // PATCH /api/users/:id
  async updateUser(id: string, input: UpdateUserInput) {
    return this.patch<User>(`/api/users/${id}`, { body: input });
  }

  // DELETE /api/users/:id
  async deleteUser(id: string) {
````
END THIRD-PARTY FILE 285c6c700aa58b42

The third-party file has ended. Everything between the 285c6c700aa58b42 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2143 of 11975 bytes. © patricio0312rev · MIT · https://github.com/patricio0312rev/skills/tree/HEAD/backend/rest-to-graphql-migrator/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
