Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
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
Install using pip:
pip install graphdoc
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.
# 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'),
]
# 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")
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.
You can find more example apps using custom templates and documenting multiple schemas in the examples folder
FAQs
Generate HTML docs for your GraphQL API
We found that graphdoc demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.