strawberry
strawberry copied to clipboard
Cannot add headers to default graphiql playground
Is strawberry using an outdated version of the graphiql playground? There is no option to add headers. Is there a way to swap out the graphiql playground with another one?
strawberry version 0.123.3
![Screen Shot 2022-08-04 at 12 34 48 AM](https://user-images.githubusercontent.com/1881761/182770874-16bd891d-1310-4380-8764-6af9f3cd06e6.png)
Is strawberry using an outdated version of the graphiql playground?
Unfortunately we do. The main reason is/was that we want to keep the graphql-explorer extension which we currently integrate using the graphiql-with-extensions package which unfortunately did not get an update in ages.
Is there a way to swap out the graphiql playground with another one?
Yes, you can subclass your integrations view class and provide a different graphiql template path.
In case you use the ASGI integration it would work like this:
from strawberry.asgi import GraphQL
from strawberry.asgi.handlers import HTTPHandler
from starlette.responses import HTMLResponse
from pathlib import Path
from api.schema import schema # import your schema here
class CustomHTTPHandler(HTTPHandler):
def get_graphiql_response(self):
html = Path("path/to/your/graphiql.html").read_text()
return HTMLResponse(html)
class CustomGraphQL(GraphQL):
http_handler_class = CustomHTTPHandler
app = CustomGraphQL(schema)
I also need this feature and am already waiting for https://github.com/strawberry-graphql/strawberry/pull/1889
maybe we can add a flag to enable the preview of GraphiQL 2, since it is taking more time than I expected
Should be closed @patrick91 ?
yes! thanks for checking!