Generate from a live endpoint
The fastest way to create documentation is to point GraphDoc at a live GraphQL endpoint.Install GraphDoc
If you haven’t already, install GraphDoc globally:Or use npx to run without installing:
Generate documentation
Point GraphDoc at your GraphQL endpoint and specify an output directory:The
-e flag specifies the endpoint URL, and -o sets the output directory where HTML files will be generated.Generate from a schema file
If you have your schema defined in a file, you can generate documentation without a running server..graphql,.gql,.graphqls,.gqls- GraphQL Schema Definition Language.json- GraphQL introspection query result.js- JavaScript module exporting a GraphQL schema
For GraphQL IDL files (.graphql), your schema must be valid and interpretable by graphql-js’s buildSchema function.
Using authentication
If your GraphQL endpoint requires authentication, you can pass headers or query parameters:Configuration with package.json
For repeated documentation generation, store your configuration in package.json:Run GraphDoc
Now you can run GraphDoc without any flags:GraphDoc will automatically read the configuration from package.json.
Advanced configuration options
GraphDoc supports many configuration options. Here’s a complete example:package.json
Configuration options explained
Configuration options explained
- endpoint - GraphQL HTTP endpoint URL
- schemaFile - Path to schema file (alternative to endpoint)
- output - Output directory for generated files (required)
- force - Delete output directory if it exists before generating
- verbose - Print detailed information during generation
- baseUrl - Base URL for templates (useful for hosting in subdirectories)
- plugins - Array of plugin paths to use
- template - Custom template directory path
- data - Custom data to inject into templates
- headers - Array of HTTP headers for endpoint requests
- queries - Array of query parameters for endpoint requests
Using custom configuration files
You can use a custom configuration file instead of package.json:Force regeneration
By default, GraphDoc will not overwrite an existing output directory. Use the--force flag to regenerate:
Verbose output
For debugging or to see detailed generation progress, enable verbose mode:- Plugins being used
- Assets being copied
- Each type/directive being rendered
- Output directory information
- Total files generated
Common workflows
Development documentation
Generate docs from your local development server:
Production documentation
Use a schema file to avoid hitting production endpoints:
CI/CD pipeline
Generate and deploy docs automatically:
Version control
Commit schema file, generate docs on deployment:
Next steps
Now that you’ve generated your first documentation, you can:- Customize the output with plugins
- Create custom templates for unique branding
- Integrate documentation generation into your CI/CD pipeline
- Host your documentation on GitHub Pages or other static hosting services