Registry / devops / altair-fastify-plugin

altair-fastify-plugin

JSON →
library8.5.7jsnpmunverified

A Fastify plugin that serves the Altair GraphQL client for interactive query development in Fastify v5+ applications. Version 8.5.7 is current, part of the Altair monorepo with active development. Key differentiators: zero-config setup, supports all Altair features including subscriptions and settings persistence, fully typed with TypeScript. Alternatives like GraphiQL or Playground require separate Express middleware adapters.

npm install altair-fastify-plugin
INSTALL
IMPORT
SIG · ALTAIR-FASTIFY-PLU
A
altair-fastify-plugin
devopsjavascriptv8.5.7
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import altairFastify from 'altair-fastify-plugin'
const altairFastify = require('altair-fastify-plugin')
ESM-only package, CommonJS require() will fail. TypeScript types included.
AltairFastifyPluginOptions
import type { AltairFastifyPluginOptions } from 'altair-fastify-plugin'
import { AltairFastifyPluginOptions } from 'altair-fastify-plugin'
Type-only import to avoid runtime inclusion.
AltairFastifyPlugin
import altairFastify from 'altair-fastify-plugin'
import { AltairFastifyPlugin } from 'altair-fastify-plugin'
Default export is the main plugin function, not a named export.

Registers Altair GraphQL client in a Fastify server with custom base URL, GraphQL endpoint, WebSocket subscriptions endpoint, and initial query.

import Fastify from 'fastify'; import altairFastify from 'altair-fastify-plugin'; const app = Fastify(); await app.register(altairFastify, { baseURL: '/altair', endpointURL: '/graphql', subscriptionsEndpoint: 'ws://localhost:4000/graphql', initialQuery: `query { hello }`, }); await app.listen({ port: 3000 }); console.log('Server listening on port 3000');
Debug
Known issues
breakingRequires Fastify v5; incompatible with Fastify v4.
fix
Upgrade Fastify to v5.x or use altair-fastify-plugin v7.x for Fastify v4.
affects: >=8.0.0
breakingESM-only since v8; no CommonJS support.
fix
Use dynamic import() in CommonJS projects or migrate to ES modules.
affects: >=8.0.0
deprecatedThe `initialVariables` option is deprecated in favor of `initialSettings`.
fix
Use `initialSettings` instead.
affects: >=8.0.0
gotchaPlugin must be registered before routes using GraphQL endpoint to avoid CORS issues.
fix
Ensure app.register(altairFastify, ...) is called before your GraphQL route registration.
affects: >=5.0.0
Errors
Common errors & fixes
TypeError: altairFastify is not a function
Importing as named export instead of default export.
fix
Change import to: import altairFastify from 'altair-fastify-plugin'
Error: Cannot find module 'altair-fastify-plugin'
Package not installed or peer dependency Fastify v5 missing.
fix
Run: npm install altair-fastify-plugin fastify@^5
TypeError: Cannot read properties of undefined (reading 'register')
Calling app.register() on a non-Fastify instance or misordering async/await.
fix
Ensure app is created with Fastify() and register is awaited.
Upgrade
Version history
8.5.7latest on npm
Audit
Dependencies
fastifyrequiredpeer dependency, plugin requires Fastify v5 minimum
Agent activity
26 hits · last 30 days
node
24
OpenAI (training)
2
Resources
altair-fastify-plugin — npm install altair-fastify-plugin · libregistry