Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2128bf5

Browse filesBrowse files
committed
Added GraphiQL template injection
1 parent d42846e commit 2128bf5
Copy full SHA for 2128bf5

File tree

Expand file treeCollapse file tree

3 files changed

+9
-6
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+9
-6
lines changed

‎README.md

Copy file name to clipboardExpand all lines: README.md
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ This will add `/graphql` and `/graphiql` endpoints to your app.
2323
* `root_value`: The `root_value` you want to provide to `executor.execute`.
2424
* `pretty`: Whether or not you want the response to be pretty printed JSON.
2525
* `executor`: The `Executor` that you want to use to execute queries.
26-
* `graphiql`: If `True`, may present [GraphiQL](https://github.com/graphql/graphiql) when loaded directly
27-
from a browser (a useful tool for debugging and exploration).
26+
* `graphiql`: If `True`, may present [GraphiQL](https://github.com/graphql/graphiql) when loaded directly from a browser (a useful tool for debugging and exploration).
27+
* `graphiql_template`: Inject a Jinja template string to customize GraphiQL.
2828

2929
You can also subclass `GraphQLView` and overwrite `get_root_value(self, request)` to have a dynamic root value
3030
per request.

‎flask_graphql/graphqlview.py

Copy file name to clipboardExpand all lines: flask_graphql/graphqlview.py
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class GraphQLView(View):
3030
pretty = False
3131
graphiql = False
3232
graphiql_version = None
33+
graphiql_template = None
3334
middleware = None
3435

3536
methods = ['GET', 'POST', 'PUT', 'DELETE']
@@ -92,6 +93,7 @@ def dispatch_request(self):
9293
if show_graphiql:
9394
return render_graphiql(
9495
graphiql_version=self.graphiql_version,
96+
graphiql_template=self.graphiql_template,
9597
query=query,
9698
variables=variables,
9799
operation_name=operation_name,

‎flask_graphql/render_graphiql.py

Copy file name to clipboardExpand all lines: flask_graphql/render_graphiql.py
+5-4Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,9 @@
123123
</html>'''
124124

125125

126-
def render_graphiql(graphiql_version=None, **kwargs):
127-
if not graphiql_version:
128-
graphiql_version = GRAPHIQL_VERSION
126+
def render_graphiql(graphiql_version=None, graphiql_template=None, **kwargs):
127+
graphiql_version = graphiql_version or GRAPHIQL_VERSION
128+
template = graphiql_template or TEMPLATE
129129

130-
return render_template_string(TEMPLATE, graphiql_version=graphiql_version, **kwargs)
130+
return render_template_string(
131+
template, graphiql_version=graphiql_version, **kwargs)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.