wallee94 / graphdoc

Autogenerate HTML docs for your GraphQL API
https://wallee94.github.io/graphdoc/
MIT License
14 stars 4 forks source link

Generate documentation with strawberry #11

Open Plaoo opened 1 year ago

Plaoo commented 1 year ago

Hi I'm trying to generate documentation with strawberry, copying exactly the code that's in the readme

@app.get("/docs")
async def graphql_docs():

    schema = strawberry.Schema(query=Query, mutation=Mutation).as_str()
    html = graphdoc.to_doc(schema)
    return Response(content=html, media_type="text/html")

Either passing it the schema.gql file or returning it in string form, but the result is the same. (with ariadne)

Traceback

INFO:     x.x.x.x:50139 - "GET /docs HTTP/1.1" 500 Internal Server Error
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/root/eda/gatewayapi_gpl_app/venv/lib/python3.9/site-packages/uvicorn/protocols/http/httptools_impl.py", line 401, in run_asgi
    result = await app(self.scope, self.receive, self.send)
  File "/root/eda/gatewayapi_gpl_app/venv/lib/python3.9/site-packages/uvicorn/middleware/proxy_headers.py", line 78, in __call__
    return await self.app(scope, receive, send)
  File "/root/eda/gatewayapi_gpl_app/venv/lib/python3.9/site-packages/fastapi/applications.py", line 208, in __call__
    await super().__call__(scope, receive, send)
  File "/root/eda/gatewayapi_gpl_app/venv/lib/python3.9/site-packages/starlette/applications.py", line 112, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/root/eda/gatewayapi_gpl_app/venv/lib/python3.9/site-packages/starlette/middleware/errors.py", line 181, in __call__
    raise exc
  File "/root/eda/gatewayapi_gpl_app/venv/lib/python3.9/site-packages/starlette/middleware/errors.py", line 159, in __call__
    await self.app(scope, receive, _send)
  File "/root/eda/gatewayapi_gpl_app/venv/lib/python3.9/site-packages/starlette/middleware/cors.py", line 84, in __call__
    await self.app(scope, receive, send)
  File "/root/eda/gatewayapi_gpl_app/venv/lib/python3.9/site-packages/starlette/exceptions.py", line 82, in __call__
    raise exc
  File "/root/eda/gatewayapi_gpl_app/venv/lib/python3.9/site-packages/starlette/exceptions.py", line 71, in __call__
    await self.app(scope, receive, sender)
  File "/root/eda/gatewayapi_gpl_app/venv/lib/python3.9/site-packages/starlette/routing.py", line 656, in __call__
    await route.handle(scope, receive, send)
  File "/root/eda/gatewayapi_gpl_app/venv/lib/python3.9/site-packages/starlette/routing.py", line 259, in handle
    await self.app(scope, receive, send)
  File "/root/eda/gatewayapi_gpl_app/venv/lib/python3.9/site-packages/starlette/routing.py", line 61, in app
    response = await func(request)
  File "/root/eda/gatewayapi_gpl_app/venv/lib/python3.9/site-packages/fastapi/routing.py", line 226, in app
    raw_response = await run_endpoint_function(
  File "/root/eda_paolo/gatewayapi_gpl_app/venv/lib/python3.9/site-packages/fastapi/routing.py", line 159, in run_endpoint_function
    return await dependant.call(**values)
  File "/root/eda/gatewayapi_gpl_app/main.py", line 40, in graphql_docs
    html = graphdoc.to_doc(schema)
  File "/root/eda/gatewayapi_gpl_app/venv/lib/python3.9/site-packages/graphdoc/render.py", line 52, in to_doc
    return _to_doc(schema, templates_path, context)
  File "/root/eda/gatewayapi_gpl_app/venv/lib/python3.9/site-packages/graphdoc/render.py", line 38, in _to_doc
    reference = utilities.build_types_reference(schema)
  File "/root/eda/gatewayapi_gpl_app/venv/lib/python3.9/site-packages/graphdoc/utilities.py", line 37, in build_types_reference
    type_map = schema.type_map if hasattr(schema, "type_map") else schema.get_type_map()
AttributeError: 'Schema' object has no attribute 'get_type_map'

The schema I pass is really big about 500 lines. I don't know how to solve this problem. I don't know how to solve this problem. Using other services like spectaql I don't have any problem.

aurthurm commented 2 days ago

@Plaoo this was fixed can you use it now