File tree Expand file tree Collapse file tree 6 files changed +34
-0
lines changed Expand file tree Collapse file tree 6 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -335,3 +335,17 @@ def format_execution_result(
335
335
response = {"data" : execution_result .data }
336
336
337
337
return FormattedResult (response , status_code )
338
+
339
+
340
+ def _check_jinja (jinja_env : Any ) -> None :
341
+ try :
342
+ from jinja2 import Environment
343
+ except ImportError :
344
+ raise RuntimeError (
345
+ "Attempt to set 'jinja_env' to a value other than None while Jinja2 is not installed.\n "
346
+ "Please install Jinja2 to render GraphiQL with Jinja2.\n "
347
+ "Otherwise set 'jinja_env' to None to use the simple regex renderer."
348
+ )
349
+
350
+ if not isinstance (jinja_env , Environment ):
351
+ raise TypeError ("'jinja_env' has to be of type jinja2.Environment." )
Original file line number Diff line number Diff line change 12
12
from graphql_server import (
13
13
GraphQLParams ,
14
14
HttpQueryError ,
15
+ _check_jinja ,
15
16
encode_execution_results ,
16
17
format_error_default ,
17
18
json_encode ,
@@ -66,6 +67,9 @@ def __init__(self, **kwargs):
66
67
if not isinstance (self .schema , GraphQLSchema ):
67
68
raise TypeError ("A Schema is required to be provided to GraphQLView." )
68
69
70
+ if self .jinja_env is not None :
71
+ _check_jinja (self .jinja_env )
72
+
69
73
def get_root_value (self ):
70
74
return self .root_value
71
75
Original file line number Diff line number Diff line change 12
12
from graphql_server import (
13
13
GraphQLParams ,
14
14
HttpQueryError ,
15
+ _check_jinja ,
15
16
encode_execution_results ,
16
17
format_error_default ,
17
18
json_encode ,
@@ -63,6 +64,9 @@ def __init__(self, **kwargs):
63
64
if not isinstance (self .schema , GraphQLSchema ):
64
65
raise TypeError ("A Schema is required to be provided to GraphQLView." )
65
66
67
+ if self .jinja_env is not None :
68
+ _check_jinja (self .jinja_env )
69
+
66
70
def get_root_value (self ):
67
71
return self .root_value
68
72
Original file line number Diff line number Diff line change 14
14
from graphql_server import (
15
15
GraphQLParams ,
16
16
HttpQueryError ,
17
+ _check_jinja ,
17
18
encode_execution_results ,
18
19
format_error_default ,
19
20
json_encode ,
@@ -67,6 +68,9 @@ def __init__(self, **kwargs):
67
68
if not isinstance (self .schema , GraphQLSchema ):
68
69
raise TypeError ("A Schema is required to be provided to GraphQLView." )
69
70
71
+ if self .jinja_env is not None :
72
+ _check_jinja (self .jinja_env )
73
+
70
74
def get_root_value (self ):
71
75
return self .root_value
72
76
Original file line number Diff line number Diff line change 14
14
from graphql_server import (
15
15
GraphQLParams ,
16
16
HttpQueryError ,
17
+ _check_jinja ,
17
18
encode_execution_results ,
18
19
format_error_default ,
19
20
json_encode ,
@@ -68,6 +69,9 @@ def __init__(self, **kwargs):
68
69
if not isinstance (self .schema , GraphQLSchema ):
69
70
raise TypeError ("A Schema is required to be provided to GraphQLView." )
70
71
72
+ if self .jinja_env is not None :
73
+ _check_jinja (self .jinja_env )
74
+
71
75
def get_root_value (self ):
72
76
return self .root_value
73
77
Original file line number Diff line number Diff line change 11
11
from graphql_server import (
12
12
GraphQLParams ,
13
13
HttpQueryError ,
14
+ _check_jinja ,
14
15
encode_execution_results ,
15
16
format_error_default ,
16
17
json_encode ,
@@ -62,6 +63,9 @@ def __init__(self, **kwargs):
62
63
if not isinstance (self .schema , GraphQLSchema ):
63
64
raise TypeError ("A Schema is required to be provided to GraphQLView." )
64
65
66
+ if self .jinja_env is not None :
67
+ _check_jinja (self .jinja_env )
68
+
65
69
def get_root_value (self ):
66
70
return self .root_value
67
71
You can’t perform that action at this time.
0 commit comments