@fumadocs/graphql@0.1.0
Introduce @fumadocs/graphql
Generate API reference docs from your GraphQL schemas, similar to the OpenAPI/AsyncAPI integration.
import { createGraphQL } from '@fumadocs/graphql/server';
export const graphql = createGraphQL({
input: ['./schema.graphql'],
});Add the generated pages to your source:
import { loader } from 'fumadocs-core/source';
export const source = loader(
{
docs: docs.toFumadocsSource(),
graphql: await graphql.staticSource({
baseDir: 'graphql',
meta: true,
}),
},
{
baseUrl: '/docs',
plugins: [graphql.loaderPlugin()],
},
);And render them with createGraphQLPage from @fumadocs/graphql/ui, with an optional interactive playground:
export const GraphQLPage = createGraphQLPage({
playground: {
url: 'https://api.example.com/graphql',
},
});It accepts SDL files (including extend type), SDL text, introspection results, and GraphQLSchema instances, and generates per-operation & per-type pages with arguments/fields, deprecations, custom directive callouts, and example queries/responses.
Highlights:
- Playground: syntax-highlighted query editor with live validation, a typed variables form generated from argument types, per-endpoint header presets, and GraphQL-aware error display. Configurable via
playground.url,allowUrlEdit,headers,fetcherandrender. - Usage backlinks: type pages list where a type is returned, used as a field, or accepted as input.
- Cross-linking out of the box: pass
baseUrl(thebaseUrlof yourloader()) tostaticSource()and type & operation references link to their pages automatically. - Request snippets: generated cURL & JavaScript tabs next to the example query.