Skip to content

Conversation

@productdevbook
Copy link
Owner

Summary

This PR introduces two major improvements to nitro-graphql:

1. Client-Only Mode (server: false)

A new configuration option that allows using nitro-graphql purely as a client-side type generator without including any server-side GraphQL code.

Use case: When you want to consume external GraphQL APIs without running your own GraphQL server.

graphql: {
  framework: 'graphql-yoga',
  server: false,
  externalServices: [
    {
      name: 'api',
      endpoint: 'https://api.example.com/graphql',
    },
  ],
}

What gets disabled:

  • GraphQL route handlers (/api/graphql, /api/graphql/health)
  • Schema, resolver, and directive scanning
  • Server type generation (#graphql/server)
  • Server scaffold files (schema.ts, config.ts, context.ts)
  • Auto-import utilities (defineResolver, etc.)

What still works:

  • External services client type generation (#graphql/client/{serviceName})
  • SDK generation for external services
  • Document scanning and hot reload

2. Simplified External Services Configuration

Reduced the required configuration from 4+ fields to just 2 fields for the common case.

Before (verbose):

externalServices: [
  {
    name: 'api',
    endpoint: 'https://api.example.com/graphql',
    schema: 'https://api.example.com/graphql',  // same as endpoint!
    downloadSchema: true,  // usually want this
  },
]

After (simple):

externalServices: [
  {
    name: 'api',
    endpoint: 'https://api.example.com/graphql',
  },
]

Smart defaults:

  • schema defaults to endpoint if not specified
  • downloadSchema defaults to true for URL schemas (enables offline caching)

Advanced options still available:

{
  name: 'api',
  endpoint: 'https://api.example.com/graphql',
  schema: './local-schema.graphql',  // use local schema file
  downloadSchema: 'always',  // always check for updates
  headers: { Authorization: 'Bearer xxx' },
  documents: ['graphql/**/*.graphql'],
}

3. Bug Fixes

  • Hot reload for Nitro projects: Fixed missing watchDirs entry for the client directory in Nitro (non-Nuxt) projects
  • Dev reload hook: Added dev:reload hook for client-only mode to ensure file changes trigger type regeneration

Test plan

  • Test server: false with external service - types and SDK generated correctly
  • Test simplified external services config - schema introspection works
  • Test hot reload - file changes trigger regeneration
  • Test offline mode - cached schema used when endpoint unreachable

🤖 Generated with Claude Code

- Add `server: false` option to disable GraphQL server functionality
  - Skip schema, resolver, and directive scanning
  - Skip route handler registration
  - Skip server type generation
  - Skip server scaffold files
  - Still allows external services client types and SDK generation

- Simplify external services configuration
  - Make `schema` optional (defaults to `endpoint`)
  - Auto-enable `downloadSchema` for URL schemas
  - Reduce required config from 4 fields to just 2 (name + endpoint)

- Fix hot reload for Nitro framework client directory
  - Add client directory to watchDirs for Nitro projects

- Add dev:reload hook for client-only mode
  - Ensures file changes trigger client type regeneration

🤖 Generated with [Claude Code](https://claude.ai/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@productdevbook productdevbook changed the title feat: add server: false mode and simplify external services config feat: add server: false mode and simplify external services config Dec 25, 2025
@productdevbook productdevbook merged commit d10c40f into v1 Dec 25, 2025
@productdevbook productdevbook deleted the feat/server-false-and-simplified-external-services branch December 25, 2025 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants