Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
85dcba5
separate shared types for nuxt/nitro code
dulnan Dec 7, 2025
3d1e187
mcp integration
dulnan Dec 7, 2025
f27bdbe
generate MCP tools
dulnan Dec 7, 2025
bf2d212
conditionally add mcp integration if module is enabled
dulnan Dec 7, 2025
b6f74e4
link to hook-documents.graphql in filePath for hook documents
dulnan Dec 7, 2025
13338b7
add mcp tool to get SDL of type
dulnan Dec 7, 2025
87317f2
add docs resources to MCP
dulnan Dec 7, 2025
28799a4
fix imports
dulnan Dec 13, 2025
6d91809
merge into mcp template
dulnan Dec 13, 2025
1dba066
add @nuxtjs/mcp-toolkit as peer dependency
dulnan Dec 13, 2025
da6309b
remove devServerUrl from runtime config
dulnan Dec 13, 2025
f8b41ff
Merge branch 'main' into feat/mcp-integration
dulnan Dec 13, 2025
8b5b8b0
MCP docs
dulnan Dec 13, 2025
2722c14
only enable MCP integration in dev mode
dulnan Dec 13, 2025
193fd50
generate tests
dulnan Dec 13, 2025
ddd8187
remove source from operation/fragment list/get tools
dulnan Dec 13, 2025
4538ebd
update vitest
dulnan Dec 13, 2025
8997b12
add tool to execute operation via middleware
dulnan Dec 13, 2025
900b584
workaround for watcher not working outside app folder
dulnan Dec 13, 2025
6644915
auto inline fragments when validating documents
dulnan Dec 14, 2025
a57cf1c
update dependencies
dulnan Dec 14, 2025
8ae22ae
don't download schema during Nuxt "prepare"
dulnan Dec 14, 2025
0d2ea5f
allow filtering operations/fragments by name
dulnan Dec 14, 2025
11869dc
add MCP tool to generate operation composable examples
dulnan Dec 14, 2025
b430b92
improve docs for useAsyncGraphqlQuery
dulnan Dec 14, 2025
e96db74
add MCP tool to get module config/state
dulnan Dec 14, 2025
248d55f
disable detailled logging during "Nuxt prepare"
dulnan Dec 14, 2025
d0d2ea8
default to only log errors
dulnan Dec 14, 2025
6c7ef57
prettier
dulnan Dec 14, 2025
4679768
add MCP tool to get server utils example, unify imports
dulnan Dec 14, 2025
4030afe
rename folders
dulnan Dec 14, 2025
961871d
operations-list tool filter by operation type
dulnan Dec 14, 2025
df6c14e
Merge branch 'main' into feat/mcp-integration
dulnan Dec 20, 2025
21224ef
fix 'declare export' in mcp template, create test for it
dulnan Dec 20, 2025
e248be1
only include composable/utils MCP tool if enabled
dulnan Dec 20, 2025
30a7102
fix server types in playground
dulnan Dec 20, 2025
4c0b0d7
move minisearch to devDependencies
dulnan Dec 20, 2025
8415edd
add sirv as dependency
dulnan Dec 20, 2025
75a1185
add eslint rule to check for missing dependencies
dulnan Dec 20, 2025
369a3f8
fix all type template exports
dulnan Dec 20, 2025
c75af0c
workaround for addTypeTemplate Nuxt bug
dulnan Dec 20, 2025
bffbda3
fix type exports in package.json, add metadata
dulnan Dec 20, 2025
5db8922
split adding type references between nuxt and nitro
dulnan Dec 20, 2025
ccb403e
fix playground page for test
dulnan Dec 21, 2025
6e7430a
fix mcp template
dulnan Dec 21, 2025
425c9b7
fix package-lock.json
dulnan Dec 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ jobs:

- name: Run vitest
run: |
npm run dev:build
npm run test:ci

- name: Start dev server
run: |
npm run dev:build
npm run dev:start &

- name: Run cypress E2E tests
Expand Down
129 changes: 129 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with
code in this repository.

## Common Commands

### Development Setup

```sh
npm install # Install dependencies
npm run dev:prepare # Generate types (required before development)
```

### Start Apollo Server (Required for Playground)

```sh
cd apollo && npm install && npm run compile && npm run start
```

### Development

```sh
npm run dev # Start playground at localhost:3000
npm run dev:layers # Start playground-layers
```

### Testing

```sh
npm run test # Run Vitest in watch mode
npm run test:ci # Run Vitest once
npm run test:coverage # Run with coverage report
```

### E2E Testing (Cypress)

```sh
npm run dev:build # Build playground first
npm run dev:start # Start built playground
npm run cypress # Run Cypress tests
npm run cypress:open # Open Cypress UI
```

### Linting & Formatting

```sh
npm run lint # ESLint check
npm run lint:fix # ESLint fix
npm run prettier # Prettier check
npm run prettier:fix # Prettier fix
npm run typecheck # TypeScript check (module + playgrounds)
```

### Build

```sh
npm run prepack # Full module build (styles + module + client)
```

## Architecture

This is a Nuxt 3 module that exposes GraphQL queries and mutations as
fully-typed server-side API routes. GraphQL requests happen only on the server;
no GraphQL documents are included in the client bundle.

### Directory Structure

- `src/` - Module source code
- `module.ts` - Main module entry point
- `build/` - Build-time code generation
- `Collector.ts` - Discovers and validates GraphQL documents
- `SchemaProvider.ts` - Loads/downloads GraphQL schema
- `ModuleHelper.ts` - Manages paths, resolvers, configuration
- `ModuleContext.ts` - Public API for module hooks
- `templates/definitions/` - Code generation templates
- `runtime/` - Runtime code (browser + server)
- `composables/` - Client-side composables (`useGraphqlQuery`,
`useGraphqlMutation`, etc.)
- `server/api/` - Server handlers for `/api/graphql_middleware/query/:name`
and `/api/graphql_middleware/mutation/:name`
- `server/utils/` - Server utilities including `doGraphqlRequest.ts`
- `plugins/` - Nuxt plugins (`provideState.ts`, `devMode.ts`)
- `helpers/` - Shared helpers (`ClientCache.ts`, `queryEncoding.ts`)
- `playground/` - Example Nuxt app for development
- `playground-layers/` - Example with Nuxt layers
- `apollo/` - Apollo server used by playground
- `docs/` - VitePress documentation
- `test/` - Vitest unit tests
- `cypress/` - E2E tests

### Key Patterns

**Code Generation Flow**: GraphQL schema is loaded via `SchemaProvider`,
documents are collected by `Collector`, then `graphql-typescript-deluxe`
generates TypeScript types. Templates in `src/build/templates/definitions/`
produce runtime code and type definitions.

**Server Routes**: Each GraphQL operation becomes an API route. Queries use GET
(`/api/graphql_middleware/query/:name`), mutations use POST
(`/api/graphql_middleware/mutation/:name`).

**Customization Hooks**:

- `nuxt-graphql-middleware:init` - Add documents/files before initialization
- `nuxt-graphql-middleware:build` - React to code generation output

**Server Options** (defined via `defineGraphqlServerOptions`):

- `graphqlEndpoint()` - Dynamic endpoint resolution
- `serverFetchOptions()` - Custom headers/auth
- `onServerResponse()` - Transform responses
- `onServerError()` - Custom error handling
- `doGraphqlRequest()` - Complete request override

**Client Options** (defined via `defineGraphqlClientOptions`):

- `buildClientContext()` - Pass dynamic context (language, locale) to server

### Module Aliases

- `#nuxt-graphql-middleware` - Generated module files
- `#graphql-operations` - Generated GraphQL operation types

### Testing Notes

- Unit tests are in `test/` and use Vitest
- E2E tests are in `cypress/e2e/` and run against the built playground
- Tests require running `npm run dev:prepare` first for type generation
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ A GraphQL client for Nuxt 3.
- Super fast **TypeScript code generation** using
**[graphql-typescript-deluxe](https://github.com/dulnan/graphql-typescript-deluxe)**
- **HMR** for all GraphQL files
- **[MCP integration](https://nuxt-graphql-middleware.dulnan.net/features/mcp)**
to expose schema and operations to AI assistants
- Optional **Client side caching** for query operations
- Modify **request headers**, responses and handle errors
- Integration with **[Nuxt DevTools](https://devtools.nuxtjs.org)**
Expand Down
Loading
Loading