Skip to main content

Graphdoc - Generate docs for your GraphQL API

Graphdoc uses your GraphQL schema to generate an HTML page documenting your API. It works with Graphene and Ariadne and any other framework generating GraphQLSchema instances from the graphql-core package.

You can see an example of autogenerated docs using the SWAPI schema in this page

Installation

Install using pip:

pip install graphdoc

Usage

Use graphdoc.to_doc to create HTML documentation from a GraphQLSchema instance or a string with your schema in SDL. Use graphdoc.to_md to create Markdown documentation.

Examples

Django and Graphene

# view.py
from django.http import HttpResponse
from graphene_django.views import GraphQLView
import graphdoc

def graphql_docs(request):
    # For graphene>=3 use schema.graphql_schema
    # html = graphdoc.to_doc(GraphQLView().schema.graphql_schema)
    html = graphdoc.to_doc(GraphQLView().schema)
    return HttpResponse(html, content_type='text/html')


# urls.py
from graphene_django.views import GraphQLView
from .views import graphql_docs

urlpatterns = [
    path('graphql', GraphQLView.as_view(), name='graphql_endpoint'),
    path('docs', graphql_docs, name='graphql_docs'),
]

FastAPI and Ariadne

# schema.py
from ariadne import load_schema_from_path

schema = load_schema_from_path("schema.graphql")


# main.py
from fastapi import FastAPI, Response
from schema import schema
import graphdoc

app = FastAPI()


@app.get("/docs")
async def graphql_docs():
    html = graphdoc.to_doc(schema)
    return Response(content=html, media_type="text/html")

API

graphdoc.to_doc(schema, templates_folder=None, context=None)

schema: GraphQLSchema instance or a str with a schema in SDL.

templates_folder: Optional path to a templates folder. If received, Jinja will look for templates in this folder before falling back to the defaults here.

context: An optional custom dictionary to be passed to the templates variables.

Custom templates

You can find more example apps using custom templates and documenting multiple schemas in the examples folder

Release files for graphdoc 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for graphdoc 0.4.0
File Size Uploaded
graphdoc-0.4.0.tar.gz 12.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for graphdoc 0.4.0
File Interpreter ABI Platform
graphdoc-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 32.8 kB

Release files / graphdoc-0.4.0.tar.gz

Download URL graphdoc-0.4.0.tar.gz
Size 12.5 kB
Tags Source
SHA-256 checksum
How to use checksums
fea0003011591b52fb92da9151f1e63b0afaf7bbb6ae93821dae42f459d56ee6
BLAKE2b-256 checksum
How to use checksums
57e44dafbeada91ee4a381bb82a4259ec2bd95b9a00eed85d0115c352dfb156c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.4

Release files / graphdoc-0.4.0-py3-none-any.whl

Download URL graphdoc-0.4.0-py3-none-any.whl
Size 20.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
08c6d6e0c381114102d4d1a3eb2b54cbc0a3c9f62fe164583e04d8256785cab8
BLAKE2b-256 checksum
How to use checksums
a018ffdea68f87018749cdec57067dddaa0d59b2f442f129bd21819e3888b862
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.4

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.11

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page