Skip to main content

Generate HTML docs for your GraphQL API

Project description

Graphdoc - Generate docs for your GraphQL API

Graphdoc uses you 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

You can use graphdoc.to_doc to convert a GraphQLSchema or a string to an HTML with the docs (or the awaitable graphdoc.to_doc_async if using asyncio).

Django and Graphene

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

def graphql_docs(request):
    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 = await graphdoc.to_doc_async(schema)
    return Response(content=html, media_type="text/html")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

graphdoc-0.1.4.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

graphdoc-0.1.4-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

Details for the file graphdoc-0.1.4.tar.gz.

File metadata

  • Download URL: graphdoc-0.1.4.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.22.0 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.3

File hashes

Hashes for graphdoc-0.1.4.tar.gz
Algorithm Hash digest
SHA256 997d5e6e13dba87ce36fe021979fce9f9e79844242cc094d36f1ca7266b3851e
MD5 07acafa0e9d2dacf6422f9faabcdf6da
BLAKE2b-256 6c1421c99ed29c943b151423f90fab4becd14a152c1d83d1755d6b3a94161fc8

See more details on using hashes here.

File details

Details for the file graphdoc-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: graphdoc-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 17.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.22.0 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.3

File hashes

Hashes for graphdoc-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 c191f4bc93abf12e197bba6d9d973b6ae7edfecd12da93a21577c9dad78ecc3e
MD5 297bc743b6232b4633cedd12364d12a7
BLAKE2b-256 98002e5d70389c61d0d3f7f41eecffc1e8c938b68606210cee066bbbc6c1e16c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page