wallee94 / graphdoc

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

"get_type_map" not found in the Schema #1

Closed PriyatamNayak closed 3 years ago

PriyatamNayak commented 3 years ago

File "C:\Repository\django_graphql\env\lib\site-packages\graphdoc\utilities.py", line 43, in build_types_reference type_map = schema.type_map if hasattr(schema, 'type_map') else schema.get_type_map() File "C:\Repository\django_graphql\env\lib\site-packages\graphene\types\schema.py", line 552, in getattr raise AttributeError(f'Type "{type_name}" not found in the Schema')

wallee94 commented 3 years ago

Hey @PriyatamNayak. Thanks for reporting the issue :beetle:

What version of graphene-django and graphene are you using? Also, can you paste how you are passing schema to the graphdoc.to_doc method? That way I can reproduce the error.

PriyatamNayak commented 3 years ago

(env) C:\Repository\django_graphql>pip freeze

Django==3.2 django-filter==2.4.0 django-graphqldoc==0.1.1 djangorestframework==3.12.4 gql==2.0.0 graphdoc==0.2.3 graphene==3.0b7 graphene-django==3.0.0b7 graphene-django-extras==0.5.1 graphql-core==3.1.4 graphql-relay==3.1.0

PriyatamNayak commented 3 years ago

@wallee94 def graphql_docs(request): html = graphdoc.to_doc(GraphQLView().schema) return HttpResponse(html, co

class Query(graphene.ObjectType): all_data = DjangoListObjectField(BloomBergType, description='All Users query')

def resolve_all_data(self, info, **kwargs):
    return BloomBerg.objects.all()

image

wallee94 commented 3 years ago

@PriyatamNayak Thanks, I was able to reproduce the error. The code wasn't compatible with graphene 3 yet. This has been fixed in version 0.2.4.

You will have to change the next line when using graphene>=3:

html = graphdoc.to_doc(GraphQLView().schema)

to:

html = graphdoc.to_doc(GraphQLView().schema.graphql_schema)
PriyatamNayak commented 3 years ago

Thanks for you fix..you are awesome @wallee94

Could you please also tell me ,how can use the graphdocs using fastapi and graphene

PriyatamNayak commented 3 years ago

image

Also how to customize this name... want to change the headings

wallee94 commented 3 years ago

Sure! GraphQLView().schema.graphql_schema and schema in the FastAPI/Ariadne example in the readme are the same class GraphQLSchema, you can just replace it :slightly_smiling_face:

from fastapi import FastAPI, Response
from graphene_django.views import GraphQLView
import graphdoc

app = FastAPI()

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

About changing the header, I want to release this feature in a new version next week, using custom jinja templates, but right now it's not possible.

PriyatamNayak commented 3 years ago

Thanks bro

PriyatamNayak commented 3 years ago

Will wait for the release