File tree 3 files changed +17
-1
lines changed
Filter options
3 files changed +17
-1
lines changed
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ class GraphQLView(View):
19
19
graphiql = False
20
20
graphiql_version = None
21
21
graphiql_template = None
22
+ graphiql_html_title = None
22
23
middleware = None
23
24
batch = False
24
25
@@ -51,6 +52,7 @@ def render_graphiql(self, params, result):
51
52
result = result ,
52
53
graphiql_version = self .graphiql_version ,
53
54
graphiql_template = self .graphiql_template ,
55
+ graphiql_html_title = self .graphiql_html_title ,
54
56
)
55
57
56
58
format_error = staticmethod (default_format_error )
Original file line number Diff line number Diff line change 12
12
<!DOCTYPE html>
13
13
<html>
14
14
<head>
15
+ <title>{{graphiql_html_title|default("GraphiQL", true)}}</title>
15
16
<style>
16
17
html, body {
17
18
height: 100%;
123
124
</html>'''
124
125
125
126
126
- def render_graphiql (params , result , graphiql_version = None , graphiql_template = None ):
127
+ def render_graphiql (params , result , graphiql_version = None ,
128
+ graphiql_template = None , graphiql_html_title = None ):
127
129
graphiql_version = graphiql_version or GRAPHIQL_VERSION
128
130
template = graphiql_template or TEMPLATE
129
131
130
132
return render_template_string (
131
133
template ,
132
134
graphiql_version = graphiql_version ,
135
+ graphiql_html_title = graphiql_html_title ,
133
136
result = result ,
134
137
params = params
135
138
)
Original file line number Diff line number Diff line change @@ -26,3 +26,14 @@ def test_graphiql_renders_pretty(client):
26
26
).replace ("\" " ,"\\ \" " ).replace ("\n " ,"\\ n" )
27
27
28
28
assert pretty_response in response .data .decode ('utf-8' )
29
+
30
+
31
+ def test_graphiql_default_title (client ):
32
+ response = client .get (url_for ('graphql' ), headers = {'Accept' : 'text/html' })
33
+ assert '<title>GraphiQL</title>' in response .data .decode ('utf-8' )
34
+
35
+
36
+ @pytest .mark .parametrize ('app' , [create_app (graphiql = True , graphiql_html_title = "Awesome" )])
37
+ def test_graphiql_custom_title (client ):
38
+ response = client .get (url_for ('graphql' ), headers = {'Accept' : 'text/html' })
39
+ assert '<title>Awesome</title>' in response .data .decode ('utf-8' )
You can’t perform that action at this time.
0 commit comments