Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"get_type_map" not found in the Schema #1

Closed
PriyatamNayak opened this issue Apr 26, 2021 · 9 comments
Closed

"get_type_map" not found in the Schema #1

PriyatamNayak opened this issue Apr 26, 2021 · 9 comments
Assignees

Comments

@PriyatamNayak
Copy link

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 wallee94 self-assigned this Apr 26, 2021
@wallee94
Copy link
Owner

Hey @PriyatamNayak. Thanks for reporting the issue 🪲

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
Copy link
Author

PriyatamNayak commented Apr 27, 2021

(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
Copy link
Author

PriyatamNayak commented Apr 27, 2021

@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
Copy link
Owner

@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
Copy link
Author

Thanks for you fix..you are awesome @wallee94

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

@PriyatamNayak
Copy link
Author

image

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

@wallee94
Copy link
Owner

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 🙂

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
Copy link
Author

Thanks bro

@PriyatamNayak
Copy link
Author

Will wait for the release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants