File tree 6 files changed +34
-0
lines changed
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 10
10
from graphql_server import (
11
11
GraphQLParams ,
12
12
HttpQueryError ,
13
+ _check_jinja ,
13
14
encode_execution_results ,
14
15
format_error_default ,
15
16
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 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 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 ,
@@ -64,6 +65,9 @@ def __init__(self, **kwargs):
64
65
if not isinstance (self .schema , GraphQLSchema ):
65
66
raise TypeError ("A Schema is required to be provided to GraphQLView." )
66
67
68
+ if self .jinja_env is not None :
69
+ _check_jinja (self .jinja_env )
70
+
67
71
def get_root_value (self ):
68
72
return self .root_value
69
73
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 ,
@@ -65,6 +66,9 @@ def __init__(self, **kwargs):
65
66
if not isinstance (self .schema , GraphQLSchema ):
66
67
raise TypeError ("A Schema is required to be provided to GraphQLView." )
67
68
69
+ if self .jinja_env is not None :
70
+ _check_jinja (self .jinja_env )
71
+
68
72
def get_root_value (self ):
69
73
return self .root_value
70
74
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