-
-
Notifications
You must be signed in to change notification settings - Fork 531
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
Unable to disable graphiql by graphql_ide=None #3327
Comments
You can pass |
@erikwrede maybe we should also support None? |
Thanks for your attention and fast reply. I tried graphiql=False but I still failed. But then I noticed an interesting phenomenon. I'm serving it with a uvicorn thread under gunicorn. I'm using django channels and I think this might have something to do with it. Can you take a look at this one more time? |
I found the solution by myself. When I use channels, graphiql option should be given for GraphQLHTTPConsumer. The following worked for me. Thanks. |
Keeping this open as this seems like a good case for a DevX improvement. @patrick91 I think =None is also an option. |
Hello! I was wondering if I could fix this. However, with the following code snippet I see no graphiql_ide. Can you check if it's fixed by now? My from django.urls import path
from strawberry.django.views import AsyncGraphQLView
import typing
import strawberry
@strawberry.type
class Book:
title: str
author: str
def get_books():
return [
Book(
title="The Great Gatsby",
author="F. Scott Fitzgerald",
),
]
@strawberry.type
class Query:
books: typing.List[Book] = strawberry.field(resolver=get_books)
schema = strawberry.Schema(query=Query)
urlpatterns = [
path("graphql/", AsyncGraphQLView.as_view(schema=schema,
graphql_ide=None)),
] |
@Birdi7 I don't think it has been fixed yet 😊 https://github.com/strawberry-graphql/strawberry/blob/main/strawberry/http/ides.py#L9-L30 we don't check for None here |
@patrick91 thank you for the entrypoint! here is what I've found. I still believe this is fixed. How's it working? This code in strawberry/strawberry/http/sync_base_view.py Line 170 in 9500eab
It's evaluated the same for both False and None values.
So, |
Hi. I'm using strawberry graphql library for my project.
I'm using async view and I tried to disable graphql ide by giving a parameter like following.
`
from strawberry.django.views import AsyncGraphQLView
class MyGraphQLView(AsyncGraphQLView):
...
urlpatterns = [
path("graphql/", MyGraphQLView.as_view(schema=schema, graphql_ide=None)),
]
`
But I still see graphiql is loaded when I accessed /graphql/ via GET method.
I looked into the details and I found that graphql_ide variable remains as a default value ("graphiql") in AsyncBaseHTTPView.run method.
`
print(self.graphql_ide) # "graphiql was printed though I gave a parameter graphql_ide=None to AsyncGraphQLView.asView function.
if self.should_render_graphql_ide(request_adapter):
if self.graphql_ide:
return await self.render_graphql_ide(request)
else:
raise HTTPException(404, "Not Found")
`
And I'm using subscription. So my asgi.py file is like following.
`
urlpatterns = [re_path(r"graphql", GraphQLWSConsumer.as_asgi(schema=schema))]
gql_http_consumer = AuthMiddlewareStack(GraphQLHTTPConsumer.as_asgi(schema=schema))
gql_ws_consumer = GraphQLWSConsumer.as_asgi(schema=schema)
app = ProtocolTypeRouter(
{
"http": URLRouter(
[
re_path("^graphql", gql_http_consumer),
re_path("^", django_asgi_app),
]
),
"websocket": AuthMiddlewareStack(URLRouter(urlpatterns))
}
)
`
System Information
Upvote & Fund
The text was updated successfully, but these errors were encountered: